{
  "protocol": "L402",
  "payment": "Lightning",
  "paid": true,
  "live": true,
  "api": "https://api.agentpaywire.com/v1",
  "host": "api.agentpaywire.com",
  "price_sats": 100,
  "credits": 100,
  "ttl_days": 30,
  "unit": "One credit is one paid request.",
  "challenge": "HTTP 402 with WWW-Authenticate: L402 macaroon=\"<macaroon>\", invoice=\"<bolt11>\".",
  "authorization": "Authorization: L402 <macaroon>:<preimage>",
  "service_discovery": "https://api.agentpaywire.com/.well-known/l402",
  "services": "https://agentpaywire.com/.well-known/l402-services",
  "packs": [
    {
      "calls": 15,
      "sats": 120,
      "usd": "0.12",
      "days": 90,
      "break_even_singles": 12
    },
    {
      "calls": 100,
      "sats": 800,
      "usd": "0.80",
      "days": 90,
      "break_even_singles": 80
    },
    {
      "calls": 1000,
      "sats": 7000,
      "usd": "7.00",
      "days": 90,
      "break_even_singles": 700
    }
  ],
  "upgrade": {
    "method": "POST",
    "url": "https://api.agentpaywire.com/v1/credits",
    "note": "One x402 payment buys one call. Packs are bought with POST /v1/credits using x402 or L402."
  },
  "utility": {
    "credit_eighths": 8,
    "note": "A pack credit is 8 eighths. Catalog routes spend 8. Tools spend 1. Markdown spends 3. x402 and one-shot L402 use the listed price and do not use the 100-sat catalog bundle.",
    "tools": {
      "method": "POST",
      "sats": 1,
      "usd": "0.001",
      "eighths": 1,
      "paths": [
        "/v1/tools/hash",
        "/v1/tools/encode",
        "/v1/tools/decode",
        "/v1/tools/validate",
        "/v1/tools/convert",
        "/v1/tools/id",
        "/v1/tools/calc"
      ],
      "example": {
        "algorithm": "sha256",
        "text": "agentpaywire"
      }
    },
    "markdown": {
      "method": "POST",
      "path": "/v1/markdown",
      "sats": 3,
      "usd": "0.003",
      "eighths": 3,
      "example": {
        "url": "https://agentpaywire.com/llms.txt"
      }
    }
  },
  "openapi": "https://api.agentpaywire.com/v1/openapi.json",
  "health": "https://api.agentpaywire.com/v1/health",
  "free_data": "https://agentpaywire.com/api/index.json",
  "note": "Paid convenience API. L402 over Lightning. 100 sats buys 100 credits for 30 days. The files on https://agentpaywire.com stay free.",
  "rails": [
    {
      "protocol": "L402",
      "payment": "Lightning",
      "price_sats": 100,
      "credits": 100,
      "ttl_days": 30,
      "unit": "One credit is one paid request."
    },
    {
      "protocol": "x402",
      "price_usd": "0.01",
      "currency": "USDC",
      "network": "base",
      "credits": null,
      "unit": "One x402 payment buys one call. Packs are POST /v1/credits."
    }
  ],
  "examples": {
    "note": "Placeholders in angle brackets are not real credentials. <macaroon> is the base64 macaroon from the HTTP 402 challenge. <preimage> is the hex payment preimage. <bolt11> is the Lightning invoice in that challenge. The changes sample uses since=2026-10-01, an inclusive verified_at date. One purchase is 100 sats for 100 credits, valid 30 days. One credit is one paid call. The files on https://agentpaywire.com stay free.",
    "search": "https://api.agentpaywire.com/v1/search?q=bitcoin",
    "changes": "https://api.agentpaywire.com/v1/changes?since=2026-10-01&format=json",
    "authorization": "Authorization: L402 <macaroon>:<preimage>",
    "curl": "# Placeholders in angle brackets are not real credentials. <macaroon> is the base64 macaroon from the HTTP 402 challenge. <preimage> is the hex payment preimage. <bolt11> is the Lightning invoice in that challenge. The changes sample uses since=2026-10-01, an inclusive verified_at date. One purchase is 100 sats for 100 credits, valid 30 days. One credit is one paid call. The files on https://agentpaywire.com stay free.\n# 1. Request with no Authorization header.\ncurl -i 'https://api.agentpaywire.com/v1/search?q=bitcoin'\n# The 402 WWW-Authenticate header is: L402 macaroon=\"<macaroon>\", invoice=\"<bolt11>\"\n# 2. Pay <bolt11> on Lightning and keep the hex preimage.\n# 3. Retry the same URL.\ncurl -i 'https://api.agentpaywire.com/v1/search?q=bitcoin' \\\n  -H 'Authorization: L402 <macaroon>:<preimage>'\n# The same credential pays for changes. since is inclusive.\ncurl -i 'https://api.agentpaywire.com/v1/changes?since=2026-10-01&format=json' \\\n  -H 'Authorization: L402 <macaroon>:<preimage>'",
    "python": "import urllib.error\nimport urllib.request\n\n# Placeholders in angle brackets are not real credentials. <macaroon> is the base64 macaroon from the HTTP 402 challenge. <preimage> is the hex payment preimage. <bolt11> is the Lightning invoice in that challenge. The changes sample uses since=2026-10-01, an inclusive verified_at date. One purchase is 100 sats for 100 credits, valid 30 days. One credit is one paid call. The files on https://agentpaywire.com stay free.\nsearch = \"https://api.agentpaywire.com/v1/search?q=bitcoin\"\nchanges = \"https://api.agentpaywire.com/v1/changes?since=2026-10-01&format=json\"\n# 1. No Authorization header. HTTP 402 carries WWW-Authenticate.\ntry:\n    urllib.request.urlopen(search)\nexcept urllib.error.HTTPError as error:\n    print(error.status, error.headers.get(\"WWW-Authenticate\"))\n# 2. Pay <bolt11>. Then replace the placeholders and retry.\ncredential = \"L402 <macaroon>:<preimage>\"\npaid = urllib.request.Request(search, headers={\"Authorization\": credential})\nprint(urllib.request.urlopen(paid).read().decode())\ndigest = urllib.request.Request(changes, headers={\"Authorization\": credential})\nprint(urllib.request.urlopen(digest).read().decode())",
    "javascript": "// Placeholders in angle brackets are not real credentials. <macaroon> is the base64 macaroon from the HTTP 402 challenge. <preimage> is the hex payment preimage. <bolt11> is the Lightning invoice in that challenge. The changes sample uses since=2026-10-01, an inclusive verified_at date. One purchase is 100 sats for 100 credits, valid 30 days. One credit is one paid call. The files on https://agentpaywire.com stay free.\nconst search = \"https://api.agentpaywire.com/v1/search?q=bitcoin\";\nconst changes = \"https://api.agentpaywire.com/v1/changes?since=2026-10-01&format=json\";\n// 1. No Authorization header.\nconst challenge = await fetch(search);\n// challenge.status is 402. Read the WWW-Authenticate header, then pay <bolt11>.\nconst credential = \"L402 <macaroon>:<preimage>\";\nconst paid = await fetch(search, { headers: { Authorization: credential } });\nconst digest = await fetch(changes, { headers: { Authorization: credential } });\nconsole.log(paid.status, await paid.text());\nconsole.log(digest.status, await digest.text());",
    "x402": {
      "curl": "# x402 is the second rail. One payment is 0.01 USDC per call on Base. Packs are POST /v1/credits.\n# L402 is listed first on the same HTTP 402. Angle brackets are placeholders, not a signature or a key.\n# 1. Request with no payment header.\ncurl -i 'https://api.agentpaywire.com/v1/search?q=bitcoin'\n# HTTP/1.1 402\n# WWW-Authenticate: L402 macaroon=\"<macaroon>\", invoice=\"<bolt11>\"\n# PAYMENT-REQUIRED: <base64 PaymentRequired>\n# 2. Retry with PAYMENT-SIGNATURE. The header value is a base64 PaymentPayload.\ncurl -i 'https://api.agentpaywire.com/v1/search?q=bitcoin' \\\n  -H 'PAYMENT-SIGNATURE: <base64 PaymentPayload>'",
      "javascript": "// 0.01 USDC per call on Base. Packs are POST /v1/credits. Do not commit a private key.\nimport { wrapFetchWithPayment, x402Client } from '@x402/fetch';\nimport { registerExactEvmScheme } from '@x402/evm/exact/client';\nimport { privateKeyToAccount } from 'viem/accounts';\n\nconst client = new x402Client();\nregisterExactEvmScheme(client, { signer: privateKeyToAccount(process.env.X402_PRIVATE_KEY) });\nconst pay = wrapFetchWithPayment(fetch, client);\nconst response = await pay(\"https://api.agentpaywire.com/v1/search?q=bitcoin\");\nconsole.log(response.status, response.headers.get('PAYMENT-RESPONSE'));\nconsole.log(await response.text());"
    }
  }
}
