Skip to main content

sync & async Crypto Pay API client.

Project description

aiocpa

Python Crypto Pay API Pydantic v2 Aiohttp Code linter: ruff Checked with mypy

aiocpa is a syncronous & asynchronous Crypto Pay API client.

Official documentation

Quick start

import asyncio
from cryptopay import CryptoPay


async def main():
    cp = CryptoPay(token="TOKEN")
    app = await cp.get_me()
    print(app.name)  # Your App Name


if __name__ == "__main__":
    asyncio.run(main())

aiogram 3.x integration example

import asyncio
from aiogram import Bot, Dispatcher
from cryptopay import CryptoPay

cp = CryptoPay("TOKEN")
bot = Bot("TOKEN")
dp = Dispatcher()


@dp.message()
async def get_invoice(message):
    invoice = await cp.create_invoice(1, "USDT")
    await message.answer(f"pay: {invoice.bot_invoice_url}")
    invoice.await_payment(message=message)


@cp.polling_handler()
async def handle_payment(invoice, message):
    await message.answer(f"invoice #{invoice.invoice_id} has been paid")


async def main():
    await asyncio.gather(
        dp.start_polling(bot),
        cp.run_polling(),
    )


if __name__ == "__main__":
    asyncio.run(main())

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

aiocpa-0.1.10.tar.gz (22.7 kB view hashes)

Uploaded Source

Built Distribution

aiocpa-0.1.10-py3-none-any.whl (42.3 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