Skip to content

Commit 9db5113

Browse files
author
Mathias Frøhlich
authored
Merge pull request #2 from blockfrost/PyPI
PyPi and API version v0.1.30
2 parents 4738b23 + 5b7e7db commit 9db5113

27 files changed

+715
-300
lines changed

.github/workflows/python-package.yml renamed to .github/workflows/package-test.yml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
2-
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
3-
4-
name: Python package
1+
name: Package Test
52

63
on:
74
push:
8-
branches: [ master ]
5+
branches:
6+
- '**'
97
pull_request:
108
branches: [ master ]
119

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#https://packaging.python.org/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/
2+
name: Publish Python 🐍 distributions 📦 to PyPI and TestPyPI
3+
4+
on: push
5+
6+
jobs:
7+
build-n-publish:
8+
9+
name: Build and publish Python 🐍 distributions 📦 to PyPI and TestPyPI
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@master
13+
- name: Set up Python 3.9
14+
uses: actions/setup-python@v1
15+
with:
16+
python-version: 3.9
17+
- name: Install pypa/build
18+
run: >-
19+
python -m
20+
pip install
21+
build
22+
--user
23+
- name: Build a binary wheel and a source tarball
24+
run: >-
25+
python -m
26+
build
27+
--sdist
28+
--wheel
29+
--outdir dist/
30+
.
31+
- name: Publish distribution 📦 to Test PyPI
32+
uses: pypa/gh-action-pypi-publish@master
33+
with:
34+
skip_existing: true
35+
user: __token__
36+
password: ${{ secrets.TESTNET_PYPI_API_TOKEN }}
37+
repository_url: https://test.pypi.org/legacy/
38+
- name: Publish distribution 📦 to PyPI
39+
if: startsWith(github.ref, 'refs/tags')
40+
uses: pypa/gh-action-pypi-publish@master
41+
with:
42+
user: __token__
43+
password: ${{ secrets.PYPI_API_TOKEN }}

