ຂ້າມໄປຫາເນື້ອຫາ
ດາວນ໌ໂຫລດ Nymbot

ພື້ນຖານຄວາມຮູ້ ການພັດທະນາ

Balance, Top-ups ແລະ Key

Check what you have, top up over Lightning, top up automatically ຈາກ wallet ຂອງທ່ານເອງ, ດາວນ໌ໂຫລດຄ່າໃຊ້ຈ່າຍຂອງລັກສະນະໃດໆ, ແລະການຄຸ້ມຄອງຊອກຫາຈາກລະຫັດ.

ການທົບທວນຄືນ Balance

ທັງຫມົດຂອງ balances ຂອງທ່ານ, ແລະຂະຫນາດໃຫຍ່ຂອງ cap ຂອງ key ນີ້ຖືກນໍາໃຊ້.

GET https://nymbot.ai/api/v1/credits/balance ການນໍາໃຊ້ API Key POST ການເຮັດວຽກສໍາລັບລູກຄ້າທີ່ຄາດວ່າຈະໄດ້.

balance ໄດ້ຮັບການຮັບປະກັນການຮັບປະກັນການຮັບປະກັນການຮັບປະກັນການຮັບປະກັນການຮັບປະກັນການຮັບປະກັນການຮັບປະກັນ (null ຖ້າຫາກວ່າຄ່າໃຊ້ຈ່າຍທີ່ບໍ່ສາມາດຖືກອ່ານ). ຂ້າງລຸ່ມນີ້ແມ່ນໃນ Credits ແລະ sats, ທີ່ແມ່ນວິທີການທີ່ສະດວກສະບາຍຂອງການເກັບຮັກສາ. key ຄຸນນະສົມບັດທີ່ຄົ້ນຄວ້າທີ່ໄດ້ຮັບ. ຄຸນນະສົມບັດທີ່ໄດ້ຮັບການບັນລຸ cap ຂອງຕົນສາມາດຄົ້ນຄວ້າບັນລຸ.

ຄໍາຖາມ

{
  "balance": 49.18,
  "balance_sats": 42037,
  "standard": { "credits": 120.4, "sats": 1204 },
  "pro": { "credits": 408.33, "sats": 40833 },
  "key": {
    "id": "4f0c9a1be27d3856",
    "name": "laptop scripts",
    "limit_sats": 20000,
    "period_used_sats": 3412,
    "total_used_sats": 18230,
    "reset_period": "monthly",
    "reset_at": "2026-10-01T00:00:00Z"
  }
}
ລະຫັດ QRໃນເວລາທີ່
401Key ແມ່ນ missing, unknown, revoked ຫຼືຜ່ານມາ.

cURL

curl https://nymbot.ai/api/v1/credits/balance \
  -H "Authorization: Bearer $NYMBOT_API_KEY"

Python

import os
import requests

res = requests.get(
    "https://nymbot.ai/api/v1/credits/balance",
    headers={"Authorization": "Bearer " + os.environ["NYMBOT_API_KEY"]},
)
balance = res.json()
print(balance["standard"]["sats"], balance["pro"]["sats"])

JavaScript

const res = await fetch("https://nymbot.ai/api/v1/credits/balance", {
  headers: { "Authorization": "Bearer " + process.env.NYMBOT_API_KEY },
});
const balance = await res.json();
console.log(balance.standard.sats, balance.pro.sats);

ລະຫັດ QR

ວິທີການທີ່ທ່ານສາມາດ top up, ແລະ limits. Lightning ເປັນວິທີຫນຶ່ງ.

GET https://nymbot.ai/api/v1/topup/payment-methods ບໍ່ຈໍາເປັນຕ້ອງ key.

Top-up ແມ່ນ 10 ເຖິງ 1,000,000 sats; Pro top-up ຕ້ອງການຊື້ຫຼືຫນຶ່ງ Pro credit, ດັ່ງນັ້ນມັນເລີ່ມຕົ້ນໃນ 100 sats. bulk_bonus ສະຫນັບສະຫນູນການເຊື່ອມຕໍ່ເພີ່ມເຕີມກ່ຽວກັບການ top-ups ຂະຫນາດໃຫຍ່, ເຊັ່ນດຽວກັນກັບໃນ app: 10%, 15% ຫຼື 20% ຫຼາຍກ່ຽວກັບການ top-ups standard ຈາກ 500, 1,000 ຫຼື 5,000 sats, ແລະກ່ຽວກັບການ top-ups Pro ຈາກ 5,000, 10,000 ຫຼື 50,000 sats.

ຄໍາຖາມ

{
  "supported_methods": [
    {
      "method": "btc-lightning",
      "display_name": "Bitcoin Lightning",
      "supported_currencies": ["SATS", "USD", "BTC"],
      "limits": {
        "SATS": { "min": 10, "max": 1000000 },
        "USD": { "min": 0.02, "max": 1170 },
        "BTC": { "min": 1e-7, "max": 0.01 }
      },
      "tiers": ["standard", "pro"],
      "default_tier": "pro",
      "tier_min_sats": { "standard": 10, "pro": 100 },
      "sats_per_credit": { "standard": 10, "pro": 100 },
      "bulk_bonus": [
        { "bonus": 0.1, "standard_sats": 500, "pro_sats": 5000 },
        { "bonus": 0.15, "standard_sats": 1000, "pro_sats": 10000 },
        { "bonus": 0.2, "standard_sats": 5000, "pro_sats": 50000 }
      ]
    }
  ]
}

cURL

curl https://nymbot.ai/api/v1/topup/payment-methods

Python

import requests

methods = requests.get("https://nymbot.ai/api/v1/topup/payment-methods").json()
print(methods["supported_methods"][0]["limits"])

JavaScript

const methods = await (await fetch("https://nymbot.ai/api/v1/topup/payment-methods")).json();
console.log(methods.supported_methods[0].limits);

ປະເພດ Top Up Over Lightning

ເຮັດໃຫ້ບັນຊີ Lightning ທີ່ເພີ່ມການຄາດຄະເນດິນກັບ nym ທີ່ key belongs ກັບ. Pay it from any Lightning wallet, then ການທົບທວນຄືນ ການເຊື່ອມຕໍ່ການເຊື່ອມຕໍ່

POST https://nymbot.ai/api/v1/topup/create/btc-lightning ການນໍາໃຊ້ API Key

ປະເພດ Fieldປະເພດປະເພດດາວໂຫລດ
amountລະຫັດ QRແມ່ນແລ້ວຂະຫນາດນ້ອຍ, ໃນ currencyຈໍານວນທັງຫມົດສໍາລັບ sats.
currencyລະຫັດ QRບໍ່SATS (ການດໍາເນີນການຂອງ Default) USD ປະເພດ BTCDollars ໄດ້ຖືກປ່ຽນແປງກັບຄ່າໃຊ້ຈ່າຍ Bitcoin ໃນປັດຈຸບັນ.
tierລະຫັດ QRບໍ່pro (ການດໍາເນີນການ) ຫຼື standardປະເພດ : ການຄາດຄະເນດິນດີຕ້ອນຮັບ

ການຄາດຄະເນດິນດີຕ້ອນຮັບແມ່ນ 10 sats ແລະການຄາດຄະເນດິນດີຕ້ອນຮັບແມ່ນ 100 sats, plus any bulk bonus; credits ຊື່ຫຍໍ້ຂອງ :

ຄໍາຖາມ

{
  "invoice_id": "b7d41e0c95a2f38e6c1d0e9a4b7f2c61d3e8a05f9b2c4d7e1a6f3b8c0d5e2a9f4",
  "payment_request": "lnbc100u1p5...",
  "amount_sats": 10000,
  "credits": 115,
  "tier": "pro",
  "expires_at": "2026-09-30T09:27:00Z",
  "status": "pending"
}
ລະຫັດ QRໃນເວລາທີ່
400ວິທີການອື່ນໆໃນປັດຈຸບັນ (unsupported_method), ຄ່າໃຊ້ຈ່າຍທີ່ບໍ່ຮູ້ຈັກ (unsupported_currency) ຫຼື tier, ປະລິມານທີ່ບໍ່ມີຫຼືຂະຫນາດນ້ອຍກວ່າ (amount_too_small), ຫຼາຍກ່ວາ 1 000 000 sats (amount_too_large) ຫຼືຕອບສະຫນອງໂດຍ wallet Lightning (amount_out_of_range).
429ຫຼາຍກ່ວາ 60 ບັນທຶກສໍາລັບ nym ນີ້, ຫຼື 120 ຈາກທີ່ຢູ່ນີ້, ໃນ 1 ຊົ່ວໂມງ (rate_limit_exceededຂ້າ ພະ ເຈົ້າ Retry-After).
502ໃນປັດຈຸບັນບໍ່ສາມາດໄດ້ຮັບອະນຸຍາດ (invoice_unavailableຂ້າ ພະ ເຈົ້າ Retry-After).

cURL

curl https://nymbot.ai/api/v1/topup/create/btc-lightning \
  -H "Authorization: Bearer $NYMBOT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"amount": 10000, "currency": "SATS", "tier": "pro"}'

