Skip to content

Commit 2e25f5a

Browse files
Merge pull request #47 from semsorock/master
Add new API endpoints for Blockfrost API v0.1.86
2 parents cb7418e + cd2bf7b commit 2e25f5a

28 files changed

Lines changed: 1403 additions & 126 deletions

.github/workflows/package-test.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ jobs:
1111
strategy:
1212
fail-fast: false
1313
matrix:
14-
python-version: ["3.7", "3.8", "3.9", "3.10"]
14+
python-version: ["3.10", "3.12", "3.13"]
1515

1616
steps:
17-
- uses: actions/checkout@v2
17+
- uses: actions/checkout@v4
1818
- name: Set up Python ${{ matrix.python-version }}
19-
uses: actions/setup-python@v2
19+
uses: actions/setup-python@v5
2020
with:
2121
python-version: ${{ matrix.python-version }}
2222
- name: Install dependencies

.github/workflows/publish-to-test-pypi.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ jobs:
1616
name: Build and publish Python 🐍 distributions 📦 to PyPI and TestPyPI
1717
runs-on: ubuntu-latest
1818
steps:
19-
- uses: actions/checkout@master
20-
- name: Set up Python 3.9
21-
uses: actions/setup-python@v1
19+
- uses: actions/checkout@v4
20+
- name: Set up Python 3.12
21+
uses: actions/setup-python@v5
2222
with:
23-
python-version: 3.9
23+
python-version: "3.12"
2424
- name: Install pypa/build
2525
run: >
2626
python -m

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ Install dependencies
175175

176176
```
177177
pip install -r requirements.txt
178-
pip install -r rest-requirements.txt
178+
pip install -r test-requirements.txt
179179
```
180180

181181
Install package

