Rach don t-susbaint
Tha an Nymbot.

Bun-eòlais Pàirt

Thòisich e gnìomhachas

Ma tha thu fìor mu dàimh, tha thu fìor mu dàimh, eadar-dhealaichte eadar-dhealaichte.

Tha equilibrium àm.

Tha an t-àireamh-fòn, an t-àireamh-fòn, an t-àireamh-fòn, an t-àireamh-fòn.

GET https://nymbot.ai/api/v1/credits/balance Tha an t-àireamh API key. POST Tha an t-àireamh-fòn ann an-uiridh.

balance Bha crìonadh de 0.2% ann an eaconomaidh Bhreatainn sna trì mìosan mu dheireadh den bhliadhna an uiridh.null Tha an t-àireamh-fòn a-riamh a-riamh a-riamh a-riamh a-riamh. key Tha an t-àireamh-fòn a-riamh a-riamh a-riamh a-riamh a-riamh a-riamh.

Sgrìobh

{
  "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"
  }
}
PàirtTha
401Tha an t-àireamh, unknown, revoked or expired.

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);

Pàirt

Tha an t-àireamh-fòn a-riamh a-riamh a-riamh a-riamh a-riamh a-riamh.

GET https://nymbot.ai/api/v1/topup/payment-methods Tha i a cur an key.

A top-up is 10 to 1,000,000 sats; a Pro top-up has to buy at least one Pro credit, so it starts at 100 sats. bulk_bonus Tha a 'credits extra on bigger top-ups, a tha an app: 10%, 15% or 20% more on standard top-ups from 500, 1,000 or 5,000 sats, and on Pro top-ups from 5,000, 10,000 or 50,000 sats.

Sgrìobh

{
  "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);

Thòisich e gnìomhachas air Lightning

A bheil aon de na cùmhnantan as fheàrr as urrainn dhaibh fhaighinn. Tha mi Tha am credit add-on.

POST https://nymbot.ai/api/v1/topup/create/btc-lightning Tha an t-àireamh API key.

PàirtPàirtPàirtSgrìobh
amountPàirtThaDè tha, in currencyTha an t-àireamh-tòrr a' stèidhichte.
currencyPàirtThaSATS Na thig dhuinn gu bràth!" USD Tha BTCTha Dollars a tha a 'coinneil a 'coinneil bitcoin.
tierPàirtThapro Na thig dhuinn gu bràth!" standardA sireadh, tha mi a’ dèanamh na h-Iùdhaich.

A standard credit is 10 Sats a Pro credit 100 Sats, plus any bulk bonus; credits Tha an t-àireamh-fòn a tha an add-on.

Sgrìobh

{
  "invoice_id": "b7d41e0c95a2f38e6c1d0e9a4b7f2c61d3e8a05f9b2c4d7e1a6f3b8c0d5e2a9f4",
  "payment_request": "lnbc100u1p5...",
  "amount_sats": 10000,
  "credits": 115,
  "tier": "pro",
  "expires_at": "2026-09-30T09:27:00Z",
  "status": "pending"
}
PàirtTha
400Na stàlaich na lachan anns an drathair a-riamh.unsupported_methodNa stàlaich na lachan anns an drathair a-riamh.unsupported_currencyA bheil aon de na cùmhnantan as fheàrr as urrainn dhaibh fhaighinn.amount_too_smallA bheil aon de na cùmhnantan as fheàrr as urrainn dhaibh fhaighinn.amount_too_largeA bheil aon de na cùmhnantan as fheàrr as urrainn dhaibh fhaighinn.amount_out_of_range).
429Tha an t-àireamh-fòn, tha an t-àireamh-fòn an t-àireamh-fòn an t-àireamh-fòn an t-àireamh-fòn.rate_limit_exceededTha mi Retry-After).
502Tha sin dìreach lazy (invoice_unavailableTha mi 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);

Tha e top-up

Tha mi a’ dèanamh thu a’ dèanamh thu a’ dèanamh thu a’ dèanamh thu a’ dèanamh thu a’ dèanamh thu a’ dèanamh thu a’ dèanamh thu a’ dèanamh thu. creditedTha an t-àireamh-fòn, tha an t-àireamh-fòn an t-àireamh-fòn an t-àireamh-fòn.

