{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/coinrithm-com/json-schema/coinrithm-com-spot-reference-response-schema.json",
  "title": "SpotReferenceResponse",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/coinrithm-com-spot-api-openapi.yml#/components/schemas/SpotReferenceResponse",
  "type": "object",
  "additionalProperties": true,
  "required": [
    "version",
    "policyVersion",
    "coin",
    "evaluatedAt",
    "referenceOnly",
    "preferredSource",
    "stream",
    "fallback",
    "verification"
  ],
  "properties": {
    "version": {
      "type": "integer",
      "const": 1
    },
    "policyVersion": {
      "type": "string"
    },
    "coin": {
      "type": "object",
      "required": [
        "coinId",
        "symbol",
        "name"
      ],
      "properties": {
        "coinId": {
          "type": "string"
        },
        "symbol": {
          "type": "string"
        },
        "name": {
          "type": "string"
        }
      }
    },
    "evaluatedAt": {
      "type": "string",
      "format": "date-time",
      "description": "Server time at which ages and expiries were checked (after all I/O)."
    },
    "referenceOnly": {
      "type": "boolean",
      "const": true
    },
    "preferredSource": {
      "type": [
        "string",
        "null"
      ],
      "enum": [
        "binance_stream",
        "rest_consensus",
        null
      ],
      "description": "`binance_stream` when `stream.observation` is present, else\n`rest_consensus` when a stored price exists, else null. A\npreference between two values in different units, not a\nconversion or an executable price.\n"
    },
    "stream": {
      "$ref": "#/$defs/SpotReferenceStream"
    },
    "fallback": {
      "$ref": "#/$defs/SpotReferenceFallback"
    },
    "verification": {
      "type": "object",
      "required": [
        "identityCheckedAt",
        "mappingUpdatedAt",
        "policyUpdatedAt",
        "policyMode"
      ],
      "properties": {
        "identityCheckedAt": {
          "type": "string",
          "format": "date-time",
          "description": "Database statement time of the coin/mapping/policy read."
        },
        "mappingUpdatedAt": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time"
        },
        "policyUpdatedAt": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time"
        },
        "policyMode": {
          "type": [
            "string",
            "null"
          ],
          "description": "Enabled per-coin source policy mode (`allow` / `deny`), null when none."
        }
      }
    }
  },
  "$defs": {
    "SpotPriceTiming": {
      "type": "object",
      "description": "Source-vs-row timing of the spot price (optional: absent on older API\nversions). Informational only: `freshness`, `eligible` and the write\npath's mark guard still measure the row WRITE time and are unchanged.\n`sourceObservedAt` is a venue snapshot/ticker time, NOT a last-trade\ntime and NOT a per-fill receipt.\n",
      "required": [
        "rowWrittenAt",
        "sourceObservedAt",
        "sourceAgeSeconds",
        "writeLagSeconds",
        "coverage",
        "basis"
      ],
      "properties": {
        "rowWrittenAt": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time",
          "description": "When CoinRithm wrote the price row; the same instant as freshness.asOf. null when there is no row."
        },
        "sourceObservedAt": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time",
          "description": "The OLDEST venue snapshot time among the winning price cluster's\nmembers that carry one. null when no member carries one.\n"
        },
        "sourceAgeSeconds": {
          "type": [
            "number",
            "null"
          ],
          "description": "max(0, now - sourceObservedAt), the same clamp as freshness.ageSeconds."
        },
        "writeLagSeconds": {
          "type": [
            "number",
            "null"
          ],
          "description": "rowWrittenAt - sourceObservedAt in seconds, SIGNED. Negative means\nthe venue's clock ran ahead of CoinRithm's (the writer admits up to\n5 minutes); it is never clamped.\n"
        },
        "coverage": {
          "type": "string",
          "enum": [
            "recorded",
            "not_recorded",
            "no_row"
          ],
          "description": "recorded: at least one cluster member carried a source time. It may\nbe PARTIAL: members without a stamp (e.g. Kraken, Gate.io) are not\nrepresented. not_recorded: the row has no source time (unknown,\nnever fresh). no_row: there is no price row.\n"
        },
        "basis": {
          "type": "string",
          "const": "venue_snapshot_time"
        }
      }
    },
    "SpotReferenceFallback": {
      "type": "object",
      "required": [
        "basis",
        "currency",
        "status",
        "priceUsd",
        "priceTiming",
        "expiresAt"
      ],
      "properties": {
        "basis": {
          "type": "string",
          "const": "stored_rest_consensus"
        },
        "currency": {
          "type": "string",
          "const": "USD"
        },
        "status": {
          "type": "string",
          "enum": [
            "fresh",
            "stale",
            "unavailable"
          ],
          "description": "fresh = stored row written at most 120 s before evaluatedAt; unavailable = no positive stored price."
        },
        "priceUsd": {
          "type": [
            "number",
            "null"
          ]
        },
        "priceTiming": {
          "$ref": "#/$defs/SpotPriceTiming"
        },
        "expiresAt": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time",
          "description": "Row write time + 120 s; null when there is no row."
        }
      }
    },
    "SpotReferenceObservation": {
      "type": "object",
      "additionalProperties": true,
      "required": [
        "venue",
        "market",
        "basis",
        "pair",
        "base",
        "quoteCurrency",
        "price",
        "quoteVolume24h",
        "eventAt",
        "statisticsCloseAt",
        "receivedAt",
        "lastTradeAt",
        "localPriceChangedAt",
        "capturedAt",
        "expiresAt",
        "universeVerifiedAt",
        "universeRevision",
        "connectionGeneration"
      ],
      "properties": {
        "venue": {
          "type": "string",
          "const": "binance"
        },
        "market": {
          "type": "string",
          "const": "spot"
        },
        "basis": {
          "type": "string",
          "const": "24h_ticker_last",
          "description": "Last price of Binance's rolling 24h ticker, not a last-trade receipt."
        },
        "pair": {
          "type": "string"
        },
        "base": {
          "type": "string"
        },
        "quoteCurrency": {
          "type": "string",
          "const": "USDT"
        },
        "price": {
          "type": "number",
          "description": "Price in USDT (not USD)."
        },
        "quoteVolume24h": {
          "type": "number",
          "description": "24h quote volume in USDT."
        },
        "eventAt": {
          "type": "string",
          "format": "date-time",
          "description": "Venue event time of the ticker."
        },
        "statisticsCloseAt": {
          "type": "string",
          "format": "date-time",
          "description": "Close of the venue's 24h statistics window."
        },
        "receivedAt": {
          "type": "string",
          "format": "date-time",
          "description": "When CoinRithm received the ticker."
        },
        "lastTradeAt": {
          "type": "null",
          "description": "Not available from this feed; always null."
        },
        "localPriceChangedAt": {
          "type": "string",
          "format": "date-time",
          "description": "When CoinRithm last saw this price change."
        },
        "capturedAt": {
          "type": "string",
          "format": "date-time",
          "description": "When the snapshot holding this ticker was written."
        },
        "expiresAt": {
          "type": "string",
          "format": "date-time",
          "description": "Earliest instant at which any input passes its age limit (10 s per stamp, 10 min for universe metadata)."
        },
        "universeVerifiedAt": {
          "type": "string",
          "format": "date-time"
        },
        "universeRevision": {
          "type": "string",
          "pattern": "^[a-f0-9]{64}$",
          "description": "Provenance of the collector's pair cohort."
        },
        "connectionGeneration": {
          "type": "integer",
          "minimum": 0
        }
      }
    },
    "SpotReferenceStream": {
      "type": "object",
      "required": [
        "status",
        "reason",
        "observation"
      ],
      "properties": {
        "status": {
          "type": "string",
          "enum": [
            "available",
            "unavailable"
          ]
        },
        "reason": {
          "type": [
            "string",
            "null"
          ],
          "description": "null when available. Otherwise one code: `inactive_coin`,\n`mapping_unavailable`, `mapping_ambiguous`, `mapping_suppressed`,\n`policy_denied`, `clock_regression`, `disabled`,\n`redis_unavailable`, `missing`, `invalid_snapshot`,\n`disconnected`, `expired_snapshot`, `expired_metadata`,\n`symbol_not_captured`, `identity_mismatch`, `expired_observation`.\nTreat unknown codes as unavailable.\n"
        },
        "observation": {
          "anyOf": [
            {
              "$ref": "#/$defs/SpotReferenceObservation"
            },
            {
              "type": "null"
            }
          ]
        }
      }
    }
  }
}