blockfrost/api/__init__.py

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def root(self, **kwargs):
2323
"""
2424
Root endpoint has no other function than to point end users to documentation.
2525
26-
https://docs.blockfrost.io/#tag/Health/paths/~1/get
26+
https://docs.blockfrost.io/#tag/health/GET/
2727
:param return_type: Optional. "object", "json" or "pandas". Default: "object".
2828
:type return_type: str
2929
:returns RootResponse object.
@@ -57,7 +57,9 @@ def root(self, **kwargs):
5757
account_mirs, \
5858
account_addresses, \
5959
account_addresses_assets, \
60-
account_addresses_total
60+
account_addresses_total, \
61+
account_utxos, \
62+
account_transactions
6163
from .cardano.addresses import \
6264
address, \
6365
address_extended, \
@@ -75,12 +77,14 @@ def root(self, **kwargs):
7577
from .cardano.blocks import \
7678
block_latest, \
7779
block_latest_transactions, \
80+
block_latest_transactions_cbor, \
7881
block, \
7982
block_slot, \
8083
block_epoch_slot, \
8184
blocks_next, \
8285
blocks_previous, \
8386
block_transactions, \
87+
block_transactions_cbor, \
8488
blocks_addresses
8589
from .cardano.epochs import \
8690
epoch_latest, \
@@ -104,7 +108,8 @@ def root(self, **kwargs):
104108
metadata_label_json, \
105109
metadata_label_cbor
106110
from .cardano.network import \
107-
network
111+
network, \
112+
network_eras
108113
from .cardano.pools import \
109114
pools, \
110115
pools_extended, \
@@ -116,7 +121,8 @@ def root(self, **kwargs):
116121
pool_relays, \
117122
pool_delegators, \
118123
pool_blocks, \
119-
pool_updates
124+
pool_updates, \
125+
pool_votes
120126
from .cardano.transactions import \
121127
transaction, \
122128
transaction_utxos, \
@@ -131,6 +137,8 @@ def root(self, **kwargs):
131137
transaction_submit, \
132138
transaction_submit_cbor, \
133139
transaction_redeemers, \
140+
transaction_required_signers, \
141+
transaction_cbor, \
134142
transaction_evaluate, \
135143
transaction_evaluate_cbor, \
136144
transaction_evaluate_utxos
@@ -142,5 +150,23 @@ def root(self, **kwargs):
142150
script_redeemers, \
143151
script_datum, \
144152
script_datum_cbor
153+
from .cardano.governance import \
154+
governance_dreps, \
155+
governance_drep, \
156+
governance_drep_delegators, \
157+
governance_drep_metadata, \
158+
governance_drep_updates, \
159+
governance_drep_votes, \
160+
governance_proposals, \
161+
governance_proposal, \
162+
governance_proposal_parameters, \
163+
governance_proposal_withdrawals, \
164+
governance_proposal_votes, \
165+
governance_proposal_metadata, \
166+
governance_proposal_by_gov_action_id, \
167+
governance_proposal_parameters_by_gov_action_id, \
168+
governance_proposal_withdrawals_by_gov_action_id, \
169+
governance_proposal_votes_by_gov_action_id, \
170+
governance_proposal_metadata_by_gov_action_id
145171
from .cardano.utils import \
146172
utils_addresses_xpub

blockfrost/api/cardano/accounts.py

Lines changed: 72 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ def accounts(self, stake_address: str, **kwargs):
77
"""
88
Obtain information about a specific networkStake account.
99
10-
https://docs.blockfrost.io/#tag/Cardano-Accounts/paths/~1accounts~1{stake_address}/get
10+
https://docs.blockfrost.io/#tag/cardano--accounts/GET/accounts/{stake_address}
1111
1212
:param stake_address: Bech32 stake address.
1313
:type stake_address: str
@@ -29,7 +29,7 @@ def account_rewards(self, stake_address: str, **kwargs):
2929
"""
3030
Obtain information about the history of a specific account.
3131
32-
https://docs.blockfrost.io/#tag/Cardano-Accounts/paths/~1accounts~1{stake_address}~1rewards/get
32+
https://docs.blockfrost.io/#tag/cardano--accounts/GET/accounts/{stake_address}/rewards
3333
3434
:param stake_address: Bech32 stake address.
3535
:type stake_address: str
@@ -60,7 +60,7 @@ def account_history(self, stake_address: str, **kwargs):
6060
"""
6161
Obtain information about the history of a specific account.
6262
63-
https://docs.blockfrost.io/#tag/Cardano-Accounts/paths/~1accounts~1{stake_address}~1history/get
63+
https://docs.blockfrost.io/#tag/cardano--accounts/GET/accounts/{stake_address}/history
6464
6565
:param stake_address: Bech32 stake address.
6666
:type stake_address: str
@@ -91,7 +91,7 @@ def account_delegations(self, stake_address: str, **kwargs):
9191
"""
9292
Obtain information about the delegation of a specific account.
9393
94-
https://docs.blockfrost.io/#tag/Cardano-Accounts/paths/~1accounts~1{stake_address}~1delegations/get
94+
https://docs.blockfrost.io/#tag/cardano--accounts/GET/accounts/{stake_address}/delegations
9595
9696
:param stake_address: Bech32 stake address.
9797
:type stake_address: str
@@ -122,7 +122,7 @@ def account_registrations(self, stake_address: str, **kwargs):
122122
"""
123123
Obtain information about the registrations and deregistrations of a specific account.
124124
125-
https://docs.blockfrost.io/#tag/Cardano-Accounts/paths/~1accounts~1{stake_address}~1registrations/get
125+
https://docs.blockfrost.io/#tag/cardano--accounts/GET/accounts/{stake_address}/registrations
126126
127127
:param stake_address: Bech32 stake address.
128128
:type stake_address: str
@@ -153,7 +153,7 @@ def account_withdrawals(self, stake_address: str, **kwargs):
153153
"""
154154
Obtain information about the withdrawals of a specific account.
155155
156-
https://docs.blockfrost.io/#tag/Cardano-Accounts/paths/~1accounts~1{stake_address}~1withdrawals/get
156+
https://docs.blockfrost.io/#tag/cardano--accounts/GET/accounts/{stake_address}/withdrawals
157157
158158
:param stake_address: Bech32 stake address.
159159
:type stake_address: str
@@ -184,7 +184,7 @@ def account_mirs(self, stake_address: str, **kwargs):
184184
"""
185185
Obtain information about the MIRs of a specific account.
186186
187-
https://docs.blockfrost.io/#tag/Cardano-Accounts/paths/~1accounts~1{stake_address}~1mirs/get
187+
https://docs.blockfrost.io/#tag/cardano--accounts/GET/accounts/{stake_address}/mirs
188188
189189
:param stake_address: Bech32 stake address.
190190
:type stake_address: str
@@ -215,7 +215,7 @@ def account_addresses(self, stake_address: str, **kwargs):
215215
"""
216216
Obtain information about the addresses of a specific account.
217217
218-
https://docs.blockfrost.io/#tag/Cardano-Accounts/paths/~1accounts~1{stake_address}~1addresses/get
218+
https://docs.blockfrost.io/#tag/cardano--accounts/GET/accounts/{stake_address}/addresses
219219
220220
:param stake_address: Bech32 stake address.
221221
:type stake_address: str
@@ -248,7 +248,7 @@ def account_addresses_assets(self, stake_address: str, **kwargs):
248248
249249
Be careful, as an account could be part of a mangled address and does not necessarily mean the addresses are owned by user as the account.
250250
251-
https://docs.blockfrost.io/#tag/Cardano-Accounts/paths/~1accounts~1{stake_address}~1addresses~1assets/get
251+
https://docs.blockfrost.io/#tag/cardano--accounts/GET/accounts/{stake_address}/addresses/assets
252252
253253
:param stake_address: Bech32 stake address.
254254
:type stake_address: str
@@ -274,14 +274,76 @@ def account_addresses_assets(self, stake_address: str, **kwargs):
274274
)
275275

276276

277+
@list_request_wrapper
278+
def account_utxos(self, stake_address: str, **kwargs):
279+
"""
280+
Obtain information about UTXOs of a specific account.
281+
282+
https://docs.blockfrost.io/#tag/cardano--accounts/GET/accounts/{stake_address}/utxos
283+
284+
:param stake_address: Bech32 stake address.
285+
:type stake_address: str
286+
:param return_type: Optional. "object", "json" or "pandas". Default: "object".
287+
:type return_type: str
288+
:param gather_pages: Optional. Default: false. Will collect all pages into one return
289+
:type gather_pages: bool
290+
:param count: Optional. Default: 100. The number of results displayed on one page.
291+
:type count: int
292+
:param page: Optional. The page number for listing the results.
293+
:type page: int
294+
:param order: Optional. "asc" or "desc". Default: "asc".
295+
:type order: str
296+
:returns A list of objects.
297+
:rtype [Namespace]
298+
:raises ApiError: If API fails
299+
:raises Exception: If the API response is somehow malformed.
300+
"""
301+
return requests.get(
302+
url=f"{self.url}/accounts/{stake_address}/utxos",
303+
params=self.query_parameters(kwargs),
304+
headers=self.default_headers
305+
)
306+
307+
308+
@list_request_wrapper
309+
def account_transactions(self, stake_address: str, **kwargs):
310+
"""
311+
Obtain information about transactions associated with a specific account.
312+
313+
https://docs.blockfrost.io/#tag/cardano--accounts/GET/accounts/{stake_address}/transactions
314+
315+
:param stake_address: Bech32 stake address.
316+
:type stake_address: str
317+
:param return_type: Optional. "object", "json" or "pandas". Default: "object".
318+
:type return_type: str
319+
:param gather_pages: Optional. Default: false. Will collect all pages into one return
320+
:type gather_pages: bool
321+
:param count: Optional. Default: 100. The number of results displayed on one page.
322+
:type count: int
323+
:param page: Optional. The page number for listing the results.
324+
:type page: int
325+
:param order: Optional. "asc" or "desc". Default: "asc".
326+
:type order: str
327+
:returns A list of objects.
328+
:rtype [Namespace]
329+
:raises ApiError: If API fails
330+
:raises Exception: If the API response is somehow malformed.
331+
"""
332+
return requests.get(
333+
url=f"{self.url}/accounts/{stake_address}/transactions",
334+
params=self.query_parameters(kwargs),
335+
headers=self.default_headers
336+
)
337+
338+
277339
@request_wrapper
278340
def account_addresses_total(self, stake_address: str, **kwargs):
279341
"""
280342
Obtain summed details about all addresses associated with a given account.
281343
282344
Be careful, as an account could be part of a mangled address and does not necessarily mean the addresses are owned by user as the account.
283345
284-
https://docs.blockfrost.io/#tag/Cardano-Addresses/paths/~1accounts~1{stake_address}~1addresses~1total/get
346+
https://docs.blockfrost.io/#tag/cardano--addresses/GET/accounts/{stake_address}/addresses/total
285347
286348
:param stake_address: Bech32 address.
287349
:type stake_address: str

