Skip to main content

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

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

License

MIT

Metadata

Release files for esimx402 0.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 esimx402 0.1.0
File Size Uploaded
esimx402-0.1.0.tar.gz 9.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for esimx402 0.1.0
File Interpreter ABI Platform
esimx402-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 16.0 kB

Release files / esimx402-0.1.0.tar.gz

Download URL esimx402-0.1.0.tar.gz
Size 9.5 kB
Tags Source
SHA-256 checksum
How to use checksums
17cc8f93e46778414b8e6bab69144c9991ffcd943ecc8673b9cd03e4678a4fb2
BLAKE2b-256 checksum
How to use checksums
e7d2a63e9d13a65f18e921cd7196afbd4cbeb4659feb6a77e9bdd164db4aced0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Release files / esimx402-0.1.0-py3-none-any.whl

Download URL esimx402-0.1.0-py3-none-any.whl
Size 6.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6cef805f4bf961bc263225352b03c6a104fe429ecb2803b2a5c36050f92aacb2
BLAKE2b-256 checksum
How to use checksums
2eb07cd11e3068d16edb2306bd0a765343cdea028fade80e723f74f059f636d2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Release history Release notifications | RSS feed

This release

0.1.0 This release

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