{
  "openapi": "3.1.0",
  "info": {
    "title": "NanoTracker API for agents",
    "version": "1.0.0",
    "summary": "XNO daily rates (free) and wallet plus/minus (paid in Nano via x402).",
    "description": "Rates are for use inside your own calculations, no redistribution. Sources: Binance daily close XNO/USDT (NANOBTC x BTCUSDT until 2019-04-02, NANOUSDT until 2022-01-24), Yahoo Finance for currencies. Not tax advice. Human page: https://nanotracker.app/agents/",
    "contact": {"url": "https://nanotracker.app/agents/"}
  },
  "servers": [{"url": "https://nanotracker.app"}],
  "paths": {
    "/api/v1/kurs": {
      "get": {
        "operationId": "xnoRate",
        "summary": "Price of 1 XNO on one day (UTC). Free.",
        "parameters": [
          {"name": "datum", "in": "query", "required": false, "description": "YYYY-MM-DD, from 2018-02-02. Omitted: current rate (provisional). Alias: date.", "schema": {"type": "string", "format": "date"}},
          {"name": "waehrung", "in": "query", "required": false, "description": "Currency, default USD. Alias: currency.", "schema": {"$ref": "#/components/schemas/Currency"}}
        ],
        "responses": {
          "200": {"description": "Rate", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Rate"}}}},
          "400": {"$ref": "#/components/responses/Error"},
          "404": {"$ref": "#/components/responses/Error"},
          "429": {"$ref": "#/components/responses/Error"}
        }
      }
    },
    "/api/v1/kurse": {
      "get": {
        "operationId": "xnoRates",
        "summary": "Daily prices of 1 XNO for a period of at most 31 days. Free.",
        "parameters": [
          {"name": "von", "in": "query", "required": true, "description": "First day YYYY-MM-DD. Alias: from.", "schema": {"type": "string", "format": "date"}},
          {"name": "bis", "in": "query", "required": true, "description": "Last day YYYY-MM-DD, at most 30 days after von. Alias: to.", "schema": {"type": "string", "format": "date"}},
          {"name": "waehrung", "in": "query", "required": false, "schema": {"$ref": "#/components/schemas/Currency"}}
        ],
        "responses": {
          "200": {"description": "Rates", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Rates"}}}},
          "400": {"$ref": "#/components/responses/Error"},
          "429": {"$ref": "#/components/responses/Error"}
        }
      }
    },
    "/api/v1/wallet-pnl": {
      "post": {
        "operationId": "walletPnl",
        "summary": "Plus/minus of one Nano address (private holding, FIFO). USD 0.002 per call, paid in XNO via x402; first call per IP free.",
        "parameters": [
          {"name": "X-Payment-Hash", "in": "header", "required": false, "description": "Hash of your send block to the agent wallet (64 hex). Omit for the free call or to get the price.", "schema": {"type": "string", "pattern": "^[0-9A-Fa-f]{64}$"}}
        ],
        "requestBody": {
          "required": true,
          "content": {"application/json": {"schema": {"type": "object", "required": ["adresse"], "properties": {"adresse": {"type": "string", "description": "Public Nano address nano_... (alias: address)"}}}}}
        },
        "responses": {
          "200": {"description": "Totals of the start page", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Pnl"}}}},
          "202": {"description": "Address is being read from the ledger. Repeat the same request; neither the free call nor the payment is used up."},
          "400": {"$ref": "#/components/responses/Error"},
          "402": {"description": "Payment required, or payment not valid (field reason).", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/PaymentRequired"}}}},
          "409": {"description": "This payment hash has already been used."},
          "413": {"description": "Address has too many blocks for this service."},
          "429": {"$ref": "#/components/responses/Error"},
          "502": {"description": "Public Nano nodes busy, try again later."}
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Currency": {"type": "string", "enum": ["USD", "USDT", "EUR", "TZS", "CHF", "GBP", "KES", "UGX", "ZAR", "INR", "BRL", "JPY", "AUD", "CAD", "NZD", "SGD", "HKD", "CNY", "NGN", "MXN", "SEK", "NOK", "PLN", "AED"], "default": "USD"},
      "Source": {"type": "object", "properties": {"xno": {"type": "string"}, "fx": {"type": "string"}, "methode": {"type": "string"}, "anbieter": {"type": "string"}}},
      "Rate": {"type": "object", "properties": {
        "datum": {"type": "string", "format": "date"},
        "waehrung": {"type": "string"},
        "xno_kurs": {"type": ["string", "null"], "description": "Price of 1 XNO, decimal string"},
        "vorlaeufig": {"type": "boolean", "description": "true while the day is not closed"},
        "gefuellt": {"type": "boolean", "description": "XNO leg carried forward from the previous day"},
        "quelle": {"$ref": "#/components/schemas/Source"},
        "hinweis": {"type": "string"}}},
      "Rates": {"type": "object", "properties": {
        "von": {"type": "string"}, "bis": {"type": "string"}, "waehrung": {"type": "string"},
        "tage": {"type": "array", "items": {"type": "object", "properties": {"datum": {"type": "string"}, "xno_kurs": {"type": ["string", "null"]}, "vorlaeufig": {"type": "boolean"}}}},
        "quelle": {"$ref": "#/components/schemas/Source"}, "hinweis": {"type": "string"}}},
      "Pnl": {"type": "object", "properties": {
        "adresse": {"type": "string"},
        "annahme": {"type": "string"},
        "uebersicht": {"type": "object", "description": "bestand (XNO), wert_heute, einstand, unrealisiert, realisiert, gesamt (per currency), naechste_haltefrist {datum, menge, tage}, anteil_steuerfrei_prozent, counts"},
        "durchschnitt_kaufkurs": {"type": ["object", "null"], "description": "Average buy price per XNO, per currency"},
        "kurs_heute": {"type": "object"},
        "freigrenze": {"type": "array"},
        "hinweis": {"type": "string"},
        "datenschutz": {"type": "string"},
        "trial": {"type": "boolean"}, "freeCallsLeft": {"type": "integer"},
        "payment_hash": {"type": "string"}, "paid_raw": {"type": "string"}, "retrieval": {"type": "boolean"}}},
      "PaymentRequired": {"type": "object", "properties": {
        "x402Version": {"type": "integer"},
        "error": {"type": "string"},
        "reason": {"type": "string"},
        "accepts": {"type": "array", "items": {"type": "object", "properties": {
          "scheme": {"const": "nano-block"}, "network": {"const": "nano"}, "asset": {"const": "XNO"},
          "payTo": {"type": "string"}, "maxAmountRequired": {"type": "string", "description": "raw"},
          "amountXNO": {"type": "string"}, "amountUSD": {"type": ["string", "null"]},
          "minimumXNO": {"type": "string"}, "priceAnchor": {"type": "string"},
          "deepLink": {"type": "string"}, "resource": {"type": "string"}}}}}}
    },
    "responses": {
      "Error": {"description": "Error", "content": {"application/json": {"schema": {"type": "object", "properties": {"fehler": {"type": "string"}}}}}}
    }
  }
}
