SDK for Onchainpay API
Project description
OnchainPay SDK
OnchainPay SDK is a comprehensive JavaScript library designed to streamline the integration of blockchain-based payment solutions into various applications. This SDK provides developers with the tools necessary to facilitate secure, transparent, and efficient transactions on supported blockchain networks.
Key Features:
- Ease of Integration: Simplifies the process of adding blockchain payment capabilities to your applications.
- Security: Ensures high-level security for all transactions using blockchain technology.
- Transparency: Leverages the transparency of blockchain networks to provide clear and verifiable transaction records.
- Multi-Network Support: Supports multiple blockchain networks, providing flexibility and scalability.
For detailed documentation, installation guides, and API references, please visit OnchainPay Documentation.
This package makes it easy OnChainPay Api.
Installation
pip install onchainpay-api
Use
Go to your personal account https://ocp.onchainpay.io/api-keys and get api-keys.
Substitute keys in class call:
from onchainpay_api import Client
client = Client("__PUBLIC_KEY__", "__PRIVATE_KEY__")
Check signature
You can test your signature within this method
checkSignature = client.basic_actions.check_x_api_signature
if not checkSignature["success"]:
print("Signature incorrect", checkSignature)
else:
if checkSignature["response"]["checkSignatureResult"]:
print("Signature correct")
else:
print("Signature incorrect:", checkSignature["response"]["errors"][0])
Fetch available currencies
Get list of available currencies for depositing/withdrawing
availableCurrencies = client.basic_actions.get_currencies()
if not availableCurrencies["success"]:
print("Request error", availableCurrencies)
else:
for currency in availableCurrencies["response"]:
print("%s (%s) = %s".format(currency["currency"], currency["alias"], currency["priceUSD"]))
if len(currency["networks"]) > 0:
print("\tnetworks:")
for network in currency["networks"]:
print("\t\t%s %s".format(network["name"], network["alias"]))
Get currencies price-rate
Get price rate from one currency to another
price = client.basic_actions.get_currency_price(fromCurrency="ETH", toCurrency="USDT")
if not price["success"]:
print("Request error", price)
else:
print("Price", price["response"])
Get advanced balances info
Get info about advanced balance by its id
balance = client.advanced_account.get_advanced_balance()
if not balance["success"]:
print("Request error", balance)
else:
print("[%s] (%s) \n\tAvailable for deposit: %s".format(balance["response"]["advancedBalanceId"], balance["response"]["currency"], ", ".join(balance["response"]["availableCurrenciesForDeposit"])))
Create order
from onchainpay_api import Client
def main():
order_link = create_order(currency="USDT", network="tron", amount="100")
#
def create_order(currency, network, amount):
client = Client("__PUBLIC_KEY__", "__PRIVATE_KEY__")
order = client.orders.create_order(
currency=currency,
network=network,
amount=amount,
order="Order #1234567",
errorWebhook="https://merchant.domain/webhook-url",
successWebhook="https://merchant.domain/webhook-url",
returnUrl="https://merchant.domain",
description="Buy some item",
)
if not order["success"]:
raise order["error"]["message"]
return order["response"]["link"]
Auto-swap to external address
from onchainpay_api import Client
def main():
auto_swap_id = make_withdrawal(currency="USDT", network="tron", address="TUfVHn...DDC", amount="100")
#
def make_withdrawal(currency, network, address, amount):
client = Client("__PUBLIC_KEY__", "__PRIVATE_KEY__")
swap = client.auto_swaps.create_swap(
address=address,
currency=currency,
network=network,
amountTo=amount,
webhook="https://merchant.domain/webhook-url",
)
if not swap["success"]:
raise swap["error"]["message"]
return swap["response"]["id"]
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
File details
Details for the file onchainpay_api-0.0.8-py3-none-any.whl
.
File metadata
- Download URL: onchainpay_api-0.0.8-py3-none-any.whl
- Upload date:
- Size: 31.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.9.19
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | df710388ce9b4d87a3947acb415b77c717327e88bc6a4e2eec98393b11a01bbb |
|
MD5 | c60343023fea2a6170fe0c3bd3a67cb7 |
|
BLAKE2b-256 | 190a2864dca4f03654f7a71f47f749da889db22256aaf4abdaab18dc3397f7a9 |