blockfrost/api/cardano/addresses.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ def address(self, address: str, **kwargs):
77
"""
88
Obtain information about a specific address.
99
10-
https://docs.blockfrost.io/#tag/Cardano-Addresses/paths/~1addresses~1{address}/get
10+
https://docs.blockfrost.io/#tag/cardano--addresses/GET/addresses/{address}
1111
1212
:param address: Bech32 address.
1313
:type address: str
@@ -29,7 +29,7 @@ def address_extended(self, address: str, **kwargs):
2929
"""
3030
Obtain information about a specific address.
3131
32-
https://docs.blockfrost.io/#tag/Cardano-Addresses/paths/~1addresses~1{address}~1extended/get
32+
https://docs.blockfrost.io/#tag/cardano--addresses/GET/addresses/{address}/extended
3333
3434
:param address: Bech32 address.
3535
:type address: str
@@ -51,7 +51,7 @@ def address_total(self, address: str, **kwargs):
5151
"""
5252
Obtain details about an address.
5353
54-
https://docs.blockfrost.io/#tag/Cardano-Addresses/paths/~1addresses~1{address}~1total/get
54+
https://docs.blockfrost.io/#tag/cardano--addresses/GET/addresses/{address}/total
5555
5656
:param address: Bech32 address.
5757
:type address: str
@@ -73,7 +73,7 @@ def address_utxos(self, address: str, **kwargs):
7373
"""
7474
UTXOs of the address.
7575
76-
https://docs.blockfrost.io/#tag/Cardano-Addresses/paths/~1addresses~1{address}~1utxos/get
76+
https://docs.blockfrost.io/#tag/cardano--addresses/GET/addresses/{address}/utxos
7777
7878
:param address: Bech32 address.
7979
:type address: str
@@ -104,7 +104,7 @@ def address_utxos_asset(self, address: str, asset: str, **kwargs):
104104
"""
105105
UTXOs of the address.
106106
107-
https://docs.blockfrost.io/#tag/Cardano-Addresses/paths/~1addresses~1{address}~1utxos~1{asset}/get
107+
https://docs.blockfrost.io/#tag/cardano--addresses/GET/addresses/{address}/utxos/{asset}
108108
109109
:param address: Bech32 address.
110110
:type address: str
@@ -138,7 +138,7 @@ def address_transactions(self, address: str, from_block: str = None, to_block: s
138138
"""
139139
Transactions on the address.
140140
141-
https://docs.blockfrost.io/#tag/Cardano-Addresses/paths/~1addresses~1{address}~1transactions/get
141+
https://docs.blockfrost.io/#tag/cardano--addresses/GET/addresses/{address}/transactions
142142
143143
:param address: Bech32 address.
144144
:type address: str

