blockapi


Nameblockapi JSON
Version 0.48.4 PyPI version JSON
download
home_pageNone
SummaryBlockAPI library
upload_time2024-10-22 12:41:53
maintainerNone
docs_urlNone
authorDevmons s.r.o.
requires_pythonNone
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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](https://github.com/crypkit)

See also the list of [contributors](https://github.com/crypkit/blockapi/contributors) who participated in this project.

## Credits

* **Chris Priest - *moneywagon library we took many ideas from* - [moneywagon](https://github.com/priestc/moneywagon)
* **Joe Black - *Address validation library* - [coinaddr](https://github.com/joeblackwaslike/coinaddr)

## License

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




            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "blockapi",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": null,
    "author": "Devmons s.r.o.",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/d7/f8/37873cc06eb06f838cc44f0c3f1d46ee289dc3be40c7e1322fb0da9809c4/blockapi-0.48.4.tar.gz",
    "platform": null,
    "description": "# blockapi\n\nLibrary to interact with numerous cryptocurrency data APIs to get the basic info about account balance, transactions, staking informations, etc.\nList of supported coins:\n\n| coin  | API name | supported operations\n| :---- | :------------| :---------------------\n| XTZ   | TzscanAPI   | balance, transactions, activations, originations, delegations, endorsements, bakings\n|       | TzStatsAPI  | staking (balance, rewards)\n| ATOM  | CosmosAPI   | balance, transactions, rewards, delegates, votes\n| DCR   | DcrdataAPI  | balance, transactions\n| ADA   | CardanoExplorerAPI | balance, transactions\n| ZEC   | ChainSoAPI  | balance, transactions\n|       | MercerweissAPI | balance\n|       | ZchainAPI | balance\n| ETC   | BlockscoutAPI | balance\n| NEO   | NeoscanAPI | balance, transactions\n| ZEN   | ZensystemAPI | balance\n| DASH  | ChainSoAPI | balance, transactions\n|       | CryptoIDAPI | balance\n| DOGE  | ChainSoAPI |balance, transactions\n| BNB   | BinanceAPI |balance,transactions\n| EOS   | EosparkAPI |balance, transactions\n|       | GreymassAPI | balance\n| BCH   | BtcAPI | balance\n| XLM   | StellarAPI | balance\n| RVN   | RavencoinAPI | balance\n| TRX   | TronscanAPI | balance\n| LTC   | BlockcypherAPI | balance\n|       | ChainSoAPI | balance, transactions\n|       | CryptoIDAPI | balance\n|       | Ltc1TrezorAPI | balance, transactions\n| BTC   | BlockchainInfoAPI | balance, transactions\n|       | BlockonomicsAPI | balance, transactions\n|       | ChainSoAPI | balance, transactions\n|       | Btc1TrezorAPI | balance, transactions\n|       | Btc2TrezorAPI | balance, transactions\n|       | BitpayAPI | balance\n| GRS   | CryptoIDAPI | balance\n| ETH   | AlethioAPI | balance, transactions, events \n|       | EtherscanAPI | balance, transactions\n|       | EthplorerAPI | balance\n| ONT   | OntioAPI | balance, transactions\n| VET   | DigonchainAPI | balance\n| BOS   | BlockchainosAPI | balance, transactions\n| LUNA  | TerraMoneyAPI | balance, transactions, delegations\n| DOT   | SubscanPolkaAPI | balance, transactions, staking (locked, rewards)\n| KSM   | SubscanKusamaAPI | balance, transactions, staking (locked, rewards)\n\n## Getting Started\n\nThese instructions will get you a copy of the project up and running on your local machine for development and testing purposes.\n\n### Prerequisites\n\nPython 3.x, PIP (if you'd like to install it this way).\n\n### Installing\n\nLibrary can be installed simply with pip:\n\n```\npip install blockapi\n```\n\nor by running:\n```\nmake install\n```\n\n### Usage examples\n\nExample usage to get account balance:\n```\nimport blockapi\nmyobj = blockapi.api.BlockchainInfoAPI(\"bitcoin-address-here\")\nmyobj.get_balance()\n```\n\nFor some coins there are multiple APIs available. With get_random_api_class_for_coin it is possible\nto randomly pick any of the available APIs:\n```\nmyapi = blockapi.get_random_api_class_for_coin('BTC')('1F1tAaz5x1HUXrCNLbtMDqcw6o5GNn4xqX')\nmyapi.get_balance()\n```\n\nTo directly pick first random working API and ask it for the account balance:\n```\n>>> blockapi.get_balance_from_random_api('BTC','16ftSEQ4ctQFDtVZiUBusQUjRrGhM3JYwe')\n0.010034040000000001\n```\n\nIt 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:\n```\n>>> blockapi.get_working_apis_for_coin('BTC')\n(<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'>)\n```\n\nDuring the API instance creation the supplied address is being checked for validity, if the address\nis not valid, ValueError exception is being raised:\n```\n>>> import blockapi\n>>> blockapi.api.CosmosAPI('blahblah')\nTraceback (most recent call last):\nFile \"<stdin>\", line 1, in <module>\nFile \"/srv/apps/blockapi/src/blockapi/blockapi/services.py\", line 195, in __init__\nself.check_validity()\nFile \"/srv/apps/blockapi/src/blockapi/blockapi/services.py\", line 201, in check_validity\nself.symbol, self.address_info.address\nValueError: Not a valid ATOM address: b'blahblah'\n```\n\nIt 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.\nNot for all coins all the details are available though:\n```\n>>> import blockapi\n>>> myapi = blockapi.api.TzscanAPI('valid tezos address here')\n>>> myapi.address_info\nValidationResult(name='tezos', ticker='xtz', address=b'valid tezos-address here', valid=True, network='both', is_extended=False, address_type='originated_account')\n```\n\n## Running the tests\n\nTo run the included tests simply issue:\n\n```\nmake test\n```\n\n## Contributing\n\nTBD\n\n## Authors\n\n* **Devmons s.r.o. - *Initial work* - [crypkit](https://github.com/crypkit)\n\nSee also the list of [contributors](https://github.com/crypkit/blockapi/contributors) who participated in this project.\n\n## Credits\n\n* **Chris Priest - *moneywagon library we took many ideas from* - [moneywagon](https://github.com/priestc/moneywagon)\n* **Joe Black - *Address validation library* - [coinaddr](https://github.com/joeblackwaslike/coinaddr)\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details\n\n\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "BlockAPI library",
    "version": "0.48.4",
    "project_urls": null,
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2ab6c189399f2af8ba105ae8012138dc6143083d3ea0c69b3f659f6280626c48",
                "md5": "8a7b8b31797d9703ce20d7b1cc9be859",
                "sha256": "e365655b191704d38c75c4b6edfc2954f25e677ecaa87d28761d58c32fae4aa6"
            },
            "downloads": -1,
            "filename": "blockapi-0.48.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "8a7b8b31797d9703ce20d7b1cc9be859",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 178499,
            "upload_time": "2024-10-22T12:41:51",
            "upload_time_iso_8601": "2024-10-22T12:41:51.960370Z",
            "url": "https://files.pythonhosted.org/packages/2a/b6/c189399f2af8ba105ae8012138dc6143083d3ea0c69b3f659f6280626c48/blockapi-0.48.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d7f837873cc06eb06f838cc44f0c3f1d46ee289dc3be40c7e1322fb0da9809c4",
                "md5": "888eaf7db73a7bafc24178f6beb45be2",
                "sha256": "c196a625bc2bd8bda6c9add02012f1030174090770e6b391413abfb47526d86d"
            },
            "downloads": -1,
            "filename": "blockapi-0.48.4.tar.gz",
            "has_sig": false,
            "md5_digest": "888eaf7db73a7bafc24178f6beb45be2",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 125512,
            "upload_time": "2024-10-22T12:41:53",
            "upload_time_iso_8601": "2024-10-22T12:41:53.164967Z",
            "url": "https://files.pythonhosted.org/packages/d7/f8/37873cc06eb06f838cc44f0c3f1d46ee289dc3be40c7e1322fb0da9809c4/blockapi-0.48.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-22 12:41:53",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "blockapi"
}
        
Elapsed time: 0.55359s