Python SDK for Crypto Pay API
Project description
CryptoPaySDK - Python SDK for Crypto Pay API
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
-
Obtain API Token:
- Mainnet: @CryptoBot
- Testnet: @CryptoTestnetBot
Send
/paycommand to create your application. -
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 amountparams- Additional options:description- Invoice description (max 1024 chars)hidden_message- Post-payment messagepaid_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 IDasset- Cryptocurrency codeamount- Transfer amountspend_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 tokenNetworkError- Connection issuesAPIError- Crypto Pay API errorsValidationError- Invalid parameters
try:
crypto.createInvoice("BTC", "0.01")
except CryptoPaySDK.exceptions.APIError as e:
print(f"API Error: {e.message}")
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cryptopaysdk-1.5.2.tar.gz.
File metadata
- Download URL: cryptopaysdk-1.5.2.tar.gz
- Upload date:
- Size: 7.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c0b7ee3f8fa7fb51a77f6841fd43769948ddf6aebbf77790cacfcbd768ed139a
|
|
| MD5 |
e66e1cc3f81bf8c136de8497b40b3c9c
|
|
| BLAKE2b-256 |
9f59c38613959f12513b70b94100d89ba767855df7a3a090fa5012bc455079ef
|
File details
Details for the file cryptopaysdk-1.5.2-py3-none-any.whl.
File metadata
- Download URL: cryptopaysdk-1.5.2-py3-none-any.whl
- Upload date:
- Size: 6.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aa52aa3258a077da586403b75c22c3c07278799692450d21003f900ef7639e73
|
|
| MD5 |
523d0f88985dd53abdb471b6da1c3edd
|
|
| BLAKE2b-256 |
d108da2484086a619ac1f104147095ab7b73161627e7df9ea5e3f575754e420a
|