Skip to main content

Python wrapper for accessing and processing information stored on the Cardano blockchain using Blockfrost API.

Project description

Python Cardano Explorer PyPI - Python Version PyPI - Python Version

Python wrapper for accessing and processing information stored on the Cardano blockchain using Blockfrost API.


Table of contents


Install (Not available yet)

The library is not deployed yet, clone the project if you want testing the functions

pip install cardano_explorer

Usage

from cardano_explorer import blockfrost_api

Api Key

If you have an API key, you can either set it as environment variable BLOCKFROST_API_KEY or set it manually.

cardano_mainnet = blockfrost_api.Auth()
#or
cardano_mainnet = blockfrost_api.Auth(api_key=api_key)

Using With Proxy

proxies = {
 "http": "http://user:password@server:port",
 "https": "https://user:password@server:portt",
}

cardano_mainnet = blockfrost_api.Auth(proxies=proxies)

Network

You can specify the cardano network with the class parameter network.

cardano_mainnet = blockfrost_api.Auth() # mainnet by default
#or
cardano_mainnet = blockfrost_api.Auth(network='mainnet')
#or
cardano_mainnet = blockfrost_api.Auth(network='testnet')

Network Informations

Network Info

Return detailed about the network.

cardano_mainnet.network_info()
{'supply': {'max': '45000000000000000',
  'total': '33206309572085375',
  'circulating': '32854605043085013',
  'locked': '11030148142156',
  'treasury': '630037263793143',
  'reserves': '11793690427914625'},
 'stake': {'live': '23374530755001598', 'active': '23395112387185878'}}

Stake

Stake Informations

Obtain information about a specific stake account.

cardano_mainnet.stake_informations(stake_address)
{'stake_address': 'stake1uyttshgm6jtejckv48tll58hfw3fg2ffrcc4d5qvcc4yc7q9jsalf',
 'active': True,
 'active_epoch': 271,
 'controlled_amount': '3002782240',
 'rewards_sum': '21216846',
 'withdrawals_sum': '0',
 'reserves_sum': '97317',
 'treasury_sum': '0',
 'withdrawable_amount': '21314163',
 'pool_id': 'pool1ekhy5xsgjaq38em75vevk8df0k0rljju77tljw288ys5kumqce5'}

Stake Reward History

Obtain information about the reward history of a specific account.

cardano_mainnet.stake_reward_history(stake_address) 
#or      
cardano_mainnet.stake_reward_history(stake_address, 
                                     data_order='asc', # Optional: Data order (default: Ascending)
                                     nb_of_results=100, # Optional: Return max 100 results at the time (default: None), None for get all the data available.
                                     pandas=True) # Optional: Return a pandas dataframe
epoch amount pool_id
14 287 2270290 pool1ekhy5xsgjaq38em75vevk8df0k0rljju77tljw288...
15 288 1768631 pool1ekhy5xsgjaq38em75vevk8df0k0rljju77tljw288...
16 289 2390373 pool1ekhy5xsgjaq38em75vevk8df0k0rljju77tljw288...
17 290 1878132 pool1ekhy5xsgjaq38em75vevk8df0k0rljju77tljw288...
18 291 2059700 pool1ekhy5xsgjaq38em75vevk8df0k0rljju77tljw288...

Stake Amount History

Obtain information about the history of a specific account.

cardano_mainnet.stake_amount_history(stake_address)
#or                        
cardano_mainnet.stake_amount_history(stake_address, 
                                     data_order='asc', # Optional: Data order (default: Ascending)
                                     nb_of_results=100, # Optional: Return max 100 results at the time (default: None), None for get all the data available.
                                     pandas=True) # Optional: Return a pandas dataframe
active_epoch amount pool_id
0 242 1424619058 pool1u7mqtde27swkarngjsn5mmw3sy20zavlafgqkmg8q...
1 243 1424619058 pool1u7mqtde27swkarngjsn5mmw3sy20zavlafgqkmg8q...
2 244 1424619058 pool1u7mqtde27swkarngjsn5mmw3sy20zavlafgqkmg8q...
3 245 1425498425 pool1u7mqtde27swkarngjsn5mmw3sy20zavlafgqkmg8q...
4 246 1426468544 pool1u7mqtde27swkarngjsn5mmw3sy20zavlafgqkmg8q...