Python

import os
import requests

res = requests.post(
    "https://nymbot.ai/api/v1/topup/create/btc-lightning",
    headers={"Authorization": "Bearer " + os.environ["NYMBOT_API_KEY"]},
    json={"amount": 10000, "currency": "SATS", "tier": "pro"},
)
invoice = res.json()
print(invoice["payment_request"])

JavaScript

const res = await fetch("https://nymbot.ai/api/v1/topup/create/btc-lightning", {
  method: "POST",
  headers: {
    "Authorization": "Bearer " + process.env.NYMBOT_API_KEY,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({ amount: 10000, currency: "SATS", tier: "pro" }),
});
const invoice = await res.json();
console.log(invoice.payment_request);

ການທົບທວນຄືນ Top-up

ຊື່ຫຍໍ້ຂອງ : ຊື່ຫຍໍ້ຂອງ : ເຢຍລະມັນ : ເຢຍລະມັນ creditedການຄວບຄຸມຕໍ່ໄປນີ້ແມ່ນປອດໄພ: ການຄາດຄະເນດິນດີຕ້ອນຮັບຫນຶ່ງ, ບໍ່ວ່າຈະຫຼາຍກ່ວາທ່ານຕ້ອງການ.

GET https://nymbot.ai/api/v1/topup/status/{invoice_id} — ຕ້ອງ key ຈາກ nym ທີ່ສ້າງບັນຊີ.

status ປະເພດ pending (ບໍ່ມີຄ່າໃຊ້ຈ່າຍໃນປັດຈຸບັນ) paid (ການຊໍາລະເງິນ, ແຕ່ບໍ່ໄດ້ຮັບການອະນຸຍາດ; ດາວນ໌ໂຫລດอีกครั้ง), credited (ໃນປັດຈຸບັນ) ຫຼື expired (ບໍ່ໄດ້ຮັບການຊໍາລະເງິນໃນເວລາທີ່ໃຊ້ເວລາ). fields balance are for the tier the invoice tops up.

ຄໍາຖາມ

{
  "invoice_id": "b7d41e0c95a2f38e6c1d0e9a4b7f2c61d3e8a05f9b2c4d7e1a6f3b8c0d5e2a9f4",
  "status": "credited",
  "amount_sats": 10000,
  "credits": 115,
  "tier": "pro",
  "expires_at": null,
  "balance_credits": 523.33,
  "balance_sats": 52333
}
ລະຫັດ QRໃນເວລາທີ່
400ID ແມ່ນບໍ່ແມ່ນ 64-character id ຈາກການຄົ້ນຄວ້າການສ້າງ.
404ຂໍຂອບໃຈຫຼາຍດັ່ງນັ້ນສໍາລັບການ NIMM ຂອງທ່ານinvoice_not_found).

cURL

curl https://nymbot.ai/api/v1/topup/status/$INVOICE_ID \
  -H "Authorization: Bearer $NYMBOT_API_KEY"

Python

import os, time
import requests

headers = {"Authorization": "Bearer " + os.environ["NYMBOT_API_KEY"]}
url = "https://nymbot.ai/api/v1/topup/status/" + invoice["invoice_id"]

while True:
    status = requests.get(url, headers=headers).json()["status"]
    if status in ("credited", "expired"):
        break
    time.sleep(3)
print(status)

JavaScript

const headers = { "Authorization": "Bearer " + process.env.NYMBOT_API_KEY };
const url = "https://nymbot.ai/api/v1/topup/status/" + invoice.invoice_id;

let status;
do {
  await new Promise((r) => setTimeout(r, 3000));
  status = (await (await fetch(url, { headers })).json()).status;
} while (status !== "credited" && status !== "expired");
console.log(status);

ຫນ້າທໍາອິດ / Query History

One line per request: ມັນເປັນສິ່ງທີ່, ໂມເລກຸນໃດ, ຫຼາຍກວ່ານັ້ນແລະຄ່າໃຊ້ຈ່າຍໃດໆ. ບໍ່ມີຄໍາແນະນໍາຫຼືການຕອບສະຫນອງ, ດັ່ງນັ້ນບໍ່ໄດ້ຮັບການຕອບສະຫນອງ. Rows ຈະໄດ້ຮັບການຕອບສະຫນອງສໍາລັບ 90 ມື້, ທີ່ທັນສະໄຫມຄັ້ງທໍາອິດ. A key that has reached its cap can still read its history.

GET https://nymbot.ai/api/v1/queries/history — needs API key, ເຊິ່ງເບິ່ງການຢັ້ງຢືນຂອງຕົນເອງ, ຫຼື ຄໍາຮ້ອງສະຫມັກ ຈາກ nym ຂອງທ່ານ, ເຊິ່ງຊອກຫາແຕ່ລະ key ຂອງທ່ານ.

ປະເພດ Fieldປະເພດປະເພດດາວໂຫລດ
pageລະຫັດ QRບໍ່ດາວນ໌ໂຫລດ Top10Site 400 invalid_value.
page_countລະຫັດ QRບໍ່Rows per page. Default 20, ທີ່ສູງສຸດ 100
start_date
end_date
ລະຫັດ QRບໍ່ລະບົບ ISO 8601 Date or Time
modelລະຫັດ QRບໍ່ລະຫັດ QR
typeລະຫັດ QRບໍ່chat, responses, messages, image, video, speech, transcription ປະເພດ embedding.
all_keysຊື່ຫຍໍ້ຂອງ : Boolean (query)ບໍ່ທີ່ຢູ່ Key: true ລວມທັງແຕ່ລະ Key ຂອງ nym ນີ້. Default false.
key_idລະຫັດ QRບໍ່ໂດຍການຢັ້ງຢືນການຢັ້ງຢືນ, ຫຼື all_keys=true: ພຽງແຕ່ Key ນີ້

ຄໍາຖາມ

{
  "data": [
    {
      "id": "q_71c4e9a0",
      "timestamp": "2026-09-30T08:12:00Z",
      "model": "anthropic/claude-sonnet-5",
      "type": "chat",
      "input_tokens": 1240,
      "output_tokens": 380,
      "cached_tokens": 0,
      "cost_sats": 16.2,
      "cost_usd": 0.01895,
      "balance": "pro",
      "key_id": "4f0c9a1be27d3856",
      "web_search": false,
      "status": "ok"
    }
  ],
  "pagination": { "page": 1, "page_count": 20, "total": 311, "total_pages": 16 }
}

cURL

curl "https://nymbot.ai/api/v1/queries/history?page_count=50&type=chat" \
  -H "Authorization: Bearer $NYMBOT_API_KEY"

Python

import os
import requests

res = requests.get(
    "https://nymbot.ai/api/v1/queries/history",
    headers={"Authorization": "Bearer " + os.environ["NYMBOT_API_KEY"]},
    params={"page_count": 50, "type": "chat"},
)
for row in res.json()["data"]:
    print(row["timestamp"], row["model"], row["cost_sats"])

JavaScript

const res = await fetch("https://nymbot.ai/api/v1/queries/history?page_count=50&type=chat", {
  headers: { "Authorization": "Bearer " + process.env.NYMBOT_API_KEY },
});
for (const row of (await res.json()).data) console.log(row.timestamp, row.model, row.cost_sats);

ຊື່ຫຍໍ້ຂອງ : Sign Account Requests

ການສ້າງ, ການປ່ຽນແປງແລະການຕັດສິນໃຈ Key, ບັນຊີລາຍລະອຽດແລະ Top-ups ອັດຕະໂນມັດບໍ່ມີ API Key. ພວກເຂົາເຈົ້າໄດ້ຮັບການລົງທະບຽນຈາກ nym ຂອງທ່ານ, ດັ່ງນັ້ນ key leaked ສາມາດໃຊ້ເວລາເຖິງ cap ຂອງຕົນ, ແຕ່ບໍ່ສາມາດສ້າງ key ທີ່ແຕກຕ່າງກັນຫຼືເພີ່ມ cap ຂອງຕົນເອງ.

ຄໍາຮ້ອງສະຫມັກເຮັດສິ່ງນີ້ສໍາລັບທ່ານ: ທັງຫມົດໃນ ພາສາລາວ Sheet ນໍາ ໃຊ້ endpoints ນີ້. You only need this section to manage keys from your own code.

ການຢັ້ງຢືນແມ່ນບັນຫາ Nostr ຂອງປະເພດ 27235 (NIP-98), ສະຫນອງ base64-coded ໃນປັດຈຸບັນ Authorization Header ກັບ Word Nostr ທີ່ຜ່ານມາ:

ປະເພດ