README.md

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
[![Python package](https://github.com/blockfrost/blockfrost-python/actions/workflows/python-package.yml/badge.svg)](https://github.com/blockfrost/blockfrost-python/actions/workflows/python-package.yml)
1+
[![Package Test](https://github.com/blockfrost/blockfrost-python/actions/workflows/package-test.yml/badge.svg)](https://github.com/blockfrost/blockfrost-python/actions/workflows/package-test.yml)
2+
[![PyPI Latest Release](https://img.shields.io/pypi/v/blockfrost-python.svg)](https://pypi.org/project/blockfrost-python/)
3+
[![Package Status](https://img.shields.io/pypi/status/blockfrost-python.svg)](https://pypi.org/project/blockfrost-python/)
4+
[![License](https://img.shields.io/pypi/l/blockfrost-python.svg)](https://github.com/blockfrost/blockfrost-python/blob/master/LICENSE)
5+
26

37
<img src="https://blockfrost.io/images/logo.svg" width="250" align="right" height="90">
48

@@ -26,7 +30,7 @@ your API key.
2630
## Installation
2731

2832
```console
29-
$ pip install git+https://github.com/blockfrost/blockfrost-python
33+
$ pip install blockfrost-python
3034
```
3135

3236
<br/>
@@ -47,8 +51,14 @@ api = BlockFrostApi(
4751
)
4852
try:
4953
health = api.health()
50-
print(health.is_healthy) # True
51-
54+
print(health) # prints object: HealthResponse(is_healthy=True)
55+
health = api.health(return_type='json') # Can be useful if python wrapper is behind api version
56+
print(health) # prints json: {"is_healthy":True}
57+
health = api.health(return_type='pandas')
58+
print(health) # prints Dataframe: is_healthy
59+
# 0 True
60+
61+
5262
account_rewards = api.account_rewards(
5363
stake_address='stake1ux3g2c9dx2nhhehyrezyxpkstartcqmu9hk63qgfkccw5rqttygt7',
5464
count=20,
@@ -59,7 +69,7 @@ try:
5969
account_rewards = api.account_rewards(
6070
stake_address='stake1ux3g2c9dx2nhhehyrezyxpkstartcqmu9hk63qgfkccw5rqttygt7',
6171
count=20,
62-
gather_pages=True,
72+
gather_pages=True, # will collect all pages
6373
)
6474
print(account_rewards[0].epoch) # prints 221
6575
print(len(account_rewards)) # prints 57

blockfrost/api/__init__.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,15 @@ class RootResponse:
1919
version: str
2020

2121
@object_request_wrapper(RootResponse)
22-
def root(self):
22+
def root(self, **kwargs):
2323
"""
2424
Root endpoint has no other function than to point end users to documentation.
2525
2626
https://docs.blockfrost.io/#tag/Health/paths/~1/get
27-
28-
:returns: RootResponse object.
29-
:rtype: RootResponse
27+
:param return_type: Optional. "object", "json" or "pandas". Default: "object".
28+
:type return_type: str
29+
:returns RootResponse object.
30+
:rtype RootResponse
3031
:raises ApiError: If API fails
3132
:raises Exception: If the API response is somehow malformed.
3233
"""
@@ -60,6 +61,7 @@ def root(self):
6061
address, \
6162
address_total, \
6263
address_utxos, \
64+
address_utxos_asset, \
6365
address_transactions
6466
from .cardano.assets import \
6567
assets, \
@@ -122,4 +124,7 @@ def root(self):
122124
from .cardano.scripts import \
123125
scripts, \
124126
script, \
125-
script_redeemers
127+
script_json, \
128+
script_cbor, \
129+
script_redeemers, \
130+
script_datum

blockfrost/api/cardano/accounts.py

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,17 @@ class AccountResponse:
1818

1919

2020
@object_request_wrapper(AccountResponse)
21-
def accounts(self, stake_address: str):
21+
def accounts(self, stake_address: str, **kwargs):
2222
"""
2323
Obtain information about a specific networkStake account.
2424
2525
https://docs.blockfrost.io/#tag/Cardano-Accounts/paths/~1accounts~1{stake_address}/get
2626
2727
:param stake_address: Bech32 stake address.
2828
:type stake_address: str
29-
:returns: AccountResponse object.
29+
:param return_type: Optional. "object", "json" or "pandas". Default: "object".
30+
:type return_type: str
31+
:returns AccountResponse object.
3032
:rtype: AccountResponse
3133
:raises ApiError: If API fails
3234
:raises Exception: If the API response is somehow malformed.
@@ -53,6 +55,8 @@ def account_rewards(self, stake_address: str, **kwargs):
5355
5456
:param stake_address: Bech32 stake address.
5557
:type stake_address: str
58+
:param return_type: Optional. "object", "json" or "pandas". Default: "object".
59+
:type return_type: str
5660
:param gather_pages: Optional. Default: 100. Will collect all pages into one return
5761
:type gather_pages: bool
5862
:param count: Optional. Default: 1. The number of results displayed on one page.
@@ -61,7 +65,7 @@ def account_rewards(self, stake_address: str, **kwargs):
6165
:type page: int
6266
:param order: Optional. "asc" or "desc". Default: "asc".
6367
:type order: str
64-
:returns: A list of AccountRewardResponse objects.
68+
:returns A list of AccountRewardResponse objects.
6569
:rtype: [AccountRewardResponse]
6670
:raises ApiError: If API fails
6771
:raises Exception: If the API response is somehow malformed.
@@ -89,6 +93,8 @@ def account_history(self, stake_address: str, **kwargs):
8993
9094
:param stake_address: Bech32 stake address.
9195
:type stake_address: str
96+
:param return_type: Optional. "object", "json" or "pandas". Default: "object".
97+
:type return_type: str
9298
:param gather_pages: Optional. Default: 100. Will collect all pages into one return
9399
:type gather_pages: bool
94100
:param count: Optional. Default: 1. The number of results displayed on one page.
@@ -97,8 +103,8 @@ def account_history(self, stake_address: str, **kwargs):
97103
:type page: int
98104
:param order: Optional. "asc" or "desc". Default: "asc".
99105
:type order: str
100-
:returns: A list of AccountHistoryResponse objects.
101-
:rtype: [AccountHistoryResponse]
106+
:returns A list of AccountHistoryResponse objects.
107+
:rtype [AccountHistoryResponse]
102108
:raises ApiError: If API fails
103109
:raises Exception: If the API response is somehow malformed.
104110
"""
@@ -126,6 +132,8 @@ def account_delegations(self, stake_address: str, **kwargs):
126132
127133
:param stake_address: Bech32 stake address.
128134
:type stake_address: str
135+
:param return_type: Optional. "object", "json" or "pandas". Default: "object".
136+
:type return_type: str
129137
:param gather_pages: Optional. Default: 100. Will collect all pages into one return
130138
:type gather_pages: bool
131139
:param count: Optional. Default: 1. The number of results displayed on one page.
@@ -134,7 +142,7 @@ def account_delegations(self, stake_address: str, **kwargs):
134142
:type page: int
135143
:param order: Optional. "asc" or "desc". Default: "asc".
136144
:type order: str
137-
:returns: A list of AccountDelegationResponse objects.
145+
:returns A list of AccountDelegationResponse objects.
138146
:rtype: [AccountDelegationResponse]
139147
:raises ApiError: If API fails
140148
:raises Exception: If the API response is somehow malformed.
@@ -161,6 +169,8 @@ def account_registrations(self, stake_address: str, **kwargs):
161169
162170
:param stake_address: Bech32 stake address.
163171
:type stake_address: str
172+
:param return_type: Optional. "object", "json" or "pandas". Default: "object".
173+
:type return_type: str
164174
:param gather_pages: Optional. Default: 100. Will collect all pages into one return
165175
:type gather_pages: bool
166176
:param count: Optional. Default: 1. The number of results displayed on one page.
@@ -169,7 +179,7 @@ def account_registrations(self, stake_address: str, **kwargs):
169179
:type page: int
170180
:param order: Optional. "asc" or "desc". Default: "asc".
171181
:type order: str
172-
:returns: A list of AccountRegistrationResponse objects.
182+
:returns A list of AccountRegistrationResponse objects.
173183
:rtype: [AccountRegistrationResponse]
174184
:raises ApiError: If API fails
175185
:raises Exception: If the API response is somehow malformed.
@@ -196,6 +206,8 @@ def account_withdrawals(self, stake_address: str, **kwargs):
196206
197207
:param stake_address: Bech32 stake address.
198208
:type stake_address: str
209+
:param return_type: Optional. "object", "json" or "pandas". Default: "object".
210+
:type return_type: str
199211
:param gather_pages: Optional. Default: 100. Will collect all pages into one return
200212
:type gather_pages: bool
201213
:param count: Optional. Default: 1. The number of results displayed on one page.
@@ -204,7 +216,7 @@ def account_withdrawals(self, stake_address: str, **kwargs):
204216
:type page: int
205217
:param order: Optional. "asc" or "desc". Default: "asc".
206218
:type order: str
207-
:returns: A list of AccountWithdrawalResponse objects.
219+
:returns A list of AccountWithdrawalResponse objects.
208220
:rtype: [AccountWithdrawalResponse]
209221
:raises ApiError: If API fails
210222
:raises Exception: If the API response is somehow malformed.
@@ -231,6 +243,8 @@ def account_mirs(self, stake_address: str, **kwargs):
231243
232244
:param stake_address: Bech32 stake address.
233245
:type stake_address: str
246+
:param return_type: Optional. "object", "json" or "pandas". Default: "object".
247+
:type return_type: str
234248
:param gather_pages: Optional. Default: 100. Will collect all pages into one return
235249
:type gather_pages: bool
236250
:param count: Optional. Default: 1. The number of results displayed on one page.
@@ -239,7 +253,7 @@ def account_mirs(self, stake_address: str, **kwargs):
239253
:type page: int
240254
:param order: Optional. "asc" or "desc". Default: "asc".
241255
:type order: str
242-
:returns: A list of AccountMIRSResponse objects.
256+
:returns A list of AccountMIRSResponse objects.
243257
:rtype: [AccountMIRSResponse]
244258
:raises ApiError: If API fails
245259
:raises Exception: If the API response is somehow malformed.
@@ -265,6 +279,8 @@ def account_addresses(self, stake_address: str, **kwargs):
265279
266280
:param stake_address: Bech32 stake address.
267281
:type stake_address: str
282+
:param return_type: Optional. "object", "json" or "pandas". Default: "object".
283+
:type return_type: str
268284
:param gather_pages: Optional. Default: 100. Will collect all pages into one return
269285
:type gather_pages: bool
270286
:param count: Optional. Default: 1. The number of results displayed on one page.
@@ -273,7 +289,7 @@ def account_addresses(self, stake_address: str, **kwargs):
273289
:type page: int
274290
:param order: Optional. "asc" or "desc". Default: "asc".
275291
:type order: str
276-
:returns: A list of AccountAddressResponse objects.
292+
:returns A list of AccountAddressResponse objects.
277293
:rtype: [AccountAddressResponse]
278294
:raises ApiError: If API fails
279295
:raises Exception: If the API response is somehow malformed.
@@ -302,6 +318,8 @@ def account_addresses_assets(self, stake_address: str, **kwargs):
302318
303319
:param stake_address: Bech32 stake address.
304320
:type stake_address: str
321+
:param return_type: Optional. "object", "json" or "pandas". Default: "object".
322+
:type return_type: str
305323
:param gather_pages: Optional. Default: 100. Will collect all pages into one return
306324
:type gather_pages: bool
307325
:param count: Optional. Default: 1. The number of results displayed on one page.
@@ -310,7 +328,7 @@ def account_addresses_assets(self, stake_address: str, **kwargs):
310328
:type page: int
311329
:param order: Optional. "asc" or "desc". Default: "asc".
312330
:type order: str
313-
:returns: A list of AccountAddressesAssetResponse objects.
331+
:returns A list of AccountAddressesAssetResponse objects.
314332
:rtype: [AccountAddressesAssetResponse]
315333
:raises ApiError: If API fails
316334
:raises Exception: If the API response is somehow malformed.

0 commit comments

Comments
 (0)