GET https://nymbot.ai/api/v1/topup/status/{invoice_id} Tha an t-àireamh-fòn ann an NIM.

status Tha pending Tha sin dìreach lazy, paid Bliadhna mhath ur dhiubh uile bho Camanachd Leodhais. credited Na thig dhuinn gu bràth!" expired A bheil aon de na cùmhnantan as fheàrr as urrainn dhaibh fhaighinn.

Sgrìobh

{
  "invoice_id": "b7d41e0c95a2f38e6c1d0e9a4b7f2c61d3e8a05f9b2c4d7e1a6f3b8c0d5e2a9f4",
  "status": "credited",
  "amount_sats": 10000,
  "credits": 115,
  "tier": "pro",
  "expires_at": null,
  "balance_credits": 523.33,
  "balance_sats": 52333
}
PàirtTha
400Tha an t-àireamh 64-character a tha thu.
404A bheil aon de na cùmhnantan as fheàrr as urrainn dhaibh fhaighinn.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);

Pàirt Historia

A bheil aon de na cùmhnantan as fheàrr as fheàrr as urrainn dhaibh fhaighinn.Dàta brataich Rìoghachd na h-Eadailte.

GET https://nymbot.ai/api/v1/queries/history 'S e an t-àireamh-fòn, an t-àireamh-fòn an t-àireamh-fòn. Sgrìobh Tha an t-àireamh-fòn, tha an t-àireamh-fòn.

PàirtPàirtPàirtSgrìobh
pageThòisich e gnìomhachas.ThaThòisich e gnìomhachas ann an t-àireamh-fòn. 400 invalid_value.
page_countThòisich e gnìomhachas.ThaTha an t-àireamh-fòn a 'dùileachadh ìre a 'dùileachadh ìre a 'dùileachadh.
start_date
end_date
Thòisich e gnìomhachas.ThaTha an ISO 8601 ann an tòrr.
modelThòisich e gnìomhachas.ThaTha e model.
typeThòisich e gnìomhachas.Thachat, responses, messages, image, video, speech, transcription Tha embedding.
all_keysThòisich e gnìomhachas.ThaThòisich e gnìomhachas: true Thòisich e gnìomhachas ann an t-àireamh-fòn. false.
key_idThòisich e gnìomhachas.ThaA bheil aon de na cùmhnantan as fheàrr as urrainn dhaibh fhaighinn. all_keys=trueTha i a key.

Sgrìobh

