## **[@cryptobot](https://t.me/CryptoBot) asynchronous api wrapper**
**Docs:** https://help.crypt.bot/crypto-pay-api
- MainNet - [@CryptoBot](http://t.me/CryptoBot)
- TestNet - [@CryptoTestnetBot](http://t.me/CryptoTestnetBot)
**Install**
``` bash
pip install aiocryptopay
poetry add aiocryptopay
```
**Basic methods**
``` python
from aiocryptopay import AioCryptoPay, Networks
crypto = AioCryptoPay(token='1337:JHigdsaASq', network=Networks.MAIN_NET)
profile = await crypto.get_me()
currencies = await crypto.get_currencies()
balance = await crypto.get_balance()
rates = await crypto.get_exchange_rates()
print(profile, currencies, balance, rates, sep='\n')
```
**Create, get and delete invoice methods**
``` python
from aiocryptopay import AioCryptoPay, Networks
crypto = AioCryptoPay(token='1337:JHigdsaASq', network=Networks.MAIN_NET)
invoice = await crypto.create_invoice(asset='TON', amount=1.5)
print(invoice.bot_invoice_url)
# Create invoice in fiat
fiat_invoice = await crypto.create_invoice(amount=5, fiat='USD', currency_type='fiat')
print(fiat_invoice)
old_invoice = await crypto.get_invoices(invoice_ids=invoice.invoice_id)
print(old_invoice.status)
deleted_invoice = await crypto.delete_invoice(invoice_id=invoice.invoice_id)
print(deleted_invoice)
# Get amount in crypto by fiat summ
amount = await crypto.get_amount_by_fiat(summ=100, asset='TON', target='USD')
invoice = await crypto.create_invoice(asset='TON', amount=amount)
print(invoice.bot_invoice_url)
```
**Create, get and delete check methods**
``` python
# The check creation method works when enabled in the application settings
from aiocryptopay import AioCryptoPay, Networks
crypto = AioCryptoPay(token='1337:JHigdsaASq', network=Networks.MAIN_NET)
check = await crypto.create_check(asset='USDT', amount=1)
print(check)
old_check = await crypto.get_checks(check_ids=check.check_id)
print(old_check)
deleted_check = await crypto.delete_check(check_id=check.check_id)
print(deleted_check)
```
**WebHook usage**
``` python
from aiohttp import web
from aiocryptopay import AioCryptoPay, Networks
from aiocryptopay.models.update import Update
web_app = web.Application()
crypto = AioCryptoPay(token='1337:JHigdsaASq', network=Networks.MAIN_NET)
@crypto.pay_handler()
async def invoice_paid(update: Update, app) -> None:
print(update)
async def create_invoice(app) -> None:
invoice = await crypto.create_invoice(asset='TON', amount=1.5)
print(invoice.bot_invoice_url)
async def close_session(app) -> None:
await crypto.close()
web_app.add_routes([web.post('/crypto-secret-path', crypto.get_updates)])
web_app.on_startup.append(create_invoice)
web_app.on_shutdown.append(close_session)
web.run_app(app=web_app, host='localhost', port=3001)
```
Raw data
{
"_id": null,
"home_page": "https://github.com/layerqa/aiocryptopay",
"name": "aiocryptopay",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.8,<4.0",
"maintainer_email": "",
"keywords": "aiocryptopay,cryptobot,cryptopay,cryptopay api,cryptobot api",
"author": "layerqa",
"author_email": "",
"download_url": "https://files.pythonhosted.org/packages/e1/9c/c4ab606c30ada4cab3f448eb7b36a51b9618604bbcd8f43a6073ee60ccfe/aiocryptopay-0.3.5.tar.gz",
"platform": null,
"description": "## **[@cryptobot](https://t.me/CryptoBot) asynchronous api wrapper**\n**Docs:** https://help.crypt.bot/crypto-pay-api\n\n - MainNet - [@CryptoBot](http://t.me/CryptoBot)\n - TestNet - [@CryptoTestnetBot](http://t.me/CryptoTestnetBot)\n\n\n**Install**\n``` bash\npip install aiocryptopay\npoetry add aiocryptopay\n```\n\n**Basic methods**\n``` python\nfrom aiocryptopay import AioCryptoPay, Networks\n\ncrypto = AioCryptoPay(token='1337:JHigdsaASq', network=Networks.MAIN_NET)\n\nprofile = await crypto.get_me()\ncurrencies = await crypto.get_currencies()\nbalance = await crypto.get_balance()\nrates = await crypto.get_exchange_rates()\n\nprint(profile, currencies, balance, rates, sep='\\n')\n```\n\n**Create, get and delete invoice methods**\n``` python\nfrom aiocryptopay import AioCryptoPay, Networks\n\ncrypto = AioCryptoPay(token='1337:JHigdsaASq', network=Networks.MAIN_NET)\n\ninvoice = await crypto.create_invoice(asset='TON', amount=1.5)\nprint(invoice.bot_invoice_url)\n\n# Create invoice in fiat\nfiat_invoice = await crypto.create_invoice(amount=5, fiat='USD', currency_type='fiat')\nprint(fiat_invoice)\n\nold_invoice = await crypto.get_invoices(invoice_ids=invoice.invoice_id)\nprint(old_invoice.status)\n\ndeleted_invoice = await crypto.delete_invoice(invoice_id=invoice.invoice_id)\nprint(deleted_invoice)\n\n# Get amount in crypto by fiat summ\namount = await crypto.get_amount_by_fiat(summ=100, asset='TON', target='USD')\ninvoice = await crypto.create_invoice(asset='TON', amount=amount)\nprint(invoice.bot_invoice_url)\n```\n\n**Create, get and delete check methods**\n``` python\n# The check creation method works when enabled in the application settings\n\nfrom aiocryptopay import AioCryptoPay, Networks\n\ncrypto = AioCryptoPay(token='1337:JHigdsaASq', network=Networks.MAIN_NET)\n\ncheck = await crypto.create_check(asset='USDT', amount=1)\nprint(check)\n\nold_check = await crypto.get_checks(check_ids=check.check_id)\nprint(old_check)\n\ndeleted_check = await crypto.delete_check(check_id=check.check_id)\nprint(deleted_check)\n```\n\n\n**WebHook usage**\n``` python\nfrom aiohttp import web\n\nfrom aiocryptopay import AioCryptoPay, Networks\nfrom aiocryptopay.models.update import Update\n\n\nweb_app = web.Application()\ncrypto = AioCryptoPay(token='1337:JHigdsaASq', network=Networks.MAIN_NET)\n\n\n@crypto.pay_handler()\nasync def invoice_paid(update: Update, app) -> None:\n print(update)\n\nasync def create_invoice(app) -> None:\n invoice = await crypto.create_invoice(asset='TON', amount=1.5)\n print(invoice.bot_invoice_url)\n\nasync def close_session(app) -> None:\n await crypto.close()\n\n\nweb_app.add_routes([web.post('/crypto-secret-path', crypto.get_updates)])\nweb_app.on_startup.append(create_invoice)\nweb_app.on_shutdown.append(close_session)\nweb.run_app(app=web_app, host='localhost', port=3001)\n```\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "@cryptobot api asynchronous python wrapper",
"version": "0.3.5",
"project_urls": {
"Documentation": "https://help.crypt.bot/crypto-pay-api",
"Homepage": "https://github.com/layerqa/aiocryptopay",
"Repository": "https://github.com/layerqa/aiocryptopay"
},
"split_keywords": [
"aiocryptopay",
"cryptobot",
"cryptopay",
"cryptopay api",
"cryptobot api"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "3e4a6e6163ed5ecc78862c011ffa787d11e07b702a78d1989d387d01d0650bfa",
"md5": "dccfdd85adaa9431a69dacd44b213d06",
"sha256": "cfee232fb6977c309ec8d036f0e9bc906a758172ffb02e464f2999555b7e6e4d"
},
"downloads": -1,
"filename": "aiocryptopay-0.3.5-py3-none-any.whl",
"has_sig": false,
"md5_digest": "dccfdd85adaa9431a69dacd44b213d06",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8,<4.0",
"size": 13525,
"upload_time": "2023-12-08T03:30:40",
"upload_time_iso_8601": "2023-12-08T03:30:40.797810Z",
"url": "https://files.pythonhosted.org/packages/3e/4a/6e6163ed5ecc78862c011ffa787d11e07b702a78d1989d387d01d0650bfa/aiocryptopay-0.3.5-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "e19cc4ab606c30ada4cab3f448eb7b36a51b9618604bbcd8f43a6073ee60ccfe",
"md5": "2b1714d03e8b19d6a7176105fbc4b570",
"sha256": "c1b218c195a0c235536c11e02b904dc7a3620faf98ec3e6343e9472eecd4c933"
},
"downloads": -1,
"filename": "aiocryptopay-0.3.5.tar.gz",
"has_sig": false,
"md5_digest": "2b1714d03e8b19d6a7176105fbc4b570",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8,<4.0",
"size": 10475,
"upload_time": "2023-12-08T03:30:42",
"upload_time_iso_8601": "2023-12-08T03:30:42.952872Z",
"url": "https://files.pythonhosted.org/packages/e1/9c/c4ab606c30ada4cab3f448eb7b36a51b9618604bbcd8f43a6073ee60ccfe/aiocryptopay-0.3.5.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-12-08 03:30:42",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "layerqa",
"github_project": "aiocryptopay",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "aiocryptopay"
}