@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
api = AioCryptoPay(token='1337:JHigdsaASq', network=Networks.MAIN_NET)
profile = await api.get_me()
currencies = await api.get_currencies()
balance = await api.get_balance()
rates = await api.get_exchange_rates()
print(profile, currencies, balance, rates, sep='\n')
Create and get invoice methods
from aiocryptopay import AioCryptoPay, Networks
api = AioCryptoPay(token='1337:JHigdsaASq', network=Networks.MAIN_NET)
invoice = await api.create_invoice(asset='TON', amount=1.5)
print(invoice.pay_url)
invoices = await api.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) -> None:
print(update)
async def create_invoice(app) -> None:
invoice = await crypto.create_invoice(asset='TON', amount=1.5)
print(invoice.pay_url)
web_app.add_routes([web.post('/crypto-secret-path', crypto.get_updates)])
web_app.on_startup.append(create_invoice)
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.0.tar.gz
(8.2 kB
view hashes)
Built Distribution
Close
Hashes for aiocryptopay-0.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 88e6e9597104d042b5de5120fdeaa4466b84ddbdac1fc43265fad1f80a9e7c64 |
|
MD5 | 51af71a317ef1c87f34fbce169c5d403 |
|
BLAKE2b-256 | 673bc9a43a7d647570576f7c885435ddb1c1943c5893d76cdcdec6c095ca3b40 |