Skip to main content

A Python library for interacting with Crypto Pay API by CryptoBot

Project description

CryptoPay

Crypto Pay API Python

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

Table of Contents

Installation

You can install the package using pip:

pip install crypto-pay-api-cryptobot

Usage

Getting Started

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}")

API Methods

Here are some of the key methods you can use with the crypto_pay library:

1. Get App Information

me = crypto_pay.get_me()
print(me)

2. Create an Invoice

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)

3. Delete an 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

4. Create a Check

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)

5. Transfer Coins

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)

6. Get Invoices

Retrieve a list of invoices created by your app:

invoices = crypto_pay.get_invoices()
print(invoices)

7. Get Balance

Get the balance of your app:

balance = crypto_pay.get_balance()
print(balance)

8. Get Exchange Rates

Retrieve the exchange rates of supported currencies:

exchange_rates = crypto_pay.get_exchange_rates()
print(exchange_rates)

License

This project is licensed under the MIT License. See the LICENSE file for details.

Contributing

Contributions are welcome! If you have suggestions for improvements or find bugs, please open an issue or submit a pull request.

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

crypto_pay_api_cryptobot-1.0.2.tar.gz (5.6 kB view details)

Uploaded Source

Built Distribution

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

crypto_pay_api_cryptobot-1.0.2-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

File details

Details for the file crypto_pay_api_cryptobot-1.0.2.tar.gz.

File metadata

File hashes

Hashes for crypto_pay_api_cryptobot-1.0.2.tar.gz
Algorithm Hash digest
SHA256 9ec13a6179d0444c013fd9696d4c0940f1fa42f885306093aedf45f8c679fe32
MD5 e8235eebcb37c1af4297746f7a4c2e6e
BLAKE2b-256 c657b172e307567fa8b7c9b9676bbd32e530a0670b34d5b6b14c6b845ed00062

See more details on using hashes here.

File details

Details for the file crypto_pay_api_cryptobot-1.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for crypto_pay_api_cryptobot-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 8816261fbb76736670d0818ea2b3e92afcf75abe14e09166a43fee92d7fd946a
MD5 a16ecce08185863edeedc08cd7be7d90
BLAKE2b-256 f2bc68e2c94b64b214d52dad794f9d9fec0fabb51f282db6f4ad6a81cb733d38

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