Skip to main content

BlockAPI library

Project description

blockapi

Library to interact with numerous cryptocurrency data APIs to get the basic info about account balance, transactions, staking informations, etc. List of supported coins:

coin API name supported operations
XTZ TzscanAPI balance, transactions, activations, originations, delegations, endorsements, bakings
TzStatsAPI staking (balance, rewards)
ATOM CosmosAPI balance, transactions, rewards, delegates, votes
DCR DcrdataAPI balance, transactions
ADA CardanoExplorerAPI balance, transactions
ZEC ChainSoAPI balance, transactions
MercerweissAPI balance
ZchainAPI balance
ETC BlockscoutAPI balance
NEO NeoscanAPI balance, transactions
ZEN ZensystemAPI balance
DASH ChainSoAPI balance, transactions
CryptoIDAPI balance
DOGE ChainSoAPI balance, transactions
BNB BinanceAPI balance,transactions
EOS EosparkAPI balance, transactions
GreymassAPI balance
BCH BtcAPI balance
XLM StellarAPI balance
RVN RavencoinAPI balance
TRX TronscanAPI balance
LTC BlockcypherAPI balance
ChainSoAPI balance, transactions
CryptoIDAPI balance
Ltc1TrezorAPI balance, transactions
BTC BlockchainInfoAPI balance, transactions
BlockonomicsAPI balance, transactions
ChainSoAPI balance, transactions
Btc1TrezorAPI balance, transactions
Btc2TrezorAPI balance, transactions
BitpayAPI balance
GRS CryptoIDAPI balance
ETH AlethioAPI balance, transactions, events
EtherscanAPI balance, transactions
EthplorerAPI balance
ONT OntioAPI balance, transactions
VET DigonchainAPI balance
BOS BlockchainosAPI balance, transactions
LUNA TerraMoneyAPI balance, transactions, delegations
DOT SubscanPolkaAPI balance, transactions, staking (locked, rewards)
KSM SubscanKusamaAPI balance, transactions, staking (locked, rewards)

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.

Prerequisites

Python 3.x, PIP (if you'd like to install it this way).

Installing

Library can be installed simply with pip:

pip install blockapi

or by running:

make install

Usage examples

Example usage to get account balance:

import blockapi
myobj = blockapi.api.BlockchainInfoAPI("bitcoin-address-here")
myobj.get_balance()

For some coins there are multiple APIs available. With get_random_api_class_for_coin it is possible to randomly pick any of the available APIs:

myapi = blockapi.get_random_api_class_for_coin('BTC')('1F1tAaz5x1HUXrCNLbtMDqcw6o5GNn4xqX')
myapi.get_balance()

To directly pick first random working API and ask it for the account balance:

>>> blockapi.get_balance_from_random_api('BTC','16ftSEQ4ctQFDtVZiUBusQUjRrGhM3JYwe')
0.010034040000000001

It is possible to ask for a list of working APIs for a coin. They are automatically checked first if they work (test is done with asking for a balance). Only APIs which pass this check are returned:

>>> blockapi.get_working_apis_for_coin('BTC')
(<class 'blockapi.api.blockchaininfo.BlockchainInfoAPI'>, <class 'blockapi.api.blockonomics.BlockonomicsAPI'>, <class 'blockapi.api.insight.BitpayAPI'>, <class 'blockapi.api.trezor.Btc2TrezorAPI'>, <class 'blockapi.api.trezor.Btc1TrezorAPI'>)

During the API instance creation the supplied address is being checked for validity, if the address is not valid, ValueError exception is being raised:

>>> import blockapi
>>> blockapi.api.CosmosAPI('blahblah')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/srv/apps/blockapi/src/blockapi/blockapi/services.py", line 195, in __init__
self.check_validity()
File "/srv/apps/blockapi/src/blockapi/blockapi/services.py", line 201, in check_validity
self.symbol, self.address_info.address
ValueError: Not a valid ATOM address: b'blahblah'

It is possible to display the result of the address validation with included details like validity, network type, address type, or the info whether the supplied address is an extended one. Not for all coins all the details are available though:

>>> import blockapi
>>> myapi = blockapi.api.TzscanAPI('valid tezos address here')
>>> myapi.address_info
ValidationResult(name='tezos', ticker='xtz', address=b'valid tezos-address here', valid=True, network='both', is_extended=False, address_type='originated_account')

Running the tests

To run the included tests simply issue:

make test

Contributing

TBD

Authors

  • **Devmons s.r.o. - Initial work - crypkit

See also the list of contributors who participated in this project.

Credits

  • **Chris Priest - moneywagon library we took many ideas from - moneywagon
  • **Joe Black - Address validation library - coinaddr

License

This project is licensed under the MIT License - see the LICENSE.md file for details

Project details


Release history Release notifications | RSS feed

Download files

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

Source Distribution

blockapi-0.1.23.tar.gz (71.6 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

blockapi-0.1.23-py3.9.egg (273.0 kB view details)

Uploaded Egg

blockapi-0.1.23-py3-none-any.whl (109.8 kB view details)

Uploaded Python 3

File details

Details for the file blockapi-0.1.23.tar.gz.

File metadata

  • Download URL: blockapi-0.1.23.tar.gz
  • Upload date:
  • Size: 71.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.5

File hashes

Hashes for blockapi-0.1.23.tar.gz
Algorithm Hash digest
SHA256 440852bbf983fb2a67bf7911f911125d665684b0594332fb00db0d3060b72f93
MD5 81d8f81c9fbd1ae338d6f0372f3b2cb1
BLAKE2b-256 c3e8d8052b448d253479e9e37885e7aebf39f60dfa2ee578a1c27ac963a33723

See more details on using hashes here.

File details

Details for the file blockapi-0.1.23-py3.9.egg.

File metadata

  • Download URL: blockapi-0.1.23-py3.9.egg
  • Upload date:
  • Size: 273.0 kB
  • Tags: Egg
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.5

File hashes

Hashes for blockapi-0.1.23-py3.9.egg
Algorithm Hash digest
SHA256 e0c5533443955e74e9535dba90d522bd15f5743095e1a500adaecbd099cab5f1
MD5 6ac9ce6e49f63834d07d15e7c937c72e
BLAKE2b-256 768558491f4aa5ffa2a858af48afeebac0fbdd81fb86abfcd3ab429eb1b55a65

See more details on using hashes here.

File details

Details for the file blockapi-0.1.23-py3-none-any.whl.

File metadata

  • Download URL: blockapi-0.1.23-py3-none-any.whl
  • Upload date:
  • Size: 109.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.5

File hashes

Hashes for blockapi-0.1.23-py3-none-any.whl
Algorithm Hash digest
SHA256 55438a5f9a09a9e6787415bc642cec0c16a34a6cad8e125763033a05248185ba
MD5 066f6c12188e9ca5c10d9a70f55d4daa
BLAKE2b-256 dd2e46bc0eed260906d87c864898b6f1c9537b20181b777f2f91c9cf101a4ed0

See more details on using hashes here.

Supported by

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