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

Uploaded Source

Built Distribution

aiocryptopay-0.2.4-py3-none-any.whl (11.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: aiocryptopay-0.2.4.tar.gz
  • Upload date:
  • Size: 8.9 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.4.tar.gz
Algorithm Hash digest
SHA256 9d47350d8e907fcb18f744875b1b3fb3f0c1928934820fadad23b5f246884992
MD5 df822e9d783cc45533603077bedaf62c
BLAKE2b-256 6dca2d7d006c0f48f3e14698790b73521ed8bf1598ce3d42b3710223a3de4054

See more details on using hashes here.

File details

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

File metadata

  • Download URL: aiocryptopay-0.2.4-py3-none-any.whl
  • Upload date:
  • Size: 11.7 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.4-py3-none-any.whl
Algorithm Hash digest
SHA256 aec7d6f514da4801f51341218bdf55125a84bee9cf5aadab4348e52138e59b05
MD5 5064aed4d9b021e06927e68e39788b3a
BLAKE2b-256 88e31acadf2adb815af8a43f8e83c7a9e1a192733fab73657916dad85dbb8650

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