Stake Delegation History

Obtain information about the delegation of a specific account.

cardano_mainnet.stake_delegation(stake_address)
#or
cardano_mainnet.stake_delegation(stake_address, 
                                 data_order='asc', # Optional: Data order (default: Ascending)
                                 nb_of_results=100, # Optional: Return max 100 results at the time (default: None), None for get all the data available.
                                 pandas=True) # Optional: Return a pandas dataframe
active_epoch tx_hash amount pool_id
0 242 b602262e1264dabd6c10747415558934d196834d7c7dea... 747625479 pool1u7mqtde27swkarngjsn5mmw3sy20zavlafgqkmg8q...
1 248 5822a3b2ebc0a45426aff524e5a0fd2bf7906f671e875a... 747452454 pool1m62sl6rauje9cknrkhwl39tc4hujudkd7gp478dpz...
2 259 2c0c3c2123b74b926d2b6969ea21f49ae92861acecf2b8... 21263559 pool1lurfk0k0wwx54hlg8a7zp3jtstu57u59aeq7aketl...

Stake Registrations And Deregistrations History

Obtain information about the registrations and deregistrations of a specific account.

cardano_mainnet.stake_registration_deregistrations(stake_address)
#or
cardano_mainnet.stake_registration_deregistrations(stake_address, 
                                                   data_order='asc', # Optional: Data order (default: Ascending)
                                                   nb_of_results=100, # Optional: Return max 100 results at the time (default: None), None for get all the data available.
                                                   pandas=True) # Optional: Return a pandas dataframe
tx_hash action
0 b602262e1264dabd6c10747415558934d196834d7c7dea... registered

Stake Withdrawal History

Obtain information about the withdrawals of a specific account.

cardano_mainnet.stake_withdrawal_history(stake_adress)
#or
cardano_mainnet.stake_withdrawal_history(stake_address, 
                                         data_order='asc', # Optional: Data order (default: Ascending)
                                         nb_of_results=100, # Optional: Return max 100 results at the time (default: None), None for get all the data available.
                                         pandas=True) # Optional: Return a pandas dataframe
tx_hash amount
0 80b09b61d2da86f5847d0b9a5f72d32224fcd7e1aa1716... 21239707

Stake MIR History

Obtain information about the MIRs of a specific account.

cardano_mainnet.stake_mir_history(stake_address)
#or
cardano_mainnet.stake_mir_history(stake_address, 
                                  data_order='asc', # Optional: Data order (default: Ascending)
                                  nb_of_results=100, # Optional: Return max 100 results at the time (default: None), None for get all the data available.
                                  pandas=True) # Optional: Return a pandas dataframe
tx_hash amount
0 443b98009b9a705c7112b031d223f26a3399f8cf1e7f12... 16922
1 f707cb4decf7f21991f506bba051a0184ca8ecbd402f79... 5196

Stake Associated Addresses

Obtain information about the MIRs of a specific account.

cardano_mainnet.stake_associated_addresses(stake_address)
#or
cardano_mainnet.stake_associated_addresses(stake_address, 
                                           data_order='asc', # Optional: Data order (default: Ascending)
                                           nb_of_results=100, # Optional: Return max 100 results at the time (default: None), None for get all the data available.
                                           pandas=True) # Optional: Return a pandas dataframe 
address
0 addr1q9asyce9kg8x8srwjuehtj0sxzc206rn5nv8tzc66...
1 addr1qyyzytknnnr3yy3hrxt7puzxy2zle6cfs3c839rdw...
2 addr1q8qe2873c334m7s3j2g27fq4sjqkh03mr28z3nd3l...
3 addr1q9226w0sg40mjhnzdt3myvnucrljqg7pyxgn9vypc...
4 addr1q8amjln6cua3scnthlm8jd7vnz4w4j7hmpkj7l8vt...

Stake Assets Associated Addresses

Obtain information about assets associated with addresses of a specific account.

cardano_mainnet.stake_associated_addresses(stake_address)
#or
cardano_mainnet.stake_assets_associated_addresses(stake_address, 
                                                  data_order='asc', # Optional: Data order (default: Ascending)
                                                  nb_of_results=100, # Optional: Return max 100 results at the time (default: None), None for get all the data available.
                                                  pandas=True) # Optional: Return a pandas dataframe 

