Skip to main content

algorand-x402-client

Query Algorand Indexer with the official py-algorand-sdk / AlgoKit client. This package does not add a new query API. It only changes where the HTTP goes, and whether that request can pay.

Backend Default origin Auth Data
.free Nodely / AlgoNode (AlgoKit getAlgoNodeConfig) none full archival Indexer v2
.paid https://api.algorand-indexer.xyz x402 USDC (exact / AVM) private full Indexer (genesis → tip)

You call the same methods as always (account_info(), search_transactions(), pagination helpers). Under the hood the official IndexerClient is pointed at one of two transports:

  1. .free — send the request to Nodely. No payment headers, no USDC.
  2. .paid — send the same path to the x402 gateway. If the gateway replies HTTP 402, the client signs a USDC payment (capped), retries once with a payment signature, and returns the Indexer JSON.

Both backends speak vanilla Indexer REST and retain history from genesis. They differ by billing and rate limits, not by how far back data goes. There is no silent “try Nodely, then pay” fallback — a free-tier 429 would otherwise spend USDC.

Install

Python 3.10+:

pip install algorand-x402-client
# or: uv add algorand-x402-client

Usage

import os

from algorand_x402_client import Payer, configure_logging, create_algorand_indexer, get_logger

configure_logging()  # stderr + algorand-x402-client.log
logger = get_logger(__name__)
indexer_client = create_algorand_indexer(
    "mainnet",
    payer=Payer(mnemonic=os.environ["BUYER_MNEMONIC"]),  # omit for free-only
)

# Nodely — never sends PAYMENT-SIGNATURE, never spends USDC
account = indexer_client.free.account_info("JRG3CUVOFK3YJK3QDD4IOWKMHHRCWVTEMUSYKDN7U73FQO5ZYTCC7CEBRQ")

# x402 gateway — HTTP 402 → sign USDC → retry (search tier is $0.0001)
paid = indexer_client.paid.account_info("JRG3CUVOFK3YJK3QDD4IOWKMHHRCWVTEMUSYKDN7U73FQO5ZYTCC7CEBRQ")

logger.info("gateway network=%s", indexer_client.gateway.health()["network"])
indexer_client.close()

indexer_client.free / indexer_client.paid are py-algorand-sdk IndexerClients. indexer_client.algorand_free is AlgorandClient.from_clients with Nodely algod

  • the free Indexer.

Payer must be opted into USDC: MainNet 31566704, TestNet 10458941. Default max payment is 10_000 microUSDC ($0.01).

Environment: BUYER_MNEMONIC, X402_BASE_URL, X402_NETWORK, ALGORAND_X402_LOG_FILE.

How the HTTP layer is swapped

py-algorand-sdk’s IndexerClient has no session hook, so this library subclasses it (SessionIndexerClient) and sends every call through a requests.Session.

  • Free session — plain requests, plus backoff on HTTP 429.
  • Paid session — the same session wrapped with x402-avm wrapRequestsWithPayment. The wrapper owns the 402 → sign → retry loop. Suggested params for the payment group come from Nodely algod, not from the Indexer.

You still get official response types. Only the transport is ours.

Docs

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

algorand_x402_client-0.1.1.tar.gz (12.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

algorand_x402_client-0.1.1-py3-none-any.whl (15.2 kB view details)

Uploaded Python 3

File details

Details for the file algorand_x402_client-0.1.1.tar.gz.

File metadata

  • Download URL: algorand_x402_client-0.1.1.tar.gz
  • Upload date:
  • Size: 12.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for algorand_x402_client-0.1.1.tar.gz
Algorithm Hash digest
SHA256 8e7f313524d8f112850a790f8ca4c565ee2e167e2a735365a7cb6203b3ec581b
MD5 7672b5bf5595fabc85f6d5afa06c3bbe
BLAKE2b-256 33d6fd9c746031cdb83cfa7f667681d25f60a2e6e0dce1f2159327aac996298d

See more details on using hashes here.

Provenance

The following attestation bundles were made for algorand_x402_client-0.1.1.tar.gz:

Publisher: release.yml on thecryptomie/algorand-x402-client

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file algorand_x402_client-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for algorand_x402_client-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 75b840e7541ae75414554476cd418fafb52c7bff79362d5d04fb8304f87169e8
MD5 941ea091428a54400900ca98c34fff7c
BLAKE2b-256 9a995f0471aa16fa430cc5cbf349e388164e10ba578036db1a085d62b771be6e

See more details on using hashes here.

Provenance

The following attestation bundles were made for algorand_x402_client-0.1.1-py3-none-any.whl:

Publisher: release.yml on thecryptomie/algorand-x402-client

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.2.0

2 files

This release

0.1.1 This release

2 files

0.1.0

2 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