@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) -> 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.1.tar.gz
(8.3 kB
view details)
Built Distribution
File details
Details for the file aiocryptopay-0.2.1.tar.gz
.
File metadata
- Download URL: aiocryptopay-0.2.1.tar.gz
- Upload date:
- Size: 8.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.12 CPython/3.9.7 Windows/10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3439d81ae1191492258fda1ca7e2292286e5467330303fd7b921f0b5390a0d32 |
|
MD5 | cb0b45f30524160f62ff628de316e78c |
|
BLAKE2b-256 | 43e72f2e560d28f2c0e34bbd8ca59c2d4566770ca1ddcade3424a287b914d4bd |
File details
Details for the file aiocryptopay-0.2.1-py3-none-any.whl
.
File metadata
- Download URL: aiocryptopay-0.2.1-py3-none-any.whl
- Upload date:
- Size: 11.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.12 CPython/3.9.7 Windows/10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5f7c1cac9e4dbda1964ca47d3aa967bd43663eb2df0fcce6d6a1c8af6783a768 |
|
MD5 | 125cebfb202be9e4702bf5543d051106 |
|
BLAKE2b-256 | eb96195a981642c22a4da9e0ea1306d976e71dfc8afdad8443fa8064eed0e99c |