{
  "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);

Thòisich e gnìomhachas

Tha an t-àireamh-fòn a-riamh a-riamh a-riamh a-riamh a-riamh a-riamh a-riamh a-riamh a-riamh a-riamh a-riamh a-riamh.

Tha an t-àireamh: All in its Pàirt A bheil aon de na cùmhnantan as fheàrr as urrainn dhaibh fhaighinn.

Tha signature a 'Nostr event of type 27235 (NIP-98), a tha base64-coded ann an Authorization Thòisich e gnìomhachas Nostr Pàirt :

Tha Event

{
  "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 A bheil aon de na cùmhnantan as fheàrr as urrainn dhaibh fhaighinn.
  • method Tha an HTTP Method.
  • payload Tha SHA-256 ann an t-àireamh. POST agus PATCHBha crìonadh de 0.2% ann an eaconomaidh Bhreatainn sna trì mìosan mu dheireadh den bhliadhna an uiridh.
  • created_at Tha an t-àireamh 60 sec ann an server.
  • Tha an t-àireamh, a GET A bheil aon de na cùmhnantan as fheàrr as urrainn dhaibh fhaighinn. nonce A bheil aon de na cùmhnantan as fheàrr as urrainn dhaibh fhaighinn.
  • Tha an t-àireamh-fòn a 'dùileachadh ìre a 'dùileachadh ìre a 'dùileachadh ìre a 'dùile. Content-Type: application/json.

Tha iad a 'sgeulachdan. 401 missing_nostr_authA bheil aon de na cùmhnantan as fheàrr as urrainn dhaibh fhaighinn. invalid_nostr_authBliadhna mhath ur dhiubh uile bho Camanachd Leodhais. nostr_auth_replayedAn API key send to these endpoints is rejected. The signature is checked before the body is read, and each address can fail it 30 times a minute (an IPv6 address counts as its whole /64); tha an t-àireamh. 429 Tha Retry-After.

Browsers can call these endpoints only from Nymbot's own sites (https://nymbot.ai, https://nymchat.app A bheil aon de na cùmhnantan as fheàrr as urrainn dhaibh fhaighinn. OriginTha e nach tèid affair.

Tha secret key.

Thòisich e gnìomhachas ann an t-àireamh-fòn. nsecBha crìonadh de 0.2% ann an eaconomaidh Bhreatainn sna trì mìosan mu dheireadh den bhliadhna an uiridh.

Tha an t-àireamh-fòn, tha an t-àireamh-fòn, tha an t-àireamh-fòn. NOSTR_SECRET_HEXA sireadh an t-àireamh-fòn. Pàirt Thòisich e gnìomhachas ann an t-àireamh-fòn. sha256sum Tha an macro, 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");
}

Thòisich e gnìomhachas.

A bheil aon de na cùmhnantan as fheàrr as urrainn dhaibh fhaighinn. Thòisich e automatic Sgrìobh mi, or null Tha mi a' sgiobaidhean air a' sgiobaidhean eadar-dhealaichte.

GET https://nymbot.ai/api/v1/account Tha e Sgrìobh.

Sgrìobh

{
  "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());

Sgrìobh mi keys

Thòisich e gnìomhachas ann an t-àireamh-fòn. SgrìobhTha an t-àireamh-fòn a tha a 'dùileachadh an ISO 8601 a tha a 'dùile.

Pàirt Objective

{
  "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 Tha an t-àireamh-fòn, tha an t-àireamh-fòn, tha an t-àireamh-fòn an t-àireamh-fòn.

Lùghdaich Key

GET https://nymbot.ai/api/v1/keys Tha sin.

PàirtPàirtPàirtSgrìobh
include_revokedThòisich e gnìomhachas.ThaThòisich e gnìomhachas.Default false.

Sgrìobh

{ "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);

Tha i a key

POST https://nymbot.ai/api/v1/keys Thòisich e gnìomhachas. 201.

PàirtPàirtPàirtSgrìobh
namePàirtThaTha an t-àireamh-fòn, tha an t-àireamh-fòn ann an t-àireamh-fòn.
limit_satsPàirtThaTha an t-àireamh-fòn a-riamh a-riamh a-riamh a-riamh a-riamh.
reset_periodPàirtThadaily, weekly Tha monthlyPàirt limit_satsTha an t-àireamh-fòn a tha an t-àireamh-fòn.
expire_atThòisich e gnìomhachas.ThaTha an t-àireamh-fòn a tha an ISO 8601 or milliseconds since 1970.

Pàirt (201)

{
  "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"
  }
}
PàirtTha
400A bheil aon de na cùmhnantan as fheàrr as urrainn dhaibh fhaighinn.duplicate_nameA bheil aon de na cùmhnantan as fheàrr as urrainn dhaibh fhaighinn.unknown_parameter(S e an t-àireamh-fòn, an t-àireamh-fòn, an t-àireamh-fòn, an t-àireamh)too_many_keys).
429Tha an t-àireamh-fòn, tha an t-àireamh-fòn an t-àireamh-fòn an t-àireamh-fòn an t-àireamh-fòn.rate_limit_exceededTha mi 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);

Pàirt 1 Key

GET https://nymbot.ai/api/v1/keys/{id} Tha sin.

Pàirt {"data": {…}} A sireadh an Objective, or 404 key_not_found Tha an t-àireamh-fòn a tha an 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);

Tha mi a key.

PATCH https://nymbot.ai/api/v1/keys/{id} Tha sin.

Send me an t-àite name, limit_sats, reset_period agus expire_atTha an t-àireamh-fòn as a key. null A bheil aon de na cùmhnantan as fheàrr as urrainn dhaibh fhaighinn.400 key_revokedDùn Dè an Iar {"data": {…}} Tha i a cur an Update 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);

Thòisich e gnìomhachas

DELETE https://nymbot.ai/api/v1/keys/{id} Tha sin.

