Skip to main content

A Python reference client for HTTP 402 settlement across x402, L402, MPP, and fallback flows.

Project description

ln-church-agent

Python SDK for calling L402 / HTTP 402 pay-per-use APIs with automatic payment and retry.


Quickstart (3-step)

1. Install

pip install ln-church-agent

2. Configure & Call

Call any 402-protected API. The SDK handles the 402 challenge, payment, and retry under the hood.

from ln_church_agent import Payment402Client

client = Payment402Client(
    base_url="https://your-402-api.com",
)

# Detects 402 -> Pays invoice -> Retries -> Returns JSON
result = client.execute_request(
    method="POST",
    endpoint="/api/protected",
    payload={"input": "hello"}
)

print(result)

What happens under the hood?

This SDK abstracts the "Payment-Retry Loop" so your agent doesn't have to:

  • Detects 402 Payment Required.
  • Negotiates the challenge (L402, MPP, or x402 support).
  • Pays the invoice via your configured Lightning or EVM provider.
  • Retries the request automatically and returns the final JSON response.

Why use this SDK?

  • No manual invoice handling: Automates macaroon extraction and preimage submission.
  • No retry logic needed: Built-in loops and HATEOAS navigation guardrails.
  • Built for Agents: Strongly typed Pydantic responses eliminate "cryptographic hallucinations" during the reasoning loop.

Detailed Documentation

Explore the full capabilities of the agentic economic loop:


License

MIT


Project details


Download files

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

Source Distribution

ln_church_agent-0.8.3.tar.gz (19.7 kB view details)

Uploaded Source

Built Distribution

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

ln_church_agent-0.8.3-py3-none-any.whl (16.6 kB view details)

Uploaded Python 3

File details

Details for the file ln_church_agent-0.8.3.tar.gz.

File metadata

  • Download URL: ln_church_agent-0.8.3.tar.gz
  • Upload date:
  • Size: 19.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.5

File hashes

Hashes for ln_church_agent-0.8.3.tar.gz
Algorithm Hash digest
SHA256 a0e444300f85ffd5da971d9e951ba1046bddba4238c30f6003048ced0b6792c1
MD5 fa9f774138057b4b42f037d265dd2219
BLAKE2b-256 8d4256745f6238c7b52e13dbee6b837a1055b451a5cd71739223e442201e1019

See more details on using hashes here.

File details

Details for the file ln_church_agent-0.8.3-py3-none-any.whl.

File metadata

File hashes

Hashes for ln_church_agent-0.8.3-py3-none-any.whl
Algorithm Hash digest
SHA256 2239fa822f4df071193e2fae45c93823ddae29d7f20ee00d1b38065074d65e51
MD5 9078a9e12dc27e2c5b32953c43255de1
BLAKE2b-256 bc7b7c0deaa718ee645667e0080fabba08fa85be3f78d70747196f94b6c21f09

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page