Stablevoy Python SDK
Python client for Stablevoy, the non-custodial gateway for USDT and USDC payments. Customers pay on chain and the money goes straight to your own wallet: USDC and USDT on Base, Arbitrum, Optimism, Avalanche, Polygon and BNB Chain, and USDT (TRC20) on Tron with no fee.
The library creates invoices, reads them, and verifies the signed webhooks that tell your shop an order is paid. It has no dependencies, needs Python 3.11 or newer and is fully typed.
Install
pip install stablevoy
Create an invoice and send the buyer to pay
Create an API key for your store in the Stablevoy dashboard.
import os
from stablevoy import Stablevoy
stablevoy = Stablevoy.create(os.environ["STABLEVOY_API_KEY"])
created = stablevoy.invoices.create(
2599, # $25.99 in US cents
external_reference="order-1042", # your order id, sent back in webhooks
return_url="https://shop.example/orders/1042",
idempotency_key="order-1042", # a retry returns the same invoice, never a second one
)
# Send the buyer to created.checkout_url
Read an invoice with stablevoy.invoices.get(invoice_id), or walk them all:
for invoice in stablevoy.invoices.all(status="paid"):
print(invoice.external_reference, invoice.amount_usd_cents)
Narrow the list by source, created days (UTC, both ends included) or a search by invoice id or the start of your order reference. Each invoice says where it came from:
from stablevoy import InvoiceSource
for invoice in stablevoy.invoices.all(source=InvoiceSource.PAYMENT_LINK, created_from="2026-11-01", created_to="2026-11-30"):
print(invoice.id, invoice.source.kind if invoice.source else None)
Check the store before going live
Invoices need a payout wallet for at least one network the store accepts; without one every invoice is refused with payout_address_not_set. Read the store of the key to find out in advance, and tell the merchant about networks buyers will not be offered:
store = stablevoy.stores.current()
if not store.can_accept_payments():
... # Hide the payment method: set the payout address in the Stablevoy dashboard first.
if store.networks_without_payout:
... # These enabled networks have no payout wallet, so buyers do not see them.
Connect a shop in one click
A shop integration can get its API key and webhook secret without the merchant copying them: it sends the merchant to the Stablevoy dashboard with a PKCE challenge, gets a code back on its callback URL and redeems it. This call needs no API key, since the shop has none yet. The code works once, so the call is never retried.
from stablevoy import StablevoyConnect
connected = StablevoyConnect.create().exchange(code=code, code_verifier=code_verifier, site="https://shop.example.com")
# Store connected.api_key and connected.webhook_secret; connected.store_name is the store the merchant chose.
When the merchant disconnects the shop, give the key up so it stops working at once. A key that is already revoked raises AuthenticationError, which for a disconnect means the same:
stablevoy.stores.revoke_current_key()
Verify webhooks
Stablevoy posts an event to your webhook URL when an invoice is paid, overpaid, underpaid, expired, paid late or put on hold. One more, invoice.payment_flagged, comes when a later transfer to an invoice that is already paid is flagged by sanctions screening: the invoice keeps its paid status, so this event is not a new payment; the flagged transfer is in event.data["payment"]. Check the signature before you trust it, using the signing secret shown when you set the webhook in the dashboard. Pass the raw body, exactly as received.
Flask:
from flask import Flask, request
from stablevoy import SignatureError, WebhookVerifier
verifier = WebhookVerifier(os.environ["STABLEVOY_WEBHOOK_SECRET"])
app = Flask(__name__)
@app.post("/stablevoy/webhook")
def stablevoy_webhook():
try:
event = verifier.verify(request.get_data(), request.headers.get("X-Stablevoy-Signature"))
except SignatureError:
return "", 400
if event.invoice is not None and event.invoice.is_paid():
... # mark the order event.invoice.external_reference as paid; use event.id to handle each event once
return "", 200
Django: verifier.verify(request.body, request.headers.get("X-Stablevoy-Signature")). FastAPI: verifier.verify(await request.body(), request.headers.get("X-Stablevoy-Signature")).
Errors and retries
Every error extends StablevoyError. API errors are ApiError with the HTTP status, a stable code, a readable detail and a link to the error catalog; the ones you may want to handle on their own are AuthenticationError, ValidationError (with issues), NotFoundError, RateLimitedError and MaintenanceError. TransportError means no answer at all.
Reads, and creates that carry an idempotency key, are retried on rate limits, maintenance, gateway errors while the API restarts (502, 504, 520 to 524) and failed connections, at most twice and only for waits of up to 10 seconds. Anything longer reaches you with retry_after_seconds, so a request never hangs. Every request times out after 30 seconds.
from stablevoy import RetryPolicy, Stablevoy
stablevoy = Stablevoy.create(api_key, retries=RetryPolicy(max_retries=3, max_wait_seconds=30), timeout_seconds=10)
Links
License
MIT
Metadata
Release files for stablevoy 1.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| stablevoy-1.3.0.tar.gz | 21.6 kB | With provenance | Details for stablevoy-1.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| stablevoy-1.3.0-py3-none-any.whl | Python 3 | none | any | Details for stablevoy-1.3.0-py3-none-any.whl |
Total release size: 59.3 kB
Release files / stablevoy-1.3.0.tar.gz
| Download URL | stablevoy-1.3.0.tar.gz |
|---|---|
| Size | 21.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
71021e0881fc936a1b8da6b791246b62edb52cf88bddf004a73e44b1eae76b8e
|
|
BLAKE2b-256 checksum How to use checksums |
b0d643fec3a746541f3bcc4172b73fc006b2541341d59ed970b5e6c4aa7a8f0c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 3, 2026.
Transparency logRelease files / stablevoy-1.3.0-py3-none-any.whl
| Download URL | stablevoy-1.3.0-py3-none-any.whl |
|---|---|
| Size | 37.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
931b084e629864450c58ced23c124498bd63ddf9e2400f18bfd3df3a08d804a1
|
|
BLAKE2b-256 checksum How to use checksums |
a8ad6ba4feeffdf3d775c5244b43f023fae116b8dd8c1b6eb69aae04aef9244c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 3, 2026.
Transparency logSecurity for stablevoy 1.3.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for stablevoy-1.3.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 3, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.