{
  "kind": 27235,
  "created_at": 1790726400,
  "tags": [
    ["u", "https://nymbot.ai/api/v1/keys"],
    ["method", "POST"],
    ["nonce", "9c4e21f07a3b...16 random bytes in hex"],
    ["payload", "3f1a0d7c8e2b...sha256 of the exact request body in hex"]
  ],
  "content": "",
  "pubkey": "your public key in hex",
  "id": "...",
  "sig": "..."
}
  • u ເປັນ URL ຂອງການຊອກຫາທັງຫມົດ, ລະບົບການຊອກຫາປະກອບດ້ວຍ, ເຊັ່ນດຽວກັນກັບການຂຽນ.
  • method ວິທີການ HTTP
  • payload ເປັນ SHA-256 ຂອງຮ່າງກາຍຄວາມຕ້ອງການ Raw, ໃນ hex. POST ແລະ PATCH, ແລະຮ່າງກາຍທີ່ທ່ານສົ່ງຕ້ອງເປັນ byte ສໍາລັບ byte ທີ່ທ່ານ hashed.
  • created_at ມັນຕ້ອງເປັນໃນໄລຍະ 60 ວິນາທີຂອງຊົ່ວໂມງຂອງ server.
  • ປະເພດຂອງການເຮັດວຽກ A GET ໃນຖານະເປັນບໍລິສັດທີ່ໃຫ້ການຝຶກອົບຮົມການຝຶກອົບຮົມໃຫ້ບຸກຄົນ, ບໍລິສັດທີ່ໃຫ້ການຝຶກອົບຮົມໃຫ້ບຸກຄົນ, ບໍລິສັດແລະວິທະຍາໄລກ່ຽວກັບການຝຶກອົບຮົມ nonce ຊື່ຫຍໍ້ຂອງ : tag ມີຄຸນນະສົມບັດທີ່ບໍ່ເສຍຄ່າ, ດັ່ງນັ້ນສອງຄໍາຮ້ອງສະຫມັກທີ່ລົງທະບຽນໃນຊົ່ວໂມງเดียวกันຍັງແຕກຕ່າງກັນ.
  • ຂະຫນາດຂອງການຢັ້ງຢືນການຢັ້ງຢືນສາມາດສູງສຸດ 64 KB, ແລະຂະຫນາດການຢັ້ງຢືນການຢັ້ງຢືນຕ້ອງ Content-Type: application/json.

ຄວາມຄິດເຫັນທີ່ The Missing Event Returns 401 missing_nostr_authຂ້າພະເຈົ້າສືບຕໍ່ໄດ້ຮັບການປະທັບໃຈກໍໂດຍການບໍລິການລູກຄ້າຂອງພວກເຮົາ invalid_nostr_auth, ທີ່ຢູ່ ສະ ຫນັບ ສະ ຫນັບ ສະ ຫນັບ ສະ ຫນູນ ສະ ຫນັບ ສະ ຫນູນ ສະ ຫນູນ ສະ ຫນູນ ສະ ຫນູນ ສະ ຫນູນ ສະ ຫນູນ ສະ ຫນູນ ສະ ຫນູນ ສະ ຫນູນ ສະ ຫນູນ ສະ ຫນູນ nostr_auth_replayedການຢັ້ງຢືນແມ່ນຖືກກວດສອບກ່ອນທີ່ຈະກວດສອບຮ່າງກາຍ, ແລະແຕ່ລະທີ່ຢູ່ສາມາດບໍ່ໄດ້ຮັບມັນ 30 ນາທີ (IPv6 address counts as its whole /64); ຫຼັງຈາກນັ້ນມັນຈະໄດ້ຮັບ 429 ປະເພດ Retry-After.

ການໂຫລດ browser ນີ້ສາມາດໂທຫາ endpoints ນີ້ພຽງແຕ່ຈາກເວັບໄຊທ໌ Nymbot ຂອງຕົນເອງ (https://nymbot.ai, https://nymchat.app ເວັບໄຊທ໌ໃນເວັບໄຊທ໌ອື່ນໆຈະບໍ່ໄດ້ຮັບ headers CORS ຫຼັງຈາກນັ້ນມັນບໍ່ສາມາດອ່ານສິ່ງທີ່ພວກເຂົາເຈົ້າຕອບສະຫນອງ. Scripts ແລະ apps native, ເຊິ່ງໃຫ້ບໍ່ມີ Originພວກເຮົາບໍ່ມີຜົນກະທົບ

ລະຫັດ QR

ຊື່ຫຍໍ້ຂອງ : Signing needs your nym's secret key nsec), ເຊິ່ງຄວບຄຸມທຸກສິ່ງທຸກຢ່າງ: identity ຂອງທ່ານ, ການປະຫວັດສາດຂອງທ່ານ, ແລະ balance ຂອງທ່ານ. ພຽງແຕ່ຕິດຕາມມັນໃນ script ໃນເຄື່ອງທີ່ທ່ານເຊື່ອມຕໍ່, ດາວນ໌ໂຫລດມັນຈາກສະພາບແວດລ້ອມໃນຂະນະທີ່ຂຽນມັນໃນເອກະສານ, ແລະເລືອກເອົາ app ໃນເວລາທີ່ທ່ານສາມາດ.

ຜູ້ຊ່ວຍເຫຼືອເຫຼົ່ານີ້ກໍ່ສ້າງ header. ເງື່ອນໄຂທີ່ຜ່ານມາໃນເວັບໄຊນີ້ນໍາໃຊ້ພວກເຂົາ. ພວກເຂົາເຈົ້າອ່ານ key secret ໃນ hex ຈາກ NOSTR_SECRET_HEX; cURL one ນໍາ ໃຊ້ ຕົ້ນ ຕໍ ເຄື່ອງມື command-line, ທີ່ໃຊ້ nsec ຫຼື hex key, ແລະ sha256sum ໃນ macOS, shasum -a 256).

cURL

nostr_auth() {
  method="$1"; url="$2"; body="$3"
  nonce=$(openssl rand -hex 16)
  if [ -n "$body" ]; then
    hash=$(printf '%s' "$body" | sha256sum | cut -d' ' -f1)
    event=$(nak event --sec "$NOSTR_SECRET_HEX" -k 27235 -t "u=$url" -t "method=$method" -t "nonce=$nonce" -t "payload=$hash")
  else
    event=$(nak event --sec "$NOSTR_SECRET_HEX" -k 27235 -t "u=$url" -t "method=$method" -t "nonce=$nonce")
  fi
  printf 'Nostr %s' "$(printf '%s' "$event" | base64 | tr -d '\n')"
}

Python

# pip install coincurve requests
import base64, hashlib, json, os, time
from coincurve import PrivateKey, PublicKeyXOnly

SECRET = bytes.fromhex(os.environ["NOSTR_SECRET_HEX"])

def nostr_auth(method, url, body=b""):
    pubkey = PublicKeyXOnly.from_secret(SECRET).format().hex()
    tags = [["u", url], ["method", method], ["nonce", os.urandom(16).hex()]]
    if body:
        tags.append(["payload", hashlib.sha256(body).hexdigest()])
    created_at = int(time.time())
    serialized = json.dumps([0, pubkey, created_at, 27235, tags, ""], separators=(",", ":"), ensure_ascii=False)
    event_id = hashlib.sha256(serialized.encode()).digest()
    event = {
        "id": event_id.hex(),
        "pubkey": pubkey,
        "created_at": created_at,
        "kind": 27235,
        "tags": tags,
        "content": "",
        "sig": PrivateKey(SECRET).sign_schnorr(event_id).hex(),
    }
    return "Nostr " + base64.b64encode(json.dumps(event).encode()).decode()

JavaScript

// npm install nostr-tools
import { createHash, randomBytes } from "node:crypto";
import { finalizeEvent } from "nostr-tools/pure";

const secret = Buffer.from(process.env.NOSTR_SECRET_HEX, "hex");

export function nostrAuth(method, url, body = "") {
  const tags = [["u", url], ["method", method], ["nonce", randomBytes(16).toString("hex")]];
  if (body) tags.push(["payload", createHash("sha256").update(body).digest("hex")]);
  const event = finalizeEvent(
    { kind: 27235, created_at: Math.floor(Date.now() / 1000), tags, content: "" },
    secret,
  );
  return "Nostr " + Buffer.from(JSON.stringify(event)).toString("base64");
}

ລະຫັດ QR

ວິທີການທີ່ API ຂອງ app ໄດ້ສະແດງໃຫ້ເຫັນໃນປັດຈຸບັນ: ຄຸນນະສົມບັດ public ຂອງທ່ານ, ຄຸນນະສົມບັດທີ່ແຕກຕ່າງກັນ, ຄຸນນະສົມບັດທີ່ແຕກຕ່າງກັນແລະຄຸນນະສົມບັດທີ່ແຕກຕ່າງກັນ ອັດຕະໂນມັດ Top-up ການຕັ້ງຄ່າ, ຫຼື null ໃນເວລາທີ່ server ບໍ່ສະເຫນີ.

GET https://nymbot.ai/api/v1/account ຂໍຂອບໃຈ ຄໍາຮ້ອງສະຫມັກ.

ຄໍາຖາມ

{
  "data": {
    "pubkey": "3bf0c63fcb93463407af97a5e5ee64fa883d107ef9e558472c4eb9aaaefa459d",
    "balances": {
      "standard": { "credits": 120.4, "sats": 1204 },
      "pro": { "credits": 408.33, "sats": 40833 }
    },
    "keys_active": 3,
    "nwc_auto_topup": {
      "connected": true, "threshold_sats": 5000, "topup_sats": 20000, "tier": "pro",
      "last_topup_at": null, "last_topup_sats": null, "last_error": null
    }
  }
}

