API for CryptoBot
Project description
cryptopayclient
cryptopayclient is a Python library for interacting with the CryptoBot API.
Installation
To install the library, use pip:
pip install requests
git clone https://github.com/andrewzaycew/cryptopayclient
cd cryptopayclient
pip install ./
or
pip install cryptopayclient
Usage
Initializing the Client
from cryptopayclient import CryptoBotClient
api_token = "YOUR_API_TOKEN"
client = CryptoBotClient(api_token=api_token, use_testnet=True)
Methods
get_me
Tests the authentication token of your app.
result = client.get_me()
print(result)
create_invoice
Creates a new invoice.
Parameters:
amount(str): The amount of the invoice.currency_type(str, optional): The type of currency, can be "crypto" or "fiat". Defaults to "crypto".asset(str, optional): The cryptocurrency code, required ifcurrency_typeis "crypto".fiat(str, optional): The fiat currency code, required ifcurrency_typeis "fiat".accepted_assets(str, optional): List of cryptocurrency codes separated by commas that can be used to pay the invoice.description(str, optional): Description of the invoice.hidden_message(str, optional): Text of the message presented to the user after the invoice is paid.paid_btn_name(str, optional): Label of the button presented to the user after the invoice is paid.paid_btn_url(str, optional): URL opened by the button presented to the user.payload(str, optional): Any data you want to attach to the invoice.allow_comments(bool, optional): Allow the user to add a comment to the payment. Defaults toTrue.allow_anonymous(bool, optional): Allow the user to pay the invoice anonymously. Defaults toTrue.expires_in(int, optional): Payment time limit for the invoice in seconds.
Example:
invoice = client.create_invoice(amount="100.00", asset="BTC", description="Test Invoice")
print(invoice)
delete_invoice
Deletes an invoice by ID.
Parameters:
invoice_id(int): The ID of the invoice.
Example:
result = client.delete_invoice(invoice_id=123456)
print(result)
create_check
Creates a new check.
Parameters:
asset(str): The cryptocurrency code.amount(str): The amount of the check.pin_to_user_id(int, optional): The ID of the user who will be able to activate the check.pin_to_username(str, optional): The username of the user who will be able to activate the check.
Example:
check = client.create_check(asset="BTC", amount="100.00")
print(check)
delete_check
Deletes a check by ID.
Parameters:
check_id(int): The ID of the check.
Example:
result = client.delete_check(check_id=123456)
print(result)
transfer
Sends coins from your app's balance to a user.
Parameters:
user_id(int): The ID of the user in Telegram.asset(str): The cryptocurrency code.amount(str): The amount of the transfer.spend_id(str): A unique UTF-8 string for idempotent requests.comment(str, optional): Comment for the transfer.disable_send_notification(bool, optional): PassTrueto not send a notification to the user about the transfer. Defaults toFalse.
Example:
transfer = client.transfer(user_id=123456789, asset="BTC", amount="50.00", spend_id="unique_id_123")
print(transfer)
get_invoices
Gets a list of invoices created by your app.
Parameters:
asset(str, optional): The cryptocurrency code.fiat(str, optional): The fiat currency code.invoice_ids(str, optional): List of invoice IDs separated by commas.status(str, optional): Status of invoices to be returned. Available statuses: "active", "paid". Defaults to all statuses.offset(int, optional): Offset for returning a specific subset of invoices. Defaults to0.count(int, optional): Number of invoices to be returned. Values between 1-1000. Defaults to100.
Example:
invoices = client.get_invoices()
print(invoices)
get_checks
Gets a list of checks created by your app.
Parameters:
asset(str, optional): The cryptocurrency code.check_ids(str, optional): List of check IDs separated by commas.status(str, optional): Status of checks to be returned. Available statuses: "active", "activated". Defaults to all statuses.offset(int, optional): Offset for returning a specific subset of checks. Defaults to0.count(int, optional): Number of checks to be returned. Values between 1-1000. Defaults to100.
Example:
checks = client.get_checks()
print(checks)
get_transfers
Gets a list of transfers created by your app.
Parameters:
asset(str, optional): The cryptocurrency code.transfer_ids(str, optional): List of transfer IDs separated by commas.offset(int, optional): Offset for returning a specific subset of transfers. Defaults to0.count(int, optional): Number of transfers to be returned. Values between 1-1000. Defaults to100.
Example:
transfers = client.get_transfers()
print(transfers)
get_balance
Gets the balances of your app.
Example:
balance = client.get_balance()
print(balance)
get_exchange_rates
Gets the exchange rates of supported currencies.
Example:
exchange_rates = client.get_exchange_rates()
print(exchange_rates)
get_currencies
Gets a list of supported currencies.
Example:
currencies = client.get_currencies()
print(currencies)
get_stats
Gets app statistics.
Parameters:
start_at(str, optional): The date from which to start calculating statistics in ISO 8601 format.end_at(str, optional): The date on which to finish calculating statistics in ISO 8601 format.
Example:
stats = client.get_stats(start_at="2023-01-01T00:00:00Z", end_at="2023-01-31T23:59:59Z")
print(stats)
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 cryptopayclient-0.1.tar.gz.
File metadata
- Download URL: cryptopayclient-0.1.tar.gz
- Upload date:
- Size: 5.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.11.0 pkginfo/1.11.1 requests/2.32.3 setuptools/71.0.3 requests-toolbelt/1.0.0 tqdm/4.66.4 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
10760c0e275480c6285ded02ffc97ece3dcd9cd8d6a3c39a99706bd1232bf079
|
|
| MD5 |
470dbf846c9326124af448976061bae2
|
|
| BLAKE2b-256 |
ff4a1f9d8514b93fe4a70594908522caa2d8a3e84576cbd06ff57c25bd50c73e
|
File details
Details for the file cryptopayclient-0.1-py3-none-any.whl.
File metadata
- Download URL: cryptopayclient-0.1-py3-none-any.whl
- Upload date:
- Size: 5.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.11.0 pkginfo/1.11.1 requests/2.32.3 setuptools/71.0.3 requests-toolbelt/1.0.0 tqdm/4.66.4 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
85f4cf931b03b86eb8bb89b0acffb8bcb3fd1149917e95cde63966da1dfe7c42
|
|
| MD5 |
7985d32707929981ac6a1bcccb68c322
|
|
| BLAKE2b-256 |
5267c50b32d4636b5b7628e1da6cab7940dc0a6e5473d2ce86b3aa7a2305f4e7
|