Address

Specific Address

Obtain information about a specific address.

cardano_mainnet.address_info(address)
{'address': 'addr1q8z24xgrlj3m2qjh2vxyqg2fh33y3tegufkll5c4lu8u35gkhpw3h4yhn93ve2whllg0wjazjs5jj8332mgqe332f3uq8m7m6h',
 'amount': [{'unit': 'lovelace', 'quantity': '350000000'}],
 'stake_address': 'stake1uyttshgm6jtejckv48tll58hfw3fg2ffrcc4d5qvcc4yc7q9jsalf',
 'type': 'shelley'}

Address Details

Obtain details about an address.

cardano_mainnet.address_details(address)
{'address': 'addr1q8z24xgrlj3m2qjh2vxyqg2fh33y3tegufkll5c4lu8u35gkhpw3h4yhn93ve2whllg0wjazjs5jj8332mgqe332f3uq8m7m6h',
 'received_sum': [{'unit': 'lovelace', 'quantity': '350000000'}],
 'sent_sum': [{'unit': 'lovelace', 'quantity': '0'}],
 'tx_count': 1}

Address UTXOs

UTXOs of the address.

cardano_mainnet.address_utxo(address)
#or
cardano_mainnet.address_utxo(address,
                             pandas=True) # Optional: Return a pandas dataframe 
tx_hash tx_index output_index amount block data_hash
0 996ff0a57282ef943ecdbc263cf9c41c178d65587d70d9... 4 4 [{'unit': 'lovelace', 'quantity': '350000000'}] 73768f4ca2a0c96611a1fbd7f53a3b1b573fb0371012e5... None

Address Transactions

Transactions on the address.

cardano_mainnet.address_transaction(address, 
                                   pandas=True) # Optional: Return a pandas dataframe 
tx_hash tx_index block_height
0 996ff0a57282ef943ecdbc263cf9c41c178d65587d70d9... 45 6095572

Epoch

Latest Epoch

Obtain the information about the latest epoch.

cardano_mainnet.latest_epoch()
{'epoch': 288,
 'start_time': 1630619091,
 'end_time': 1631051091,
 'first_block_time': 1630619101,
 'last_block_time': 1630695809,
 'block_count': 3867,
 'tx_count': 77200,
 'output': '41529702474109934',
 'fees': '16021622015',
 'active_stake': '23136223153988390'}

Latest Epoch Protocol Parameters

Return the protocol parameters for the latest epoch.

cardano_mainnet.latest_epoch_protocol_parameters()
{'epoch': 288,
 'min_fee_a': 44,
 'min_fee_b': 155381,
 'max_block_size': 65536,
 'max_tx_size': 16384,
 'max_block_header_size': 1100,
 'key_deposit': '2000000',
 'pool_deposit': '500000000',
 'e_max': 18,
 'n_opt': 500,
 'a0': 0.3,
 'rho': 0.003,
 'tau': 0.2,
 'decentralisation_param': 0,
 'extra_entropy': None,
 'protocol_major_ver': 4,
 'protocol_minor_ver': 0,
 'min_utxo': '1000000',
 'min_pool_cost': '340000000',
 'nonce': 'bf3b52ab86e152b392cbf095c1d0f07aaeda956eecfdb44b09bcb85a0ecae36a'}

Specific Epoch

Obtain informations about a specific epoch.

cardano_mainnet.specific_epoch(287)
{'epoch': 287,
 'start_time': 1630187091,
 'end_time': 1630619091,
 'first_block_time': 1630187230,
 'last_block_time': 1630619085,
 'block_count': 21065,
 'tx_count': 401343,
 'output': '74754307451589173',
 'fees': '86536781869',
 'active_stake': '23041097075076811'}

Epochs History

Obtain informations about sevrals epochs.

cardano_mainnet.epochs_history([270, 271, 272],
                               pandas=True) # Optional: Return a pandas dataframe 