cURL

URL=https://nymbot.ai/api/v1/account
curl "$URL" -H "Authorization: $(nostr_auth GET "$URL")"

Python

import requests

url = "https://nymbot.ai/api/v1/account"
print(requests.get(url, headers={"Authorization": nostr_auth("GET", url)}).json())

JavaScript

const url = "https://nymbot.ai/api/v1/account";
const res = await fetch(url, { headers: { "Authorization": nostrAuth("GET", url) } });
console.log(await res.json());

ການຄຸ້ມຄອງ Key

ຫນ້າທໍາອິດ / Apps / Apps / Apps / Apps / Apps / Apps / Apps ຄໍາຮ້ອງສະຫມັກຄຸນນະສົມບັດຂອງຄຸນນະສົມບັດແລະຄຸນນະສົມບັດຂອງຄຸນນະສົມບັດ

ລະຫັດ QR

{
  "id": "4f0c9a1be27d3856",
  "name": "laptop scripts",
  "hint": "sk-nymbot-Qm7x…c2Lw",
  "limit_sats": 20000,
  "reset_period": "monthly",
  "reset_at": "2026-10-01T00:00:00Z",
  "expire_at": null,
  "period_used_sats": 3412,
  "total_used_sats": 18230,
  "created_at": "2026-08-14T09:21:07Z",
  "updated_at": "2026-09-02T17:40:55Z",
  "last_used_at": "2026-09-30T08:12:00Z",
  "revoked_at": null
}

hint ການເຂົ້າລະຫັດເປັນປະສິດທິພາບສໍາລັບການເຂົ້າລະຫັດເປັນປະສິດທິພາບສໍາລັບການເຂົ້າລະຫັດເປັນປະສິດທິພາບສໍາລັບການເຂົ້າລະຫັດເປັນປະສິດທິພາບສໍາລັບການເຂົ້າລະຫັດເປັນປະສິດທິພາບສໍາລັບການເຂົ້າລະຫັດເປັນປະສິດທິພາບສໍາລັບການເຂົ້າລະຫັດເປັນປະສິດທິພາບສໍາລັບການເຂົ້າລະຫັດເປັນປະສິດທິພາບ

ລະຫັດ QR

GET https://nymbot.ai/api/v1/keys ຂໍຂອບໃຈ

ປະເພດ Fieldປະເພດປະເພດດາວໂຫລດ
include_revokedຊື່ຫຍໍ້ຂອງ : Boolean (query)ບໍ່ລວມທັງ Key Revoked. false.

ຄໍາຖາມ

{ "data": [ { "id": "4f0c9a1be27d3856", "name": "laptop scripts", "hint": "sk-nymbot-Qm7x…c2Lw", "...": "..." } ] }

cURL

URL=https://nymbot.ai/api/v1/keys
curl "$URL" -H "Authorization: $(nostr_auth GET "$URL")"

Python

import requests

url = "https://nymbot.ai/api/v1/keys"
for key in requests.get(url, headers={"Authorization": nostr_auth("GET", url)}).json()["data"]:
    print(key["id"], key["name"], key["period_used_sats"], key["limit_sats"])

JavaScript

const url = "https://nymbot.ai/api/v1/keys";
const { data } = await (await fetch(url, { headers: { "Authorization": nostrAuth("GET", url) } })).json();
for (const key of data) console.log(key.id, key.name, key.period_used_sats, key.limit_sats);

ດາວນ໌ໂຫລດ Key

POST https://nymbot.ai/api/v1/keys ດາວນ໌ໂຫລດ 201.

ປະເພດ Fieldປະເພດປະເພດດາວໂຫລດ
nameລະຫັດ QRແມ່ນແລ້ວ1 ເຖິງ 40 ກິດຈະກໍາ, ທີ່ແຕກຕ່າງກັນຈາກຄອມພິວເຕີທີ່ເຮັດວຽກອື່ນໆຂອງທ່ານ (ລັກສະນະ ignoring).
limit_satsລະຫັດ QRບໍ່ຄ່າໃຊ້ຈ່າຍ cap ໃນ sats, ບໍ່ພຽງແຕ່ 1. ກະລຸນາໃຫ້ມັນ off ສໍາລັບບໍ່ມີ cap.
reset_periodລະຫັດ QRບໍ່daily, weekly ປະເພດ monthlyປະເພດ limit_sats. ຂ້າງລຸ່ມນີ້ສໍາລັບ cap ທີ່ບໍ່ໄດ້ reset.
expire_atລະຫັດ QRບໍ່ໃນເວລາທີ່ຄ້າຍຄືການເຮັດວຽກ: ການ ISO 8601 ເວລາ, ຫຼື milliseconds ຈາກ 1970.

ລະຫັດ QR

{
  "data": {
    "id": "4f0c9a1be27d3856",
    "name": "laptop scripts",
    "hint": "sk-nymbot-Qm7x…c2Lw",
    "limit_sats": 20000,
    "reset_period": "monthly",
    "key": "sk-nymbot-Qm7x...c2Lw",
    "...": "the rest of the key object"
  }
}
ລະຫັດ QRໃນເວລາທີ່
400ຊື່ທີ່ບໍ່ມີຫຼືຂະຫນາດນ້ອຍ; ຊື່ທີ່ໄດ້ຮັບການນໍາໃຊ້ (duplicate_name); cap ທີ່ບໍ່ແມ່ນຂະຫນາດໃຫຍ່ທີ່ບໍ່ມີຫຼາຍກ່ວາ 1; ໄລຍະເວລາທີ່ບໍ່ມີ cap; ໄລຍະເວລາທີ່ຜ່ານມາ; field unknown (unknown_parameter); ຫຼື 25 key ທີ່ເຮັດວຽກ already (too_many_keys).
429ຫຼາຍກ່ວາ 60 key ສ້າງໂດຍ nym ນີ້, ຫຼື 120 ຈາກທີ່ຢູ່ນີ້, ໃນ 1 ຊົ່ວໂມງ (rate_limit_exceededຂ້າ ພະ ເຈົ້າ Retry-After).

cURL

URL=https://nymbot.ai/api/v1/keys
BODY='{"name":"laptop scripts","limit_sats":20000,"reset_period":"monthly"}'
curl "$URL" \
  -H "Authorization: $(nostr_auth POST "$URL" "$BODY")" \
  -H "Content-Type: application/json" \
  -d "$BODY"

Python

import json
import requests

url = "https://nymbot.ai/api/v1/keys"
body = json.dumps({"name": "laptop scripts", "limit_sats": 20000, "reset_period": "monthly"}).encode()
res = requests.post(
    url,
    data=body,
    headers={"Authorization": nostr_auth("POST", url, body), "Content-Type": "application/json"},
)
print(res.json()["data"]["key"])

JavaScript

const url = "https://nymbot.ai/api/v1/keys";
const body = JSON.stringify({ name: "laptop scripts", limit_sats: 20000, reset_period: "monthly" });
const res = await fetch(url, {
  method: "POST",
  headers: { "Authorization": nostrAuth("POST", url, body), "Content-Type": "application/json" },
  body,
});
console.log((await res.json()).data.key);

ດາວນ໌ໂຫລດ One Key

GET https://nymbot.ai/api/v1/keys/{id} ຂໍຂອບໃຈ

ຫນ້າທໍາອິດ {"data": {…}} ໃນຖານະເປັນ Key Object, ຫຼື 404 key_not_found ຖ້າຫາກວ່າບໍ່ມີ key ຂອງທ່ານມີ id ນີ້.

cURL

URL=https://nymbot.ai/api/v1/keys/4f0c9a1be27d3856
curl "$URL" -H "Authorization: $(nostr_auth GET "$URL")"

Python

import requests

url = "https://nymbot.ai/api/v1/keys/4f0c9a1be27d3856"
print(requests.get(url, headers={"Authorization": nostr_auth("GET", url)}).json()["data"])

JavaScript

const url = "https://nymbot.ai/api/v1/keys/4f0c9a1be27d3856";
console.log((await (await fetch(url, { headers: { "Authorization": nostrAuth("GET", url) } })).json()).data);

ການປ່ຽນແປງ Key

PATCH https://nymbot.ai/api/v1/keys/{id} ຂໍຂອບໃຈ

ດາວນ໌ໂຫລດ name, limit_sats, reset_period ແລະ expire_at, ໂດຍປົກກະຕິເຊັ່ນດຽວກັນເຊັ່ນດຽວກັນກັບການສ້າງ key. null ການປ່ຽນແປງປະເພດຂອງການປ່ຽນແປງປະເພດຂອງການປ່ຽນແປງປະເພດຂອງການປ່ຽນແປງປະເພດຂອງການປ່ຽນແປງປະເພດ400 key_revokedດາວໂຫລດ {"data": {…}} ການປັບປຸງ Key Object

cURL

URL=https://nymbot.ai/api/v1/keys/4f0c9a1be27d3856
BODY='{"limit_sats":50000,"expire_at":null}'
curl -X PATCH "$URL" \
  -H "Authorization: $(nostr_auth PATCH "$URL" "$BODY")" \
  -H "Content-Type: application/json" \
  -d "$BODY"