blockfrost/api/cardano/assets.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ def assets(self, **kwargs):
77
"""
88
List of assets.
99
10-
https://docs.blockfrost.io/#tag/Cardano-Assets/paths/~1assets/get
10+
https://docs.blockfrost.io/#tag/cardano--assets/GET/assets
1111
1212
:param return_type: Optional. "object", "json" or "pandas". Default: "object".
1313
:type return_type: str
@@ -36,7 +36,7 @@ def asset(self, asset: str, **kwargs):
3636
"""
3737
Information about a specific asset
3838
39-
https://docs.blockfrost.io/#tag/Cardano-Assets/paths/~1assets~1{asset}/get
39+
https://docs.blockfrost.io/#tag/cardano--assets/GET/assets/{asset}
4040
4141
:param asset: Concatenation of the policy_id and hex-encoded asset_name.
4242
:type asset: str
@@ -58,7 +58,7 @@ def asset_history(self, asset: str, **kwargs):
5858
"""
5959
History of a specific asset
6060
61-
https://docs.blockfrost.io/#tag/Cardano-Assets/paths/~1assets~1{asset}~1history/get
61+
https://docs.blockfrost.io/#tag/cardano--assets/GET/assets/{asset}/history
6262
6363
:param asset: Concatenation of the policy_id and hex-encoded asset_name.
6464
:type asset: str
@@ -89,7 +89,7 @@ def asset_transactions(self, asset: str, **kwargs):
8989
"""
9090
List of a specific asset transactions
9191
92-
https://docs.blockfrost.io/#tag/Cardano-Assets/paths/~1assets~1{asset}~1transactions/get
92+
https://docs.blockfrost.io/#tag/cardano--assets/GET/assets/{asset}/transactions
9393
9494
:param asset: Concatenation of the policy_id and hex-encoded asset_name.
9595
:type asset: str
@@ -120,7 +120,7 @@ def asset_addresses(self, asset: str, **kwargs):
120120
"""
121121
List of a addresses containing a specific asset
122122
123-
https://docs.blockfrost.io/#tag/Cardano-Assets/paths/~1assets~1{asset}~1addresses/get
123+
https://docs.blockfrost.io/#tag/cardano--assets/GET/assets/{asset}/addresses
124124
125125
:param asset: Concatenation of the policy_id and hex-encoded asset_name.
126126
:type asset: str
@@ -151,7 +151,7 @@ def assets_policy(self, policy_id: str, **kwargs):
151151
"""
152152
List of asset minted under a specific policy
153153
154-
https://docs.blockfrost.io/#tag/Cardano-Assets/paths/~1assets~1policy~1{policy_id}/get
154+
https://docs.blockfrost.io/#tag/cardano--assets/GET/assets/policy/{policy_id}
155155
156156
:param policy_id: Specific policy_id.
157157
:type policy_id: str

0 commit comments

Comments
 (0)