@cryptobot api asynchronous python wrapper
Project description
@cryptobot asynchronous api wrapper
Docs: https://help.crypt.bot/crypto-pay-api
- MainNet - @CryptoBot
- TestNet - @CryptoTestnetBot
Install
pip install aiocryptopay
poetry add aiocryptopay
Basic methods
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 and get invoice methods
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.pay_url)
invoices = await crypto.get_invoices(invoice_ids=invoice.invoice_id)
print(invoices.status)
WebHook usage
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.pay_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)
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
aiocryptopay-0.2.8.tar.gz
(9.2 kB
view details)
Built Distribution
File details
Details for the file aiocryptopay-0.2.8.tar.gz
.
File metadata
- Download URL: aiocryptopay-0.2.8.tar.gz
- Upload date:
- Size: 9.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.2.2 CPython/3.9.2 Linux/4.4.0-19041-Microsoft
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fd7ef1e6ec5f237ac4caa477637eb4f422097d9607455c5fab77448157cb178a |
|
MD5 | f3d30b713c15116f7bf2c0a5beb8d0fc |
|
BLAKE2b-256 | 3eedd0e0bda5de68d0bbd31246056d212af18cce171bbfa14610ca2cc43fa8ab |
File details
Details for the file aiocryptopay-0.2.8-py3-none-any.whl
.
File metadata
- Download URL: aiocryptopay-0.2.8-py3-none-any.whl
- Upload date:
- Size: 11.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.2.2 CPython/3.9.2 Linux/4.4.0-19041-Microsoft
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d24b2035767170b5fd415be1d8ce0a46a1f386bc05ea814623436403499c19a0 |
|
MD5 | 5f678839849b79cb5fe499b107907273 |
|
BLAKE2b-256 | cc69007d04f4af268cf19f14052217254cf3b870cc2258101f443db95961a794 |