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

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


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.6.tar.gz (9.1 kB view details)

Uploaded Source

Built Distribution

aiocryptopay-0.2.6-py3-none-any.whl (11.8 kB view details)

Uploaded Python 3

File details

Details for the file aiocryptopay-0.2.6.tar.gz.

File metadata

  • Download URL: aiocryptopay-0.2.6.tar.gz
  • Upload date:
  • Size: 9.1 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

Hashes for aiocryptopay-0.2.6.tar.gz
Algorithm Hash digest
SHA256 342b98a43b5d557e7f1f1c777df250cd6a824b32d868daf7466c1e93c9681eb8
MD5 b860722d33c5170682079371cfb4d384
BLAKE2b-256 b6e96cc93e932935f790c5bf35f32fd583bd577a52c22e0a2f7cdfa2baee44a3

See more details on using hashes here.

File details

Details for the file aiocryptopay-0.2.6-py3-none-any.whl.

File metadata

  • Download URL: aiocryptopay-0.2.6-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

Hashes for aiocryptopay-0.2.6-py3-none-any.whl
Algorithm Hash digest
SHA256 2d2bb7092e9e7f487f4f4f4dba8384cce672b1985b62f7eaa63b6b686dbf0279
MD5 f242fa60566821f2a1ea8046f2e99b5a
BLAKE2b-256 fc0133417c0be3aee163eb84072a263bf95a94e31dd81661445e876e429456cb

See more details on using hashes here.

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