epoch start_time end_time first_block_time last_block_time block_count tx_count output fees active_stake
0 270 1622843091 1623275091 1622843183 1623275038 21395 174334 12213404538685056 36489177917 22893778548073522
1 271 1623275091 1623707091 1623275098 1623707059 21410 145244 12686700012872148 30802442909 22970909569111347
2 272 1623707091 1624139091 1623707123 1624139087 21499 135373 10640794327820158 29593210504 23020000415780615

Pool

List Of Stake Pools

List of registered stake pools.

cardano_mainnet.registered_polls()
#or
cardano_mainnet.registered_polls(nb_of_results=100, # Optional: Return max 100 results at the time (default: None), None for get all the data available.
                                 pandas=True) # Optional: Return a pandas dataframe 
registered_polls_id
0 pool1z5uqdk7dzdxaae5633fqfcu2eqzy3a3rgtuvy087f...
1 pool1pu5jlj4q9w9jlxeu370a3c9myx47md5j5m2str0na...
2 pool1c8k78ny3xvsfgenhf4yzvpzwgzxmz0t0um0h2xnn2...
3 pool1q80jjs53w0fx836n8g38gtdwr8ck5zre3da90peux...
4 pool1ddskftmsscw92d7vnj89pldwx5feegkgcmamgt5t0...

Specific Stake Pool Informations

Pool informations.

cardano_mainnet.pool_informations(pool_id)
{'pool_id': 'pool1ekhy5xsgjaq38em75vevk8df0k0rljju77tljw288ys5kumqce5',
 'hex': 'cdae4a1a08974113e77ea332cb1da97d9e3fca5cf797f9394739214b',
 'vrf_key': '5517fbeb4c6a5a613835808de183345eaf85ab0e251210e493e088afa41d9ab0',
 'blocks_minted': 3073,
 'live_stake': '55648149168432',
 'live_size': 0.0023887520907477904,
 'live_saturation': 0.8479059445396915,
 'live_delegators': 1443,
 'active_stake': '55449417952886',
 'active_size': 0.002396649512923082,
 'declared_pledge': '200000000000',
 'live_pledge': '203180990314',
 'margin_cost': 0.01,
 'fixed_cost': '340000000',
 'reward_account': 'stake1u8uzevd539lxn40jt60g72a649zdphe9e8hrye4nf5jv0js9uzhzg',
 'owners': ['stake1u9qsgte62jau0qu6kjy8zch8aynt55gql6jsxe05464n99gsqd7ra',
  'stake1u8uzevd539lxn40jt60g72a649zdphe9e8hrye4nf5jv0js9uzhzg'],
 'registration': ['b1bfffc26b6210ced9cc679781922e8b1ac70a2f7719523528639da4ab7f2d88',
  'be5b798897f5b83e5bf562df6fc68a94d5528acc80ab8e999ce866aa63a4d06a',
  '0f4781efd649f91e37847cb2699a8a41632ee94df1465e255577772f362339bf',
  '630c7195fdc1c5c14bb12c460059c5adb11b3cd6d3e576628aee0a8338f1b6ad',
  '119fe23a35e0ddcbb5778f17ad2371228a53b5ced037c12083a0c77b5711e1d4',
  'f1fe58c30ec7f5193476694fafc46dcdb11c3408e114e8fa2a95425243907ed4',
  '09c2c3d34de116365c9cf9a6e75f45856013388d962dbd5584c27b7d0bb36eed'],
 'retirement': []}

Stake Pool History

History of stake pool over epochs.

cardano_mainnet.stake_pool_history(pool_id)
#or
cardano_mainnet.stake_pool_history(pool_id,
                                   pandas=True) # Optional: Return a pandas dataframe 
epoch blocks active_stake active_size delegators_count rewards fees
79 289 66 55724573270655 0.002390 1443 47200199605 808601996
80 290 49 54675837934319 0.002351 1440 34877628423 685376284
81 291 54 54806809508971 0.002360 1451 38286415852 719464158
82 292 60 57943587612745 0.002484 1451 0 0
83 293 50 63400551099817 0.002710 1440 0 0

Assets

Assets List

List of assets.

cardano_mainnet.assets()
#or
cardano_mainnet.assets(data_order='asc', # Optional: Data order (default: Ascending)
                       nb_of_results=100, # Optional: Return max 100 results at the time (default: None), None for get all the data available.
                       pandas=True) # Optional: Return a pandas dataframe 
