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.4.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.4-py3-none-any.whl (16.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ln_church_agent-0.8.4.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.4.tar.gz
Algorithm Hash digest
SHA256 596f542ca528d933807c0418c8bda4e893d376e81835591b54ba3ad72b3586e3
MD5 0b740012f5e3069a5d1a696ccba126cd
BLAKE2b-256 a04d565bba00484c825168287ff54dfc5419df6096e1dbc75c6f4e8d11e86160

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ln_church_agent-0.8.4-py3-none-any.whl
Algorithm Hash digest
SHA256 60367184cc912de004cc06c4fb8a99a4686b2746497b8b75032542b0a3627e96
MD5 a40cb24a0344d9ae4c81ab428ab982b7
BLAKE2b-256 e6e0ec128233ca48b8f3eca489b1f77b3c326464f1b08adb1fa837e58352373b

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