Skip to main content

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 HMAC header (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 details
  • generate_white_label – White-label payment. More details
  • generate_static_address – Create static deposit address. More details
  • revoke_static_address – Revoke static address. More details
  • static_address_list – List static addresses. More details
  • information – Single payment information. More details
  • history – Payment history list. More details
  • accepted_currencies – Accepted currencies. More details

🔹account

🔹payout

🔹exchange

🔹common

🔹webhook

  • verify – Validates HMAC header (sha512 of raw body).
  • get_data – Validates HMAC header 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.

Metadata

Release files for oxapay-python 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for oxapay-python 1.1.0
File Size Uploaded
oxapay_python-1.1.0.tar.gz 43.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for oxapay-python 1.1.0
File Interpreter ABI Platform
oxapay_python-1.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 57.0 kB

Release files / oxapay_python-1.1.0.tar.gz

Download URL oxapay_python-1.1.0.tar.gz
Size 43.4 kB
Tags Source
SHA-256 checksum
How to use checksums
9ba99caca4b2c22629854e51a108193f4ad04c4f7aa68e4763660963ee021024
BLAKE2b-256 checksum
How to use checksums
fa9de12f1fd44a15d2d6ac23f388ac5728b8449140e1ee7b0e9d206ebcf8eb47
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.0

Release files / oxapay_python-1.1.0-py3-none-any.whl

Download URL oxapay_python-1.1.0-py3-none-any.whl
Size 13.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ded534de57c4ebd48aa942fd890992f202a917e71d36ffc5d1857a23e5683ea6
BLAKE2b-256 checksum
How to use checksums
9dd3314955171637dd1eb083266fa01a05a246d1196f216a53f723efd390bb7c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.0

Release history Release notifications | RSS feed

This release

1.1.0 This release

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page