asset quantity
0 00000002df633853f6a47465c9496721d2d5b1291b8398... 1
1 3a9241cd79895e3a8d65261b40077d4437ce71e9d7c8c6... 1
2 02f68378e37af4545d027d0a9fa5581ac682897a3fc1f6... 1000000
3 e8e62d329e73190190c3e323fb5c9fb98ee55f0676332b... 1
4 ac3f4224723e2ed9d166478662f6e48bae9ddf0fc5ee58... 10000000

Specific Asset

Information about a specific asset.

cardano_mainnet.specific_asset(policy_id+asset_name)
{'asset': '40fa2aa67258b4ce7b5782f74831d46a84c59a0ff0c28262fab21728436c61794e6174696f6e33393836',
 'policy_id': '40fa2aa67258b4ce7b5782f74831d46a84c59a0ff0c28262fab21728',
 'asset_name': '436c61794e6174696f6e33393836',
 'fingerprint': 'asset1ay3atwzy3hrdnn74v05jusgsycl344nquyq9nq',
 'quantity': '1',
 'initial_mint_tx_hash': '117f97ccf6e98a16697e7cc205daf2d0bfe83d849a63df2f40d10bef235848e7',
 'mint_or_burn_count': 1,
 'onchain_metadata': {'name': 'Clay Nation #3986',
  'image': 'ipfs://QmYREMX1uTQAFScJD4Xv5tUPnWimKyLzBTBFLv1oCyzMj2',
  'body': 'Brown Clay',
  'eyes': 'Big Eyes',
  'brows': 'Normal Eyebrows',
  'mouth': 'Normal Mouth',
  'Project': 'Clay Nation by Clay Mates',
  'clothes': 'Tshirt Green',
  'background': 'Cyan',
  'accessories': 'Flower Necklace',
  'hats and hair': 'Fringe'},
 'metadata': None}

Asset History

History of a specific asset.

cardano_mainnet.asset_history(policy_id+asset_name)
#or
cardano_mainnet.asset_history(policy_id+asset_name,
                              data_order='asc', # Optional: Data order (default: Ascending)
                              nb_of_results=100, # Optional: Return max 100 results at the time (default: None), None for get all the data available.
                              pandas=True) # Optional: Return a pandas dataframe
tx_hash action amount
0 117f97ccf6e98a16697e7cc205daf2d0bfe83d849a63df... minted 1

Asset Transactions

List of a specific asset transactions.

cardano_mainnet.asset_addresses(policy_id+asset_name)
#or
cardano_mainnet.asset_addresses(policy_id+asset_name,
                                data_order='asc', # Optional: Data order (default: Ascending)
                                nb_of_results=100, # Optional: Return max 100 results at the time (default: None), None for get all the data available.
                                pandas=True) # Optional: Return a pandas dataframe 
address quantity
0 addr1qytstx6xt93ux775sg2k5f9l4xfpat8e06mpg8mm7... 1

Assets Of A Specific Policy

List of asset minted under a specific policy

cardano_mainnet.assets_policy(policy_id)
#or
cardano_mainnet.assets_policy(policy_id,
                              data_order='asc', # Optional: Data order (default: Ascending)
                              nb_of_results=None, # Optional: Return max 100 results at the time (default: None), None for get all the data available.
                              pandas=True) # Optional: Return a pandas dataframe 
asset quantity
0 40fa2aa67258b4ce7b5782f74831d46a84c59a0ff0c282... 1
1 40fa2aa67258b4ce7b5782f74831d46a84c59a0ff0c282... 1
2 40fa2aa67258b4ce7b5782f74831d46a84c59a0ff0c282... 1
3 40fa2aa67258b4ce7b5782f74831d46a84c59a0ff0c282... 1
4 40fa2aa67258b4ce7b5782f74831d46a84c59a0ff0c282... 1

Get Assets Informations

Get informations about the assests under a specific policy.

assets_info, assets_not_found = cardano_mainnet.assets_policy_informations(policy_id, # Policy ID of the project
                                                                           nb_of_results=100, # Optional: Return max 100 results at the time (default: None), None for get all the data available.
                                                                           pandas=True) # Optional: Return a pandas dataframe 
