Skip to main content

Python SDK for Crypto Pay API

Project description

CryptoPaySDK - Python SDK for Crypto Pay API

PyPI version License: MIT

Official Python SDK for seamless integration with Crypto Pay - cryptocurrency payments platform in Telegram.

Key Features

  • Full coverage of Crypto Pay API methods
  • Simple and intuitive interface
  • Support for both mainnet and testnet environments
  • Type hints for better development experience
  • 100% API consistency with official documentation

Installation

pip install CryptoPaySDK

Getting Started

  1. Obtain API Token:

    Send /pay command to create your application.

  2. Environment Configuration:

Network Bot API Hostname
Mainnet @CryptoBot pay.crypt.bot
Testnet @CryptoTestnetBot testnet-pay.crypt.bot

All API requests must use HTTPS protocol

Basic Usage

from CryptoPaySDK import cryptopay

# Initialize client (testnet mode by default)
crypto = cryptopay.Crypto(
    api_token="YOUR_API_TOKEN",
    testnet=True  # Set False for production
)

# Get app information
print(crypto.getMe())

# Create payment invoice
invoice = crypto.createInvoice(
    asset="TON",
    amount="0.4",
    params={
        "description": "Premium subscription",
        "expires_in": 3600,
        "paid_btn_url": "https://your-service.com/premium"
    }
)

API Reference

Core Methods

getMe()

Verify authentication token and get basic app info.

response = crypto.getMe()

createInvoice(asset: str, amount: str, params: dict)

Create payment invoice.

Parameters:

  • asset - Cryptocurrency code (BTC, TON, ETH, USDT, etc.)
  • amount - Payment amount
  • params - Additional options:
    • description - Invoice description (max 1024 chars)
    • hidden_message - Post-payment message
    • paid_btn_name - Button type (viewItem/openChannel/openBot/callback)
    • paid_btn_url - Button URL (required if paid_btn_name set)
    • payload - Custom data (up to 4KB)
    • expires_in - Invoice TTL (1-2678400 seconds)
invoice = crypto.createInvoice(
    "BTC", "0.01",
    params={
        "description": "VIP Access",
        "paid_btn_name": "openBot",
        "paid_btn_url": "https://t.me/YourBot"
    }
)

transfer(user_id: int, asset: str, amount: str, spend_id: str, params: dict)

Send cryptocurrency to user.

Parameters:

  • user_id - Recipient Telegram ID
  • asset - Cryptocurrency code
  • amount - Transfer amount
  • spend_id - Unique operation ID (prevent duplicates)
  • params:
    • comment - Transfer note (max 1024 chars)
crypto.transfer(
    123456789, "TON", "5.0", "order_123",
    params={"comment": "Order #123 payment"}
)

Additional Methods

Method Description
getInvoices() Retrieve payment invoices
getBalance() Check current balance
getExchangeRates() Get current exchange rates
getCurrencies() List supported currencies

Error Handling

The SDK raises specific exceptions for different error scenarios:

  • AuthError - Invalid API token
  • NetworkError - Connection issues
  • APIError - Crypto Pay API errors
  • ValidationError - Invalid parameters
try:
    crypto.createInvoice("BTC", "0.01")
except CryptoPaySDK.exceptions.APIError as e:
    print(f"API Error: {e.message}")

License

MIT

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

cryptopaysdk-1.5.1.tar.gz (6.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cryptopaysdk-1.5.1-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

File details

Details for the file cryptopaysdk-1.5.1.tar.gz.

File metadata

  • Download URL: cryptopaysdk-1.5.1.tar.gz
  • Upload date:
  • Size: 6.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.0

File hashes

Hashes for cryptopaysdk-1.5.1.tar.gz
Algorithm Hash digest
SHA256 66345a594309bfeaf017564fb966ce22273b69a67b922add58c83fd62a744509
MD5 16a558440fe8b347b86460f3ebb9ab9d
BLAKE2b-256 126b5f9fda7c0bad90be035bf9a39caf205bd3766808e1e784ab6d5a46ede32d

See more details on using hashes here.

File details

Details for the file cryptopaysdk-1.5.1-py3-none-any.whl.

File metadata

  • Download URL: cryptopaysdk-1.5.1-py3-none-any.whl
  • Upload date:
  • Size: 6.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.0

File hashes

Hashes for cryptopaysdk-1.5.1-py3-none-any.whl
Algorithm Hash digest
SHA256 429f9805d2080ea11ab2574736b9c0427b5c7984cf92ace8d45f64ae8b61ac1a
MD5 751d61aa7feada22b63a695cb2454bf4
BLAKE2b-256 532f8be21a23515388779a69f9fe3e679aa13840cbfe44f2e3b77f90cc337ba9

See more details on using hashes here.

Supported by

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