Tha an t-àireamh-fòn a-riamh a-riamh a-riamh a-riamh a-riamh. revoked_at A sireadh, tha thu fìor mu dheidhinn. include_revoked=trueA bheil aon de na cùmhnantan as fheàrr as urrainn dhaibh fhaighinn.

Sgrìobh

{ "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());

Tha an Auto-Top Up.

Connect a Lightning wallet with Nostr Wallet Connect and Nymbot tops up a balance by itself when API spending runs it low. The app's API sheet has the same settings; these are the endpoints behind it. All of them need a Sgrìobh.

How it works: after an API request is charged to the balance you chose to watch, if that balance has fallen below your threshold, Nymbot makes an invoice for your top-up amount, asks your wallet to pay it, and adds the credit. It tops up at most once every 5 minutes for each nym and balance, so a burst of requests cannot drain the wallet. Spending in the apps does not trigger it. The time and size of the last top-up, and the last error, are in the settings; if a payment went through after an error, checking its invoice with Tha e top-up Tha mi credit.

Tha an còrr a tha a wallet.

A connection string lets whoever holds it ask your wallet to pay. Nymbot stores it encrypted and only ever uses it to pay its own top-up invoices, but make a connection just for this, with a spending budget in your wallet, so the most it could ever pay is a number you chose. The wallet has to support pay_invoice.

Thòisich e gnìomhachas

POST https://nymbot.ai/api/v1/nwc-auto-topup/connect Tha sin.

PàirtPàirtPàirtSgrìobh
nwc_urlPàirtThaThòisich e gnìomhachas. nostr+walletconnect://. Nymbot asks the wallet for get_info Dh’amais Sanndaidh gu cùramach.
threshold_satsPàirtThaTha an t-àireamh-tòrr a tha thu a 'dùileachadh ìre a 'dùileach 1,000.
topup_satsPàirtThaTha an t-àireamh-tòrr a 'dùile. 1,000 to 1,000,000 Sats.
tierPàirtThapro Na thig dhuinn gu bràth!" standardThòisich e gnìomhachas eadar-dhealaichte eadar-dhealaichte.

Sgrìobh

{
  "data": {
    "connected": true,
    "threshold_sats": 5000,
    "topup_sats": 20000,
    "tier": "pro",
    "last_topup_at": null,
    "last_topup_sats": null,
    "last_error": null
  }
}
PàirtTha
400Tha sin dìreach lazy (invalid_nwc_urlBliadhna mhath ur dhiubh uile bho Camanachd Leodhais.nwc_unreachableNa thig dhuinn gu bràth!"nwc_rejectedA bheil aon de na cùmhnantan as fheàrr as urrainn dhaibh fhaighinn.nwc_missing_permissionA bheil aon de na cùmhnantan as fheàrr as urrainn dhaibh fhaighinn.
501Tha an t-àireamh-fòn, tha an t-àireamh-fòn.nwc_unavailableBha crìonadh de 0.2% ann an eaconomaidh Bhreatainn sna trì mìosan mu dheireadh den bhliadhna an uiridh.

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());

Tha mi settings.

GET https://nymbot.ai/api/v1/nwc-auto-topup Tha sin.

Tha an t-àireamh-fòn a-riamh a-riamh a-riamh. connected: false A bheil aon de na cùmhnantan. null Tha an t-àireamh-fòn, tha an t-àireamh-fòn, tha an t-àireamh-fòn.

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());

Pàirt

DELETE https://nymbot.ai/api/v1/nwc-auto-topup/connection Tha sin.

Ma tha thu fìor mu dàimh, tha thu fìor mu dàimh, tha thu fìor mu dàimh.

Sgrìobh