asset policy_id asset_name fingerprint quantity initial_mint_tx_hash mint_or_burn_count name image body eyes brows mouth Project clothes background accessories hats and hair metadata wings
0 40fa2aa67258b4ce7b5782f74831d46a84c59a0ff0c282... 40fa2aa67258b4ce7b5782f74831d46a84c59a0ff0c282... 436c61794e6174696f6e37383939 asset1xkngd3y2njd3dzhfg25rtfp66gyvke6skqftxc 1 d7e089dce7c170f1af519fab710f9ed5d4d8680978035d... 1 Clay Nation #7899 ipfs://QmdXSPVnjRMsT2LuUMW5MMAKunwjpL34WDWjSy3... Tan Clay Trippy Eyes Blue Eyebrows Grin Clay Nation by Clay Mates Tracksuit Seafoam Green Silver Chain Clay Nation Hat & Mullet None NaN
1 40fa2aa67258b4ce7b5782f74831d46a84c59a0ff0c282... 40fa2aa67258b4ce7b5782f74831d46a84c59a0ff0c282... 436c61794e6174696f6e38343838 asset14pm7d5k9xtgeu87g7skz8sqvxjkepwsysdmvcg 1 a5e9fb001c2a0838d380acccc90eb06f9c06c74ce94eee... 1 Clay Nation #8488 ipfs://QmZfeNhctaLzmpNYAvkaoLcHR3yCvtBn44TNuUL... Tan Clay Big Eyes Normal Eyebrows Joint in Mouth Clay Nation by Clay Mates Tshirt Green Cyan No Accessories Top Hat None NaN

Data Analysis


Rewards History Analysis

Stake rewards analysis.

cardano_mainnet.rewards_history_analysis(stake_address)
#or
cardano_mainnet.rewards_history_analysis(stake_address,
                                         pandas=True) # Optional: Return a pandas dataframe 
epoch rewards_amount stake_amount pool_id epoch_start_time epoch_end_time epoch_first_block_time epoch_last_block_time epoch_block_count epoch_tx_count epoch_output epoch_fees epoch_active_stake stake_pool_blocks stake_pool_active_stake stake_pool_active_size stake_pool_delegators_count stake_pool_rewards stake_pool_fees
14 287 2270290 2843385384 pool1ekhy5xsgjaq38em75vevk8df0k0rljju77tljw288... 1630187091 1630619091 1630187230 1630619085 21065 401343 74754307451589173 86536781869 23041097075076811 47 40998606047892 0.001779 1413 33319647907 669796479
15 288 1768631 2866605326 pool1ekhy5xsgjaq38em75vevk8df0k0rljju77tljw288... 1630619091 1631051091 1630619101 1631051088 21136 475383 120564869080762073 99992854778 23136223153988390 49 55449417952886 0.002397 1439 34863643156 685236431
16 289 2390373 2868437494 pool1ekhy5xsgjaq38em75vevk8df0k0rljju77tljw288... 1631051091 1631483091 1631051131 1631483087 21195 501443 30450853050129419 105082493097 23311196777534712 66 55724573270655 0.002390 1443 47200199605 808601996
17 290 1878132 3002707784 pool1ekhy5xsgjaq38em75vevk8df0k0rljju77tljw288... 1631483091 1631915091 1631483266 1631915089 21320 423156 28653067841498377 88193252097 23253494675755279 49 54675837934319 0.002351 1440 34877628423 685376284
18 291 2059700 3004575519 pool1ekhy5xsgjaq38em75vevk8df0k0rljju77tljw288... 1631915091 1632347091 1631915193 1632347076 21261 415399 27614827533993432 88508486990 23219858534473043 54 54806809508971 0.002360 1451 38286415852 719464158

Developing

Tests run assuming you have set the API key in the environment variable BLOCKFROST_API_KEY, otherwise they will error.

python3 setup.py pytest

Credit

Donate

If this wrapper has been useful to you, feel free to put a star or donate (ADA) at this address :blush:.

wallet address

Thank you.

Disclaimer

The project is still under development, If you find bugs or want additional features, open an issue and/or create a pull request.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cardano_explorer-0.1.8.tar.gz (30.5 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page