Python

import json
import requests

url = "https://nymbot.ai/api/v1/keys/4f0c9a1be27d3856"
body = json.dumps({"limit_sats": 50000, "expire_at": None}).encode()
res = requests.patch(
    url,
    data=body,
    headers={"Authorization": nostr_auth("PATCH", url, body), "Content-Type": "application/json"},
)
print(res.json()["data"])

JavaScript

const url = "https://nymbot.ai/api/v1/keys/4f0c9a1be27d3856";
const body = JSON.stringify({ limit_sats: 50000, expire_at: null });
const res = await fetch(url, {
  method: "PATCH",
  headers: { "Authorization": nostrAuth("PATCH", url, body), "Content-Type": "application/json" },
  body,
});
console.log((await res.json()).data);

ດາວໂຫລດ Key

DELETE https://nymbot.ai/api/v1/keys/{id} ຂໍຂອບໃຈ

ດາວນ໌ໂຫລດ The Best Online revoked_at ສ້າງຕັ້ງຂຶ້ນ, ແລະສາມາດເບິ່ງກັບ include_revoked=trueRevoicing a key that is already revoked reply the same way. Only the latest 50 revoked keys are retained; older ones are deleted when another key is revoked.

ຄໍາຖາມ

{ "data": { "id": "4f0c9a1be27d3856", "revoked": true } }

cURL

URL=https://nymbot.ai/api/v1/keys/4f0c9a1be27d3856
curl -X DELETE "$URL" -H "Authorization: $(nostr_auth DELETE "$URL")"

Python

import requests

url = "https://nymbot.ai/api/v1/keys/4f0c9a1be27d3856"
print(requests.delete(url, headers={"Authorization": nostr_auth("DELETE", url)}).json())

JavaScript

const url = "https://nymbot.ai/api/v1/keys/4f0c9a1be27d3856";
const res = await fetch(url, { method: "DELETE", headers: { "Authorization": nostrAuth("DELETE", url) } });
console.log(await res.json());

NWC ອັດຕະໂນມັດ Top-up

ການເຊື່ອມຕໍ່ wallet Lightning ກັບ Nostr Wallet Connect ແລະ Nymbot ສະຫນັບສະຫນູນການປະທັບໃຈໂດຍຕົນເອງໃນເວລາທີ່ການ spending API ເຮັດໃຫ້ມັນຕ່ໍາ. ເອກະສານ API ຂອງ app ມີການຕັ້ງຄ່າທີ່ແຕກຕ່າງກັນ; ນີ້ແມ່ນ endpoints ໃນຂະນະທີ່ມັນ. ທັງຫມົດຂອງພວກເຂົາເຈົ້າຕ້ອງການ ຄໍາຮ້ອງສະຫມັກ.

ວິທີການເຮັດວຽກ: ຫຼັງຈາກການຢັ້ງຢືນ API ໄດ້ຖືກດາວໂຫລດໄປຫາສະຖາບັນທີ່ທ່ານເລືອກທີ່ຈະເບິ່ງ, ຖ້າຫາກວ່າສະຖາບັນທີ່ຂ້າງລຸ່ມຂ້າງລຸ່ມຂອງທ່ານ, Nymbot ເຮັດໃຫ້ບັນຊີລາຍຊື່ສໍາລັບລາຍລະອຽດ top-up ຂອງທ່ານ, ກະລຸນາບັນຊີລາຍລະອຽດຫຼັງຈາກນັ້ນໃຫ້ບັນຊີລາຍລະອຽດຫຼັງຈາກນັ້ນ, ແລະເພີ່ມບັນຊີລາຍລະອຽດ. ມັນຖືກດາວໂຫລດຫຼາຍກ່ວາຫນຶ່ງໃນ 5 ນາທີສໍາລັບທຸກຄົນແລະສະຖາບັນ, ດັ່ງນັ້ນບັນຊີລາຍລະອຽດບໍ່ສາມາດດາວໂຫລດບັນຊີລາຍລະອຽດຫຼັງຈາກນັ້ນ. ການໃຊ້ເວລາແລະຂະຫນາດຂອງບັນຊີລາຍລະອຽດຫຼັງຈາກນັ້ນ, ແລະບັນຊີລາຍລະອຽດຫຼັງຈາກນັ້ນ, ແມ່ນຢູ່ໃນສະຖານທີ່; ຖ້າຫ ປະເພດ Top-Up ການເຊື່ອມຕໍ່

ຫຼັງຈາກການເຊື່ອມຕໍ່ wallet

Nymbot ສະຫນັບສະຫນູນການເຂົ້າລະຫັດແລະພຽງແຕ່ນໍາໃຊ້ມັນເພື່ອຊໍາລະຫັດ top-up ຂອງຕົນເອງ, ແຕ່ສ້າງການເຊື່ອມຕໍ່ພຽງແຕ່ສໍາລັບການນີ້, ມີຄຸນຄ່າໃຊ້ຈ່າຍໃນ wallet ຂອງທ່ານ, ດັ່ງນັ້ນຫຼາຍທີ່ສຸດມັນສາມາດຊໍາລະເງິນແມ່ນຈໍານວນທີ່ເລືອກທ່ານ. wallet ມີການສະຫນັບສະຫນູນ pay_invoice.

ການເຊື່ອມຕໍ່ wallet

POST https://nymbot.ai/api/v1/nwc-auto-topup/connect ຂໍຂອບໃຈ

ປະເພດ Fieldປະເພດປະເພດດາວໂຫລດ
nwc_urlລະຫັດ QRແມ່ນແລ້ວລະຫັດ QR nostr+walletconnect://. Nymbot ເຮັດໃຫ້ wallet ສໍາລັບ get_info ຂໍຂອບໃຈວ່າທ່ານກໍາລັງຊອກຫາຂໍ້ມູນເພີ່ມເຕີມ.
threshold_satsລະຫັດ QRແມ່ນແລ້ວTop up when the balance falls below these many sats. ອັດຕະໂນມັດ
topup_satsລະຫັດ QRແມ່ນແລ້ວຫຼາຍກວ້າງຂວາງທີ່ຈະເພີ່ມ. 1000 ກັບ 1,000,000 sats.
tierລະຫັດ QRບໍ່pro (ການດໍາເນີນການ) ຫຼື standard: Balance to Watch ແລະ Top Up.

ຄໍາຖາມ

{
  "data": {
    "connected": true,
    "threshold_sats": 5000,
    "topup_sats": 20000,
    "tier": "pro",
    "last_topup_at": null,
    "last_topup_sats": null,
    "last_error": null
  }
}
ລະຫັດ QRໃນເວລາທີ່
400ລະຫັດ QRinvalid_nwc_url); wallet ໄດ້ບໍ່ໄດ້ຮັບການຕອບກ່ຽວກັບການ relay ຂອງຕົນ (nwc_unreachable) ຫຼືບໍ່ໄດ້ຮັບການກວດສອບ (nwc_rejected); ການເຊື່ອມຕໍ່ບໍ່ສາມາດຊໍາລະເງິນ (nwc_missing_permission); ຫຼືຂະຫນາດທີ່ບໍ່ແມ່ນກໍານົດໄວ້.
501ອັດຕະໂນມັດ Top-ups ແມ່ນບໍ່ເຂົ້າໃຈສໍາລັບ server ນີ້ (nwc_unavailable) ຄຸນນະສົມບັດທີ່ກ່ຽວຂ້ອງກັບສອງ endpoints ອື່ນໆ.

cURL

URL=https://nymbot.ai/api/v1/nwc-auto-topup/connect
BODY='{"nwc_url":"nostr+walletconnect://...","threshold_sats":5000,"topup_sats":20000,"tier":"pro"}'
curl "$URL" \
  -H "Authorization: $(nostr_auth POST "$URL" "$BODY")" \
  -H "Content-Type: application/json" \
  -d "$BODY"

Python

import json, os
import requests

url = "https://nymbot.ai/api/v1/nwc-auto-topup/connect"
body = json.dumps({
    "nwc_url": os.environ["NWC_URL"],
    "threshold_sats": 5000,
    "topup_sats": 20000,
    "tier": "pro",
}).encode()
res = requests.post(
    url,
    data=body,
    headers={"Authorization": nostr_auth("POST", url, body), "Content-Type": "application/json"},
)
print(res.json())

JavaScript

const url = "https://nymbot.ai/api/v1/nwc-auto-topup/connect";
const body = JSON.stringify({
  nwc_url: process.env.NWC_URL,
  threshold_sats: 5000,
  topup_sats: 20000,
  tier: "pro",
});
const res = await fetch(url, {
  method: "POST",
  headers: { "Authorization": nostrAuth("POST", url, body), "Content-Type": "application/json" },
  body,
});
console.log(await res.json());

ດາວນ໌ໂຫລດ The Settings

GET https://nymbot.ai/api/v1/nwc-auto-topup ຂໍຂອບໃຈ

