Skip to main content

@cryptobot api asynchronous python wrapper

Project description

@cryptobot asynchronous api wrapper

Docs: https://help.crypt.bot/crypto-pay-api

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


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)

Uploaded Source

Built Distribution

aiocryptopay-0.2.0-py3-none-any.whl (11.0 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page