Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ Install dependencies

```
pip install -r requirements.txt
pip install -r rest-requirements.txt
pip install -r test-requirements.txt
```

Install package
Expand Down
24 changes: 22 additions & 2 deletions blockfrost/api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ def root(self, **kwargs):
account_mirs, \
account_addresses, \
account_addresses_assets, \
account_addresses_total
account_addresses_total, \
account_utxos, \
account_transactions
from .cardano.addresses import \
address, \
address_extended, \
Expand All @@ -75,12 +77,14 @@ def root(self, **kwargs):
from .cardano.blocks import \
block_latest, \
block_latest_transactions, \
block_latest_transactions_cbor, \
block, \
block_slot, \
block_epoch_slot, \
blocks_next, \
blocks_previous, \
block_transactions, \
block_transactions_cbor, \
blocks_addresses
from .cardano.epochs import \
epoch_latest, \
Expand All @@ -104,7 +108,8 @@ def root(self, **kwargs):
metadata_label_json, \
metadata_label_cbor
from .cardano.network import \
network
network, \
network_eras
from .cardano.pools import \
pools, \
pools_extended, \
Expand All @@ -131,6 +136,8 @@ def root(self, **kwargs):
transaction_submit, \
transaction_submit_cbor, \
transaction_redeemers, \
transaction_required_signers, \
transaction_cbor, \
transaction_evaluate, \
transaction_evaluate_cbor, \
transaction_evaluate_utxos
Expand All @@ -142,5 +149,18 @@ def root(self, **kwargs):
script_redeemers, \
script_datum, \
script_datum_cbor
from .cardano.governance import \
governance_dreps, \
governance_drep, \
governance_drep_delegators, \
governance_drep_metadata, \
governance_drep_updates, \
governance_drep_votes, \
governance_proposals, \
governance_proposal, \
governance_proposal_parameters, \
governance_proposal_withdrawals, \
governance_proposal_votes, \
governance_proposal_metadata
from .cardano.utils import \
utils_addresses_xpub
62 changes: 62 additions & 0 deletions blockfrost/api/cardano/accounts.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,68 @@ def account_addresses_assets(self, stake_address: str, **kwargs):
)


@list_request_wrapper
def account_utxos(self, stake_address: str, **kwargs):
"""
Obtain information about UTXOs of a specific account.

https://docs.blockfrost.io/#tag/Cardano-Accounts/paths/~1accounts~1{stake_address}~1utxos/get

:param stake_address: Bech32 stake address.
:type stake_address: str
:param return_type: Optional. "object", "json" or "pandas". Default: "object".
:type return_type: str
:param gather_pages: Optional. Default: false. Will collect all pages into one return
:type gather_pages: bool
:param count: Optional. Default: 100. The number of results displayed on one page.
:type count: int
:param page: Optional. The page number for listing the results.
:type page: int
:param order: Optional. "asc" or "desc". Default: "asc".
:type order: str
:returns A list of objects.
:rtype [Namespace]
:raises ApiError: If API fails
:raises Exception: If the API response is somehow malformed.
"""
return requests.get(
url=f"{self.url}/accounts/{stake_address}/utxos",
params=self.query_parameters(kwargs),
headers=self.default_headers
)


@list_request_wrapper
def account_transactions(self, stake_address: str, **kwargs):
"""
Obtain information about transactions associated with a specific account.

https://docs.blockfrost.io/#tag/Cardano-Accounts/paths/~1accounts~1{stake_address}~1transactions/get

:param stake_address: Bech32 stake address.
:type stake_address: str
:param return_type: Optional. "object", "json" or "pandas". Default: "object".
:type return_type: str
:param gather_pages: Optional. Default: false. Will collect all pages into one return
:type gather_pages: bool
:param count: Optional. Default: 100. The number of results displayed on one page.
:type count: int
:param page: Optional. The page number for listing the results.
:type page: int
:param order: Optional. "asc" or "desc". Default: "asc".
:type order: str
:returns A list of objects.
:rtype [Namespace]
:raises ApiError: If API fails
:raises Exception: If the API response is somehow malformed.
"""
return requests.get(
url=f"{self.url}/accounts/{stake_address}/transactions",
params=self.query_parameters(kwargs),
headers=self.default_headers
)


@request_wrapper
def account_addresses_total(self, stake_address: str, **kwargs):
"""
Expand Down
56 changes: 56 additions & 0 deletions blockfrost/api/cardano/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,62 @@ def block_transactions(self, hash_or_number: str, **kwargs):
)


@list_request_wrapper
def block_latest_transactions_cbor(self, **kwargs):
"""
Return the transactions within the latest block in CBOR format.

https://docs.blockfrost.io/#tag/Cardano-Blocks/paths/~1blocks~1latest~1txs~1cbor/get

:param gather_pages: Optional. Default: false. Will collect all pages into one return
:type gather_pages: bool
:param count: Optional. Default: 100. The number of results displayed on one page.
:type count: int
:param page: Optional. The page number for listing the results.
:type page: int
:param order: Optional. "asc" or "desc". Default: "asc".
:type order: str
:returns A list of objects.
:rtype [Namespace]
:raises ApiError: If API fails
:raises Exception: If the API response is somehow malformed.
"""
return requests.get(
url=f"{self.url}/blocks/latest/txs/cbor",
params=self.query_parameters(kwargs),
headers=self.default_headers
)


@list_request_wrapper
def block_transactions_cbor(self, hash_or_number: str, **kwargs):
"""
Return the transactions within the block in CBOR format.

https://docs.blockfrost.io/#tag/Cardano-Blocks/paths/~1blocks~1{hash_or_number}~1txs~1cbor/get

:param hash_or_number: Hash or number of the requested block.
:type hash_or_number: str
:param gather_pages: Optional. Default: false. Will collect all pages into one return
:type gather_pages: bool
:param count: Optional. Default: 100. The number of results displayed on one page.
:type count: int
:param page: Optional. The page number for listing the results.
:type page: int
:param order: Optional. "asc" or "desc". Default: "asc".
:type order: str
:returns A list of objects.
:rtype [Namespace]
:raises ApiError: If API fails
:raises Exception: If the API response is somehow malformed.
"""
return requests.get(
url=f"{self.url}/blocks/{hash_or_number}/txs/cbor",
params=self.query_parameters(kwargs),
headers=self.default_headers
)


@list_request_wrapper
def blocks_addresses(self, hash_or_number: str, **kwargs):
"""
Expand Down
Loading
Loading