ດາວໂຫລດ Object ທີ່ດຽວກັນກັບການເຊື່ອມຕໍ່, ມີ connected: false ແລະພາກພື້ນອື່ນໆ null ໃນເວລາທີ່ບໍ່ມີ wallet ໄດ້ເຊື່ອມຕໍ່, ສາຍການເຊື່ອມຕໍ່ຕົນເອງຈະບໍ່ໄດ້ຮັບການດໍາເນີນການ.

cURL

URL=https://nymbot.ai/api/v1/nwc-auto-topup
curl "$URL" -H "Authorization: $(nostr_auth GET "$URL")"

Python

import requests

url = "https://nymbot.ai/api/v1/nwc-auto-topup"
print(requests.get(url, headers={"Authorization": nostr_auth("GET", url)}).json())

JavaScript

const url = "https://nymbot.ai/api/v1/nwc-auto-topup";
console.log(await (await fetch(url, { headers: { "Authorization": nostrAuth("GET", url) } })).json());

ການເຊື່ອມຕໍ່

DELETE https://nymbot.ai/api/v1/nwc-auto-topup/connection ຂໍຂອບໃຈ

ດາວໂຫລດການເຊື່ອມຕໍ່ທີ່ຖືກເກັບຮັກສາ. No more top-ups are made. To be sure, you can also revoke the connection in your wallet.

ຄໍາຖາມ

{ "data": { "connected": false, "threshold_sats": null, "topup_sats": null, "tier": null, "last_topup_at": null, "last_topup_sats": null, "last_error": null } }

cURL

URL=https://nymbot.ai/api/v1/nwc-auto-topup/connection
curl -X DELETE "$URL" -H "Authorization: $(nostr_auth DELETE "$URL")"

Python

import requests

url = "https://nymbot.ai/api/v1/nwc-auto-topup/connection"
print(requests.delete(url, headers={"Authorization": nostr_auth("DELETE", url)}).json())

JavaScript

const url = "https://nymbot.ai/api/v1/nwc-auto-topup/connection";
const res = await fetch(url, { method: "DELETE", headers: { "Authorization": nostrAuth("DELETE", url) } });
console.log(await res.json());

ການຊໍາລະເງິນໂດຍບໍ່ມີ Key

ຄ່າໃຊ້ຈ່າຍ endpoints ອັດຕະໂນມັດສາມາດໄດ້ຮັບການຊໍາລະເງິນສໍາລັບການຊໍາລະເງິນຫນຶ່ງໃນເວລາຫຼາຍກ່ວາ Lightning, ບໍ່ມີ key, ບໍ່ມີ account ແລະບໍ່ມີ balance: POST /images/generations, POST /images/edits, POST /videos, POST /audio/speech, POST /audio/transcriptions, POST /audio/translations ແລະ POST /embeddingsການສອບເສັງ, ຄໍາຖາມ, ແລະ ຄໍາຖາມ ຕ້ອງການເປັນເອກະສານ. ຄໍາຖາມທີ່ມີເອກະສານເປັນເອກະສານເປັນເອກະສານເປັນເອກະສານເປັນເອກະສານເປັນເອກະສານເປັນເອກະສານເປັນເອກະສານເປັນເອກະສານເປັນເອກະສານເປັນເອກະສານ.

Nymbot ສະແດງໃຫ້ເຫັນສອງຕົວແທນຂອງຕົວແທນเดียวกัน, ຈາກຫນຶ່ງ backend: Lightning Labs ' ລະຫັດ QR (ຍັງໄດ້ຮັບການຮັບຮອງໂດຍຊື່ຫຼັງຈາກນັ້ນ, LSAT) ແລະໂຄງການ IETF ເງິນຝາກ ລະບົບການຢັ້ງຢືນ HTTP ກັບ lightning ວິທີການແລະ charge ການນໍາໃຊ້ສິ່ງທຸກຢ່າງທີ່ລູກຄ້າຂອງທ່ານຮູ້.

ການນໍາໃຊ້ server ຂອງທ່ານເອງ

ການຊໍາລະເງິນໂດຍບໍ່ມີ Key ແມ່ນ only on when API_L402_SECRET ມີປະມານ 32 bytes random, ເປັນ hex (64 characters) ຫຼື base64 (44). openssl rand -hex 32ຄ່າໃຊ້ຈ່າຍທີ່ຍິ່ງໃຫຍ່ຫຼືສາມາດຄາດຄະເນດິນທີ່ຖືກຄາດຄະເນດິນທີ່ຖືກຄາດຄະເນດິນທີ່ຖືກຄາດຄະເນດິນທີ່ຖືກຄາດຄະເນດິນທີ່ຖືກຄາດຄະເນດິນທີ່ຖືກຄາດຄະເນດິນທີ່ຖືກຕ້ອງ API_L402_SECRET_PREVIOUS ໃນມື້ນີ້: credentials, URLs ລະບົບແລະການປະທັບໃຈທີ່ເຮັດໄດ້ພາຍໃຕ້ມັນຈະເຮັດວຽກ jusqu'à ce qu'ils expire.

ຄວາມຄິດເຫັນ

ດາວນ໌ໂຫລດ No Authorization header. ຖ້າຫາກວ່າມັນເປັນປະສິດທິພາບ, ບໍ່ມີການເຮັດວຽກ, ແລະທ່ານໄດ້ຮັບ 402 Payment Required ມີການຊໍາລະເງິນສໍາລັບສິ່ງທີ່ຄົ້ນບໍ່ແຮ່: ລາຄາທີ່ແຕກຕ່າງກັນທີ່ຄົ້ນບໍ່ແຮ່ຈະໄດ້ຮັບການຊໍາລະເງິນ, ການປ່ຽນແປງໃນ 10 sats ສໍາລັບການຄົ້ນບໍ່ແຮ່ປະເພດຫຼື 100 sats ສໍາລັບການຄົ້ນບໍ່ແຮ່ປະເພດ Pro ແລະຕໍາແຫນ່ງເຖິງການຄົ້ນບໍ່ແຮ່ປະເພດທັງຫມົດ (ຫຼຸດລົງ 1 sat, ແລະຫຼຸດລົງ 0.05 ສໍາລັບການຄົ້ນບໍ່ແຮ່ປະເພດ). WWW-Authenticate ຄໍາຖາມ ສໍາ ລັບ ສັດ ລ້ຽງ:

HTTP/1.1 402 Payment Required
Content-Type: application/problem+json; charset=utf-8
Cache-Control: no-store
WWW-Authenticate: L402 macaroon="AgJC...", invoice="lnbc2370n1..."
WWW-Authenticate: LSAT macaroon="AgJC...", invoice="lnbc2370n1..."
WWW-Authenticate: Payment id="kM9x...", realm="nymbot", method="lightning", intent="charge",
    request="eyJhbW91bnQiOiIyMzciLC...", description="Nymbot API POST /images/generations (237 sats)",
    digest="sha-256=:X48E9qOokqqrvdts8nOJRJN3OWDUoyWxBf7kbu9DBPE=:", expires="2026-09-30T12:15:00.000Z",
    opaque="eyJlbmRwb2ludCI6IlBPU1QgL2ltYWdlcy9nZW5lcmF0aW9ucyJ9"

{
  "type": "https://paymentauth.org/problems/payment-required",
  "title": "Payment Required",
  "status": 402,
  "detail": "This request costs 237 sats. Pay the Lightning invoice, then send the identical request again ...",
  "challengeId": "kM9x...",
  "amount_sats": 237,
  "invoice": "lnbc2370n1...",
  "payment_hash": "9db1370f...",
  "expires_at": "2026-09-30T12:15:00.000Z",
  "error": { "message": "This request costs 237 sats. ...", "type": "payment_required", "code": "payment_required", "param": null }
}

ການຊໍາລະເງິນ request ອັດຕະໂນມັດ JSON base64url: {"amount":"237","currency":"sat","methodDetails":{"invoice":"lnbc...","network":"mainnet","paymentHash":"..."}}.