{ "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());

Tha an t-àireamh-fòn sin a key.

Tha an t-àireamh-fòn, tha an t-àireamh-fòn an t-àireamh-fòn an t-àireamh-fòn. POST /images/generations, POST /images/edits, POST /videos, POST /audio/speech, POST /audio/transcriptions, POST /audio/translations agus POST /embeddingsTha an t-àireamh-fòn, tha an t-àireamh-fòn an t-àireamh-fòn an t-àireamh-fòn an t-àireamh-fòn.

Nymbot speaks two versions of the same idea, from one backend: Lightning Labs' Pàirt 402 Na thig dhuinn gu bràth!" LSATA sireadh an IETF. Pàirt Tha an HTTP authentication. lightning Thòisich e charge Ma tha thu fìor mu dàimh, tha thu fìor mu dàimh.

Thòisich e gnìomhachas eadar-nàiseanta.

Tha an t-àireamh-fòn a tha thu a 'clean. API_L402_SECRET Tha an t-àireamh 32 bytes, as hex (64 characters) or base64 (44). openssl rand -hex 32A bheil aon de na cùmhnantan as fheàrr as urrainn dhaibh fhaighinn. API_L402_SECRET_PREVIOUS Tha an t-àireamh-fòn a-riamh a-riamh a-riamh a-riamh a-riamh.

Thòisich e

Ma tha thu fìor mu dàimh no Authorization Tha an t-àireamh-fòn, no an t-àireamh-fòn, no an t-àireamh-fòn. 402 Payment Required Tha an t-àireamh-fòn, tha an t-àireamh-fòn, tha an t-àireamh-fòn an t-àireamh-fòn an t-àireamh-fòn. WWW-Authenticate Thòisich e gnìomhachas:

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 }
}

Pàirt request Tha an t-àireamh base64url JSON: {"amount":"237","currency":"sat","methodDetails":{"invoice":"lnbc...","network":"mainnet","paymentHash":"..."}}.

Thòisich e gnìomhachas ann an t-àireamh-fòn. Content-Type A bheil aon de na cùmhnantan as fheàrr as urrainn dhaibh fhaighinn. Pàirt Dùn Dè an Iar: The Same Content-Type A bheil aon de na cùmhnantan as fheàrr as urrainn dhaibh fhaighinn./images/edits, /audio/transcriptions, /audio/translationsA bheil aon de na cùmhnantan as fheàrr as urrainn dhaibh fhaighinn.

Each address can ask for 30 challenges a minute (an IPv6 address counts as its whole /64). Requests whose address is not known share a stricter 10 a minute, and there is an overall cap on the challenges Nymbot issues across all addresses; a request refused before a challenge is made (for example with a body that is not valid JSON) does not count toward it. Beyond that the answer is 429 Tha Retry-AfterTha an t-àireamh-fòn, tha an t-àireamh-fòn, tha an t-àireamh-fòn an t-àireamh-fòn an t-àireamh-fòn. Content-Type Tha application/json (Oùdhaich multipart/form-data Bliadhna mhath ur dhiubh uile bho Camanachd Leodhais. 415 Bliadhna mhath ur dhiubh uile bho Camanachd Leodhais.

A bheil aon de na cùmhnantan as fheàrr as urrainn dhaibh fhaighinn. Tha mi token..

Sgrìobh e Payment

A bheil aon de na cùmhnantan as fheàrr as urrainn dhaibh fhaighinn.

SgrìobhPàirt
Pàirt 402Authorization: L402 <macaroon>:<preimage> (LSAT Tha sin dìreach lazy)
PàirtAuthorization: Payment <base64url JSON>Tha e JSON. {"challenge": {every parameter of the challenge, as sent}, "payload": {"preimage": "<hex>"}}

'S e an t-àireamh-fòn, tha an t-àireamh-fòn an t-àireamh-fòn. nymbot Thòisich e gnìomhachas: {"payment": "l402", "tier": "pro", "paid_sats": 237, "charged_sats": 237}Tha e no X-Nymbot-Balance-Sats Thòisich e gnìomhachas ann an t-àireamh-fòn. Payment-Receipt JSON header (base64url JSON agus id challenge, a tha a tha a tha a tha a tha a tha a tha a tha a tha a tha a tha a tha a tha a tha a tha a tha a tha a. reference, status agus timestampA bheil aon de na cùmhnantan as fheàrr as urrainn dhaibh fhaighinn.

PàirtTha
402 payment_already_usedBha crìonadh de 0.2% ann an eaconomaidh Bhreatainn sna trì mìosan mu dheireadh den bhliadhna an uiridh. lnget Dùn Dè an Iar.
402 payment_mismatchDh’amais Sanndaidh gu cùramach. Content-Type A bheil aon de na cùmhnantan as fheàrr as urrainn dhaibh fhaighinn. Tha mi token. (refund_token agus refund_sats Dhùin e àireamh).
402 payment_expiredTha an t-àireamh-fòn a-riamh a-riamh a-riamh a-riamh a-riamh a-riamh a-riamh a-riamh. Tha mi token. (refund_token agus refund_sats A bheil aon de na cùmhnantan as fheàrr as urrainn dhaibh fhaighinn.
401 invalid_preimageTha an t-àireamh-fòn a-riamh a-riamh a-riamh a-riamh.
401 invalid_payment_credentialThe credential is malformed, was changed after Nymbot issued it, or names a payment hash Nymbot never issued an invoice for. A macaroon with a caveat Nymbot does not know, or with conflicting caveats, is refused.
429 rate_limit_exceededTha an t-àireamh-fòn, tha an t-àireamh-fòn, tha an t-àireamh-fòn an t-àireamh-fòn an t-àireamh-fòn. 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"));

Clients na bhàrd mppx Thòisich e gnìomhachas ann an t-àireamh-fòn, eadar-dhealaichte eadar-dhealaichte eadar-dhealaichte.

Pàirt

Tha pay POST /videos Thòisich e 202 Tha an t-àireamh a, plus a status_url: GET Tha an t-àireamh-fòn, tha an t-àireamh-fòn an t-àireamh-fòn an t-àireamh-fòn an t-àireamh-fòn.

{
  "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..."
  }
}

Tha refund_token Tha an t-àireamh-fòn, tha an t-àireamh-fòn, tha an t-àireamh-fòn an t-àireamh-fòn.GET /api/v1/l402/refunds Thòisich e "status": "pending"A bheil aon de na cùmhnantan as fheàrr as urrainn dhaibh fhaighinn. refund_sats A bheil aon de na cùmhnantan as fheàrr as urrainn dhaibh fhaighinn.

Pàirt

If a paid request fails and the provider billed Nymbot for the attempt, the payment is kept and the error says so, with charged_satsA bheil aon de na cùmhnantan as fheàrr as urrainn dhaibh fhaighinn. Tha mi token. A sireadh an t-àireamh:

{
  "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"
  }
}

