Production x402 protocol client for buying eSIM data — no account, on-chain payment in USDC/USDT (Polygon, TON).
Project description
esimx402
Python client for the eSIMx402 production x402 API.
Buy travel eSIM data with a single HTTP request — no account, no API key. Pay on-chain in USDC or USDT (Polygon or TON). Built for AI agents and autonomous workflows.
Install
pip install esimx402
Quickstart
from esimx402 import Client
with Client() as client:
# 1. Discover plans for a country
plans = client.list_plans(country="JP")
cheap = min(plans, key=lambda p: p.price_usd)
# 2. Request an order — server returns 402 with the on-chain invoice
invoice = client.create_order(plan_id=cheap.id)
print(f"Pay {invoice.amount} {invoice.asset} on {invoice.chain} → {invoice.pay_to}")
# 3. Pay it. Bring your own wallet — any sender of ERC-20 transfers works.
your_wallet.send(
to=invoice.pay_to,
amount=invoice.amount,
chain=invoice.chain,
asset=invoice.asset,
)
# 4. Wait for the eSIM (5-15 s typical, 30 s ceiling)
esim = client.wait_for_esim(invoice.order_id)
print(esim.qr_image_url)
Async variant: from esimx402 import AsyncClient — same surface, all methods awaitable.
Three full examples
- examples/01_buy_esim.py — basic happy path
- examples/02_agent_failover.py — autonomous failover when the primary uplink dies
- examples/03_iot_geofence.py — IoT device crossing borders, no ops console
Errors
| Exception | When |
|---|---|
APIError |
Server returned an unexpected HTTP status (contract violation or outage) |
PaymentExpired |
The 402 invoice expired before payment landed on-chain |
OrderFailed |
Server received payment but couldn't fulfill the order. Automatic on-chain refund within 5 min |
TimeoutError |
wait_for_esim() ceiling reached without the order reaching DELIVERED |
Links
- API docs: https://esimx402.com/docs
- Quickstart: https://esimx402.com/quickstart
- Pricing: https://esimx402.com/pricing
- Issues / questions: https://github.com/timav12/esimx402/issues
- Email:
dev@esimx402.com
License
MIT
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 esimx402-0.1.0.tar.gz.
File metadata
- Download URL: esimx402-0.1.0.tar.gz
- Upload date:
- Size: 9.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
17cc8f93e46778414b8e6bab69144c9991ffcd943ecc8673b9cd03e4678a4fb2
|
|
| MD5 |
ae546975acdb9d2fe9819dd85a25c23b
|
|
| BLAKE2b-256 |
e7d2a63e9d13a65f18e921cd7196afbd4cbeb4659feb6a77e9bdd164db4aced0
|
File details
Details for the file esimx402-0.1.0-py3-none-any.whl.
File metadata
- Download URL: esimx402-0.1.0-py3-none-any.whl
- Upload date:
- Size: 6.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6cef805f4bf961bc263225352b03c6a104fe429ecb2803b2a5c36050f92aacb2
|
|
| MD5 |
c454843f0187a2e93b08f6e6d311ff6e
|
|
| BLAKE2b-256 |
2eb07cd11e3068d16edb2306bd0a765343cdea028fade80e723f74f059f636d2
|