Skip to main content

# netthouse (Python)

Pay for HTTP resources with USDC — in three lines of code.

Python client for the [x402 payment protocol](https://www.x402.org). Handles the full payment loop automatically: discover paid resources → get HTTP 402 → sign an EIP-3009 authorization → retry with X-PAYMENT → consume.

No accounts. No API keys. No invoices. Just a wallet and a request.

## Install

pip install netthouse

## Quickstart

import os

from netthouse import X402Client



client = X402Client(private\_key=os.environ\["WALLET\_PRIVATE\_KEY"])



\# Any paid URL. The SDK pays automatically on HTTP 402.

result = client.fetch("https://netthouse-api.onrender.com/premium/data")



if result.response.ok:

    print(result.response.json())  # the paid resource

    print("paid:", result.paid)    # True

## Discover paid resources

Ask a server what it sells before paying:

for item in client.discover("https://netthouse-api.onrender.com"):

    req = item\["accepts"]\[0]

    price = int(req\["maxAmountRequired"]) / 1\_000\_000  # USDC has 6 decimals

    print(f"{item\['resource']} - {price} USDC on {req\['network']}")

\# /premium/data - 0.1 USDC on base-sepolia

\# /market-data - 0.05 USDC on base-sepolia

## API

### X402Client(private\_key, timeout=30)

| Field | Type | Description |

|---|---|---|

| private\_key | str | Private key of the payer wallet (USDC holder) |

| timeout | int | HTTP timeout in seconds |

### client.fetch(url, \*\*kwargs)

Performs a GET request. If the server responds **402 Payment Required**, the SDK:

1. reads payment requirements from the response,

2. selects a USDC requirement for Base networks,

3. signs an EIP-3009 transferWithAuthorization off-chain,

4. retries the request with the X-PAYMENT header.

Returns a PaymentResult(response, paid, payment\_header).

### client.discover(base\_url)

Fetches GET {base\_url}/discover and returns the list of catalog items per the x402 discovery spec.

### client.address

The payer wallet address (0x...).

## How x402 works


agent                     server                    facilitator

  |  GET /resource           |                            |

  |------------------------->|                            |

  |      402 + requirements  |                            |

&#x20; |<-------------------------|                            |

&#x20; |  sign EIP-3009 (off-chain)                            |

&#x20; |  GET /resource + X-PAYMENT                            |

&#x20; |------------------------->|  verify + settle           |

&#x20; |                          |--------------------------->|

&#x20; |                          |     on-chain USDC transfer |

&#x20; |        200 + resource    |                            |

&#x20; |<-------------------------|                            |

- **Scheme:** exact (fixed price per request)

- **Asset:** USDC on Base (mainnet) / Base Sepolia (testnet)

- **Gas:** paid by the facilitator — the seller receives USDC gasless

## Networks

| Network | Chain ID | USDC |

|---|---|---|

| Base (mainnet) | 8453 | 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913 |

| Base Sepolia | 84532 | 0x036CbD53842c5426634e7929541eC2318f3dCF7e |

## Security

- Never commit private keys. Use environment variables or a secret manager.

- The payer wallet only signs transfer authorizations for the exact amounts it chooses to pay.

- Verify txHash from server responses on [basescan.org](https://basescan.org) if you need independent proof of payment.

## TypeScript SDK

Prefer Node.js? See [@netthouse/sdk](https://www.npmjs.com/package/@netthouse/sdk).

## License

MIT © 2026 Netthouse

Metadata

Release files for netthouse 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 netthouse 0.1.0
File Size Uploaded Provenance Actions
netthouse-0.1.0.tar.gz 6.0 kB Without provenance Details for netthouse-0.1.0.tar.gz

Built distribution (wheel)

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

Total release size: 13.0 kB

Release files / netthouse-0.1.0.tar.gz

Download URL netthouse-0.1.0.tar.gz
Size 6.0 kB
Tags Source
SHA-256 checksum
How to use checksums
b2a39c94703a7430638feb97eec36092e7b4958f46172ab34a46d8cf5dad1136
BLAKE2b-256 checksum
How to use checksums
6c9436b4aa18d5a7e0d6afd3da5b90b622441a8819d293bc402afacf6f0e4f56
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.7

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

Download URL netthouse-0.1.0-py3-none-any.whl
Size 7.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bb862660b59e90b3266864752873459371d7b37db65a25482cb791dada660e75
BLAKE2b-256 checksum
How to use checksums
583d8888624aad1bc33c3b3e6f84a5850568f434af2b880a60500b09855ded77
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.7

Security for netthouse 0.1.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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A 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.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

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