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

Uploaded Source

Built Distribution

aiocpa-0.1.9-py3-none-any.whl (42.3 kB view details)

Uploaded Python 3

File details

Details for the file aiocpa-0.1.9.tar.gz.

File metadata

  • Download URL: aiocpa-0.1.9.tar.gz
  • Upload date:
  • Size: 21.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.6 Windows/11

File hashes

Hashes for aiocpa-0.1.9.tar.gz
Algorithm Hash digest
SHA256 247c0e66d28af564a6ce811ceef983cea982cc347676f65f3a5f103701b49a0f
MD5 714207f4085ff3eecec235cfc3ad9beb
BLAKE2b-256 ab15367f4d214922c9a1d3aaa211d37dc91a6a2062a0a66ca7afc5448201ff6e

See more details on using hashes here.

Provenance

File details

Details for the file aiocpa-0.1.9-py3-none-any.whl.

File metadata

  • Download URL: aiocpa-0.1.9-py3-none-any.whl
  • Upload date:
  • Size: 42.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.6 Windows/11

File hashes

Hashes for aiocpa-0.1.9-py3-none-any.whl
Algorithm Hash digest
SHA256 1ca92b8193ba8e30a7219802649854d2d5c0be8f63362e89bd217575d52b0a13
MD5 5bf8f7e5589c5cf5769e0e018a9d609b
BLAKE2b-256 c28a21698f060b9469db3a3c30ea679f2e1b65c7b833ecfc091eda7087b964d0

See more details on using hashes here.

Provenance

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