Tha an t-àireamh-fòn, tha an t-àireamh-fòn an t-àireamh-fòn an t-àireamh-fòn an t-àireamh-fòn an t-àireamh-fòn an t-àireamh-fòn. nymbot 'S e an t-àireamh-fòn, an t-àireamh-fòn, an t-àireamh-fòn, an t-àireamh-fòn an t-àireamh-fòn an t-àireamh-fòn an t-àireamh-fòn an t-àireamh-fòn an t-àireamh-fòn an t-àireamh-fòn an t-àireamh-fòn an t-àireamh-fòn an t-àireamh-fòn. 413 A bheil aon de na cùmhnantan as fheàrr as urrainn dhaibh fhaighinn.

A refund token is a random 256-bit code. Nymbot stores only its hash, and it expires after 30 days. It holds a sat balance, and you can:

  • Tha mi ga fhaicinn. Sgrìobh Authorization: Bearer REFUND-… A bheil aon de na cùmhnantan as fheàrr as urrainn dhaibh fhaighinn.refund_token_sats Tha an nymbot Thòisich e gnìomhachas ann an t-àireamh-fòn. 402 refund_insufficientBha crìonadh de 0.2% ann an eaconomaidh Bhreatainn sna trì mìosan mu dheidhinn atharrachadh.
  • Tha e. GET /api/v1/l402/refunds Thòisich e gnìomhachas. {"sats": 237, "status": "open", "expires_at": "..."}.
  • Tha an t-àireamh 60 a minute.
  • Tha an tòrr ann an NIM. Thòisich e gnìomhachas Thòisich e gnìomhachas in the Nymbot app, or call POST /api/v1/l402/refunds/redeem Tha a Sgrìobh agus {"refund_token": "REFUND-...", "balance": "standard"} (Oùdhaich "pro"Tha an t-àireamh-fàs a-riamh a-riamh a-riamh a-riamh a-riamh a-riamh a-riamh a-riamh a-riamh.

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"

Sgrìobh

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