Official Python SDK for OxaPay — accept crypto payments, exchanges, and payouts.
Project description
OxaPay Python SDK
Official Python SDK for OxaPay — accept crypto payments, exchanges, and payouts.
Python: 3.8+
Docs: https://docs.oxapay.com
Installation
pip install oxapay-python
Quick start
from oxapay_python import OxaPayManager
oxapay = OxaPayManager(timeout=10)
res = (
oxapay
.payment("XXXXXX-XXXXXX-XXXXXX-XXXXXX")
.generate_invoice({
"amount": 10.5,
"currency": "USDT",
})
)
print(res)
Handling Webhooks (Payments & Payouts)
OxaPay sends
HMACheader (sha512 over raw request body).
from oxapay_python import OxaPayManager
from oxapay_python.exceptions import WebhookSignatureException
raw_body = request.get_data(as_text=True) # Flask example
headers = dict(request.headers) # Flask example
oxapay = OxaPayManager()
# Merchant webhook
try:
data = oxapay.webhook(merchant_api_key="XXXXXX-XXXXXX-XXXXXX-XXXXXX", raw_body=raw_body, headers=headers).get_data()
except WebhookSignatureException:
pass
# Payout webhook
try:
data = oxapay.webhook(payout_api_key="XXXXXX-XXXXXX-XXXXXX-XXXXXX", raw_body=raw_body, headers=headers).get_data()
except WebhookSignatureException:
pass
# Both
try:
data = oxapay.webhook(
merchant_api_key="XXXXXX-XXXXXX-XXXXXX-XXXXXX",
payout_api_key="XXXXXX-XXXXXX-XXXXXX-XXXXXX",
raw_body=raw_body,
headers=headers,
).get_data()
except WebhookSignatureException:
pass
# Or skip verification
data = oxapay.webhook(raw_body=raw_body, headers=headers).get_data(verify=False)
Available methods
🔹payment
generate_invoice– Create invoice & get payment URL. More detailsgenerate_white_label– White-label payment. More detailsgenerate_static_address– Create static deposit address. More detailsrevoke_static_address– Revoke static address. More detailsstatic_address_list– List static addresses. More detailsinformation– Single payment information. More detailshistory– Payment history list. More detailsaccepted_currencies– Accepted currencies. More details
🔹account
balance– Account balance. More details
🔹payout
generate– Request payout. More detailsinformation– Single payout information. More detailshistory– Payout history list. More details
🔹exchange
swap_request– Swap request. More detailsswap_history– Swap history. More detailsswap_pairs– Swap pairs. More detailsswap_calculate– Swap pre-calc. More detailsswap_rate– Swap Quote rate. More details
🔹common
prices– Market prices. More detailscurrencies– Supported crypto. More detailsfiats– Supported fiats. More detailsnetworks– Supported networks. More detailsmonitor– System status. More details
🔹webhook
verify– ValidatesHMACheader (sha512 of raw body).get_data– ValidatesHMACheader and return webhook data. More details
Raw responses
By default, endpoints return the unwrapped data field.
To receive the full API response (data, status, message, error, version), enable raw mode:
from oxapay_python import OxaPayManager
sdk = OxaPayManager(timeout=20, raw=True)
res = sdk.payment("MERCHANT_API_KEY").generate_invoice({"amount": 1, "currency": "USDT"})
print(res["data"]) # unwrap manually
Exceptions
All SDK exceptions extend oxapay.exceptions.OxaPayException:
ValidationRequestException(HTTP 400)InvalidApiKeyException(HTTP 401)NotFoundException(HTTP 404)RateLimitException(HTTP 429)ServerErrorException(HTTP 500)ServiceUnavailableException(HTTP 503)HttpException(network/unknown)MissingApiKeyException(missing api key)MissingTrackIdException(missing track id)MissingAddressException(missing address)WebhookSignatureException(bad/missing HMAC)WebhookNotReceivedException(webhook request was not received)
Security Notes
- Verify webhook HMAC before use input data.
- Whitelist OxaPay IPs on your firewall (ask support).
- Use HTTPS everywhere.
- Store keys in
.env, not code. - Rotate keys regularly.
Testing (safe & offline)
This package uses pytest and responses for testing.
pip install -e ".[dev]"
pytest
Compatibility
- Python 3.8+
Security
If you discover a security vulnerability, please email contact@oxapay.com. Do not disclose publicly until it has been fixed.
Contributing
Pull requests are welcome. For major changes, open an issue first.
pip install -e ".[dev]"
ruff check .
pytest
License
Apache-2.0 — see LICENSE.
Changelog
See CHANGELOG.md for version history.
OxaPay Made with ♥ for Python.
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 oxapay_python-1.1.0.tar.gz.
File metadata
- Download URL: oxapay_python-1.1.0.tar.gz
- Upload date:
- Size: 43.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9ba99caca4b2c22629854e51a108193f4ad04c4f7aa68e4763660963ee021024
|
|
| MD5 |
8bac9053804559f452105d83682fd6c8
|
|
| BLAKE2b-256 |
fa9de12f1fd44a15d2d6ac23f388ac5728b8449140e1ee7b0e9d206ebcf8eb47
|
File details
Details for the file oxapay_python-1.1.0-py3-none-any.whl.
File metadata
- Download URL: oxapay_python-1.1.0-py3-none-any.whl
- Upload date:
- Size: 13.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ded534de57c4ebd48aa942fd890992f202a917e71d36ffc5d1857a23e5683ea6
|
|
| MD5 |
be71d2c8fd8352cf05a855f822141341
|
|
| BLAKE2b-256 |
9dd3314955171637dd1eb083266fa01a05a246d1196f216a53f723efd390bb7c
|