ການທົດສອບແມ່ນເຊື່ອມຕໍ່ກັບ endpoint, ກັບ Content-Type (ປະເພດອຸປະກອນຂອງຕົນແລະ, ສໍາລັບ multipart, ການກວດສອບຂອງຕົນ) ແລະກັບ SHA-256 ຂອງຮ່າງກາຍທີ່ແທ້ຈິງທີ່ທ່ານສົ່ງ, ແລະໃຊ້ເວລາ 15 ນາທີ. ຫຼັງຈາກການຊໍາລະເງິນ, ກະລຸນາສົ່ງ ປະເພດ ຄໍາຮ້ອງສະຫມັກທີ່ແຕກຕ່າງກັນ: same Content-Type ຂ້າພະເຈົ້າສືບຕໍ່ໄດ້ຮັບການປະທັບໃຈກໍໂດຍ JSON Bytes (/images/edits, /audio/transcriptions, /audio/translationsວິທະຍາໄລຂອງ HTTP ວິທະຍາໄລໄດ້ກວດສອບການຄົ້ນຄວ້າແລະການຄົ້ນຄວ້າທາງດ້ານວິຊາການແລະການຄົ້ນຄວ້າທາງດ້ານວິຊາການ.

ຄໍາຖາມທີ່ອີເມວທີ່ບໍ່ໄດ້ຮູ້ສຶກມີ 10 ໃນຂະນະທີ່ບໍ່ໄດ້ຮູ້ສຶກວ່າມີ 10 ໃນຂະນະທີ່ບໍ່ໄດ້ຮູ້ສຶກວ່າມີ 30 ຄໍາຖາມໃນຂະນະທີ່ບໍ່ໄດ້ຮູ້ສຶກວ່າມີ 30 ຄໍາຖາມໃນຂະນະທີ່ບໍ່ຮູ້ສຶກວ່າມີ 64 ຄໍາຖາມໃນຂະນະທີ່ບໍ່ຮູ້ສຶກວ່າມີ 30 ຄໍາຖາມໃນຂະນະທີ່ບໍ່ຮູ້ສຶກວ່າມີ 64 ຄໍາຖາມ. 429 ປະເພດ Retry-Afterຫຼັງຈາກນັ້ນ, ທ່ານຈະເລີ່ມຕົ້ນການສອບເສັງຂອງການສອບເສັງຂອງການສອບເສັງຂອງການສອບເສັງຂອງການສອບເສັງຂອງການສອບເສັງຂອງການສອບເສັງຂອງການສອບເສັງ. Content-Type ຂ້າພະເຈົ້າບໍ່ application/json (ຫຼື multipart/form-data ການອັບໂຫລດ 415 ຂໍຂອບໃຈວ່າທ່ານຈະບໍ່ໄດ້ຮັບອະນຸຍາດ.

Embeddings ໄດ້ຮັບຄ່າໃຊ້ຈ່າຍຈາກການຄາດຄະເນຂອງ tokens ໃນ input, ມີ 1.5 times; margin, ໃນຂະນະທີ່ການຄາດຄະເນດິນທີ່ແທ້ຈິງແມ່ນຮູ້ຈັກຫຼັງຈາກນັ້ນ. You pay for the tokens actually used, and the unused part of the payment comes back as a reward. ລະຫັດ QR.

ການຈັດສົ່ງການຊໍາລະເງິນ

Pay the invoice with any Lightning wallet. The wallet gives you the preimage, 64 hex characters. ຫຼັງຈາກນັ້ນຂຽນຄໍາຮ້ອງສະຫມັກเดียวกันກັບຫນຶ່ງຂອງພວກເຂົາ:

ລະບົບລະຫັດ QR
ລະຫັດ QRAuthorization: L402 <macaroon>:<preimage> (LSAT ການເຮັດວຽກ)
ເງິນຝາກAuthorization: Payment <base64url JSON>, ທີ່ JSON ແມ່ນ {"challenge": {every parameter of the challenge, as sent}, "payload": {"preimage": "<hex>"}}

ຄໍາຮ້ອງສະຫມັກມີຄ່າໃຊ້ຈ່າຍແມ່ນຄ້າຍຄືກັບຄໍາຮ້ອງສະຫມັກທີ່ມີຄຸນນະສົມບັດ, ເຖິງແມ່ນວ່າ nymbot Object ບໍ່ມີ fields ການຄຸ້ມຄອງ: {"payment": "l402", "tier": "pro", "paid_sats": 237, "charged_sats": 237}, ແລະບໍ່ມີ X-Nymbot-Balance-Sats header. ຄໍາຮ້ອງສະຫມັກທີ່ໄດ້ຮັບການຊໍາລະເງິນໂດຍໃຊ້ລະບົບການຊໍາລະເງິນຍັງໄດ້ຮັບການ Payment-Receipt header (base64url JSON ມີ id Challenge, ການຊໍາລະເງິນ hash as reference, status ແລະ timestamp). ຄໍາຮ້ອງສະຫມັກທີ່ໄດ້ຮັບການຊໍາລະເງິນບໍ່ແມ່ນເຊື່ອມຕໍ່ກັບ nym, ດັ່ງນັ້ນພວກເຂົາບໍ່ສະແດງໃນປະຫວັດສາດການຊໍາລະເງິນ.

ລະຫັດ QRໃນເວລາທີ່
402 payment_already_usedການຊໍາລະເງິນທຸກຄົນແມ່ນມີຄ່າໃຊ້ຈ່າຍສໍາລັບການຊໍາລະເງິນຫນຶ່ງ. ການຕອບສະຫນອງແມ່ນການສອບເສັງໃຫມ່ສໍາລັບການຊໍາລະເງິນນີ້, ດັ່ງນັ້ນລູກຄ້າທີ່ caching ການອະນຸຍາດທີ່ຜ່ານມາຂອງຕົນ (ເຊັ່ນ: lnget ເປັນຫຍັງ) ພຽງແຕ່ land again.
402 payment_mismatchcredential ໄດ້ຖືກຈັດຂຶ້ນສໍາລັບ endpoint ອື່ນໆ, Content-Type ຫຼັງຈາກນັ້ນ, ທ່ານຈະຊອກຫາຂໍ້ມູນເພີ່ມເຕີມກ່ຽວກັບການຊອກຫາຂໍ້ມູນເພີ່ມເຕີມກ່ຽວກັບການຊອກຫາຂໍ້ມູນ. ລະຫັດ QR (refund_token ແລະ refund_sats ໃນຮ່າງກາຍ
402 payment_expiredຫຼາຍກ່ວາ 15 ນາທີກ່ອນຫນ້ານີ້ຈາກການສອບເສັງ. ການສອບເສັງໃຫມ່ໄດ້ມາກັບມັນ. ຖ້າຫາກວ່າ preimage ໄດ້ສະແດງໃຫ້ເຫັນວ່າທ່ານໄດ້ຊື້, ສິ່ງທີ່ທ່ານໄດ້ຊື້ໄດ້ມາຈາກການສອບເສັງ ລະຫັດ QR (refund_token ແລະ refund_sats ໃນຮ່າງກາຍ), once; credential ຫຼັງຈາກນັ້ນຖືກນໍາໃຊ້.
401 invalid_preimageຮູບພາບ ສໍາ ລັບ ເອກະຊົນບໍລິການບໍລິການບໍລິສັດ ເອກະຊົນບໍລິການບໍລິສັດ ເອກະຊົນບໍລິການບໍລິສັດ ເອກະຊົນບໍລິການບໍລິສັດ ເອກະຊົນບໍລິການບໍລິສັດ ເອກະຊົນບໍລິການບໍລິສັດ ເອກະຊົນບໍລິການບໍລິສັດ ເອກະຊົນບໍລິການບໍລິສັດ ເອກະຊົນບໍລິການບໍລິການບໍລິສັດ ເອກະຊົນ
401 invalid_payment_credentialການຢັ້ງຢືນແມ່ນ malformed, ໄດ້ຖືກປ່ຽນແປງຫຼັງຈາກ Nymbot ໄດ້ສົ່ງອອກມັນ, ຫຼືຊື່ hash ການຊໍາລະເງິນ Nymbot ໄດ້ບໍ່ໄດ້ຮັບການອະນຸຍາດ. A macaroon ມີຄໍາແນະນໍາທີ່ Nymbot ບໍ່ຮູ້, ຫຼືມີຄໍາແນະນໍາທີ່ແຕກຕ່າງກັນ, ຈະໄດ້ຮັບການຕັດສິນໃຈ.
429 rate_limit_exceededຫຼາຍກ່ວາ 30 credentials ຫຼື key ທີ່ບໍ່ໄດ້ຮັບການຢັ້ງຢືນໄດ້ມາຈາກທີ່ຢູ່ນີ້ໃນຂະນະທີ່ 1 ນາທີ, ຫຼື 1 reimbursement token ໄດ້ຖືກສົ່ງຫຼາຍກ່ວາ 60 ເວລາໃນຂະນະທີ່ 1 ນາທີ. Retry-After.

cURL

BODY='{"model":"nano-banana","prompt":"a lighthouse at dusk","response_format":"b64_json"}'
URL=https://nymbot.ai/api/v1/images/generations

# 1. Get the challenge
CH=$(curl -s -D - -o /dev/null "$URL" -H "Content-Type: application/json" -d "$BODY" | grep -i '^www-authenticate: L402')
MAC=$(echo "$CH" | sed -E 's/.*macaroon="([^"]+)".*/\1/')
INVOICE=$(echo "$CH" | sed -E 's/.*invoice="([^"]+)".*/\1/')

# 2. Pay $INVOICE with your wallet and copy the preimage
PREIMAGE=...

# 3. Send the identical request with the credential
curl "$URL" -H "Content-Type: application/json" -H "Authorization: L402 $MAC:$PREIMAGE" -d "$BODY"

lnget

# lnget (Lightning Labs) pays L402 challenges from your own lnd node and retries for you
lnget -X POST -H "Content-Type: application/json" \
  -d '{"model":"nano-banana","prompt":"a lighthouse at dusk","response_format":"b64_json"}' \
  https://nymbot.ai/api/v1/images/generations

Python

import base64, json, re
import requests

url = "https://nymbot.ai/api/v1/images/generations"
body = json.dumps({"model": "nano-banana", "prompt": "a lighthouse at dusk", "response_format": "b64_json"}).encode()
headers = {"Content-Type": "application/json"}

challenge = requests.post(url, data=body, headers=headers)
assert challenge.status_code == 402
info = challenge.json()
print("Pay", info["amount_sats"], "sats:", info["invoice"])

preimage = pay_with_your_wallet(info["invoice"])  # 64 hex characters

# L402
mac = re.search(r'L402 macaroon="([^"]+)"', challenge.headers["WWW-Authenticate"]).group(1)
res = requests.post(url, data=body, headers={**headers, "Authorization": f"L402 {mac}:{preimage}"})
print(res.json()["nymbot"])

JavaScript

const url = "https://nymbot.ai/api/v1/images/generations";
const body = JSON.stringify({ model: "nano-banana", prompt: "a lighthouse at dusk", response_format: "b64_json" });
const headers = { "Content-Type": "application/json" };

const challenge = await fetch(url, { method: "POST", headers, body });
const www = challenge.headers.get("www-authenticate");

// The Payment scheme: echo every challenge parameter back with the preimage
const start = www.indexOf("Payment ");
const params = Object.fromEntries([...www.slice(start + 8).matchAll(/(\w+)="((?:[^"\\]|\\.)*)"/g)].map((m) => [m[1], m[2]]));
const { invoice } = JSON.parse(Buffer.from(params.request, "base64url").toString()).methodDetails;
const preimage = await payWithYourWallet(invoice);

const credential = Buffer.from(JSON.stringify({ challenge: params, payload: { preimage } })).toString("base64url");
const res = await fetch(url, { method: "POST", headers: { ...headers, Authorization: `Payment ${credential}` }, body });
console.log((await res.json()).nymbot, res.headers.get("payment-receipt"));

ບໍລິສັດທີ່ສ້າງຕັ້ງຂຶ້ນໃນ mppx ມີການປິ່ນປົວການຝຶກອົບຮົມ Lightning, ທ່ານສາມາດປິ່ນປົວການຝຶກອົບຮົມການຝຶກອົບຮົມການຝຶກອົບຮົມການຝຶກອົບຮົມການຝຶກອົບຮົມການຝຶກອົບຮົມ.

ວິດີໂອ

ຊື້ຂາຍ POST /videos ຄໍາຖາມ 202 ໃນຖານະເປັນ Keyed One, Plus A status_url: GET ມັນຖືກເຂົ້າລະຫັດແລະເຮັດວຽກສໍາລັບ 24 ຊົ່ວໂມງ, ໃນຂະນະທີ່ການເຮັດວຽກໄດ້ຮັບ.

{
  "id": "vid_...",
  "status": "in_progress",
  "status_url": "https://nymbot.ai/api/v1/videos/vid_...?exp=1790000000&sig=...",
  "nymbot": {
    "payment": "l402", "tier": "pro", "paid_sats": 4800, "charged_sats": 4800,
    "refund_token": "REFUND-5E0B..."
  }
}

ດາວໂຫລດ The refund_token ການທົບທວນຄືນທີ່ຜ່ານມາ: ມັນຖືກສະແດງໃຫ້ເຫັນພຽງແຕ່ໃນນີ້. ມັນແມ່ນ vacant ໃນເວລາທີ່ວິດີໂອ renders (GET /api/v1/l402/refunds ຄໍາຖາມ "status": "pending"); ຖ້າຫາກວ່າ render ໄດ້ບໍ່ໄດ້ຮັບການບັນທຶກ, ການຊໍາລະເງິນ landed ກ່ຽວກັບມັນ. URL ສະພາບອາກາດສະແດງໃຫ້ເຫັນ refund_sats ສໍາລັບການເຮັດວຽກທີ່ໄດ້ຮັບການຂົນສົ່ງ, ແຕ່ບໍ່ມີ token, ດັ່ງນັ້ນການຂົນສົ່ງ URL ສະພາບແວດລ້ອມບໍ່ມີການຂົນສົ່ງ. ການຄວບຄຸມ token ຍັງແກ້ໄຂການເຮັດວຽກທີ່ບໍ່ໄດ້ຮັບການກວດສອບ.

ດາວໂຫລດ

If a paid request fails and the provider invoiced Nymbot for the attempt, payment is retained and the error says so, with charged_sats, ເຊັ່ນດຽວກັນກັບຄໍາຮ້ອງສະຫມັກ Keyed. ຖ້າຫາກວ່າມັນບໍ່ໄດ້ຮັບການບັນທຶກ, ຄໍາຮ້ອງສະຫມັກແມ່ນມີ ລະຫັດ QR ຄ່າໃຊ້ຈ່າຍທີ່ທ່ານໄດ້ຮັບ:

{
  "error": {
    "message": "The image generator failed. Nothing was charged. Please try again. The 237 sats you paid are on refund token REFUND-...",
    "type": "api_error",
    "code": "upstream_error",
    "refund_token": "REFUND-0C15DBED145D59131BA70298A413ADEB3D9B9AB082C476EA70A5BD38FCA5DE6D",
    "refund_sats": 237,
    "refund_expires_at": "2026-10-30T12:00:00.000Z"
  }
}

ພາກສ່ວນທີ່ບໍ່ໄດ້ຮັບການນໍາໃຊ້ຈະໄດ້ຮັບການປັບປຸງຢ່າງງ່າຍດາຍ: ຖ້າຫາກວ່າທ່ານກໍາລັງຊອກຫາສໍາລັບສອງຮູບພາບແລະຫນຶ່ງບໍ່ໄດ້ຮັບການປັບປຸງ, ຄວາມປອດໄພຂອງຄໍາຮ້ອງສະຫມັກ nymbot Object ມີ token reimbursement ສໍາ ລັບ one missing; transcription whose length couldn’t be read up front is priced for the longest the file could be (ບໍ່ຫຼາຍກ່ວາ 30 ນາທີ), ແລະ differential ສໍາ ລັບ length real comes back as a reimbursement token; ຖ້າຫາກວ່າມັນຈະເປັນຫຼາຍກ່ວາ 30 ນາທີ, ມັນແມ່ນ rejected 413 ແລະການຊໍາລະເງິນທັງຫມົດໄດ້ຖືກຂັບຂື້ນ. Embeddings ດາວນ໌ໂຫລດສິ່ງທີ່ຄາດຄະເນດິນໄດ້ຂັບຂັບຂື້ນ. ວິດີໂອທີ່ບໍ່ໄດ້ຮັບການຊໍາລະເງິນໄດ້ຖືກຂັບຂ້າງຂວາງກັບ token ການຂັບຂ້າງຂວາງ.

ຊື່ຫຍໍ້ຂອງ : Nymbot Stores Only Its Hash, and It Expired After 30 Days

  • Pay ກັບມັນ. ດາວໂຫລດ Authorization: Bearer REFUND-… ຂ້າພະເຈົ້າສືບຕໍ່ໄດ້ຮັບການປະທັບໃຈກໍໂດຍການບໍລິການລູກຄ້າຂອງພວກເຮົາ. ຂໍຂອບໃຈຫຼາຍດັ່ງນັ້ນສໍາລັບທຸກສິ່ງທຸກຢ່າງrefund_token_sats ໃນ The nymbot Object). A token worth less than the request answers 402 refund_insufficientການດໍາເນີນການທີ່ບໍ່ໄດ້ຮັບການກວດສອບໄດ້ໄດ້ດໍາເນີນການທີ່ບໍ່ໄດ້ຮັບການກວດສອບໄດ້. ; A unbiled failure places the sats back on the same token.
  • ການທົບທວນຄືນ GET /api/v1/l402/refunds ມີ header ທີ່ແທ້ຈິງ {"sats": 237, "status": "open", "expires_at": "..."}.
  • ຫນຶ່ງ token ສາມາດຖືກນໍາໃຊ້ຫຼາຍກ່ວາ 60 ນາທີ.
  • ເຮັດໃຫ້ມັນກັບ nym. ຫນ້າທໍາອິດ / Paste it into ດາວນ໌ໂຫລດ Present ໃນ app Nymbot, ຫຼືໂທ POST /api/v1/l402/refunds/redeem ມີ A ຄໍາຮ້ອງສະຫມັກ ແລະ {"refund_token": "REFUND-...", "balance": "standard"} (ຫຼື "pro"ການຄາດຄະເນດິນຟ້າອິນເຕີເນັດແມ່ນການຄາດຄະເນດິນຟ້າອິນເຕີເນັດ. ການຄາດຄະເນດິນຟ້າອິນເຕີເນັດແມ່ນການຄາດຄະເນດິນຟ້າອິນເຕີເນັດ.

cURL

URL=https://nymbot.ai/api/v1/l402/refunds/redeem
BODY='{"refund_token":"REFUND-...","balance":"standard"}'
curl "$URL" \
  -H "Authorization: $(nostr_auth POST "$URL" "$BODY")" \
  -H "Content-Type: application/json" \
  -d "$BODY"

ຄໍາຖາມ

{ "data": { "credited": 23, "tier": "standard", "balance_credits": 123, "remaining_sats": 7 } }