A Python library for interacting with the Crypto Pay API, allowing you to accept payments in cryptocurrency and manage transactions easily.
Official documentation: https://help.crypt.bot/crypto-pay-api
You can install the package using pip
:
pip install crypto-pay-api-cryptobot
To start using the crypto_pay
library, you first need to create an application and obtain an API token from the Crypto Pay bot. Once you have your token, you can create an instance of the CryptoPay
class.
from crypto_pay import CryptoPay
# Your API token
TOKEN = 'YOUR_API_TOKEN'
# Create an instance of CryptoPay
crypto_pay = CryptoPay(TOKEN)
# Example: Get app information
try:
me = crypto_pay.get_me()
print(me)
except Exception as e:
print(f"Error: {e}")
Here are some of the key methods you can use with the crypto_pay
library:
me = crypto_pay.get_me()
print(me)
You can create a new invoice by specifying the asset and amount:
invoice = crypto_pay.create_invoice('BTC', '0.01', {
'description': 'Payment for services',
'expires_in': 3600 # Invoice expires in 1 hour
})
print(invoice)
To delete an invoice, you need to provide the invoice ID:
result = crypto_pay.delete_invoice(invoice_id)
print(result) # Should return True on success
You can create a check that can be activated by a user:
check = crypto_pay.create_check('ETH', '0.05', pin_to_user_id=123456789)
print(check)
To transfer coins from your app's balance to a user, use the transfer method:
transfer_result = crypto_pay.transfer(user_id=123456789, asset='USDT', amount='10.00', spend_id='unique_spend_id')
print(transfer_result)
Retrieve a list of invoices created by your app:
invoices = crypto_pay.get_invoices()
print(invoices)
Get the balance of your app:
balance = crypto_pay.get_balance()
print(balance)
Retrieve the exchange rates of supported currencies:
exchange_rates = crypto_pay.get_exchange_rates()
print(exchange_rates)
This project is licensed under the MIT License. See the LICENSE file for details.
Contributions are welcome! If you have suggestions for improvements or find bugs, please open an issue or submit a pull request.