{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://docs.anon.inc/schemas/railgun-liveness-history.v1.schema.json",
  "title": "Anon Railgun liveness history (beta)",
  "description": "BETA. The body of GET https://api.anon.inc/api/v1/railgun/liveness/history. Fields, values and the shape may change without notice, with no notice period and no deprecation or sunset commitment. This schema is deliberately permissive: it describes today's response, not a promise, and it does not close any set of values. Clients should ignore unknown fields and values. Up to 14 days of Anon's own monitor's published statuses for the Railgun services Anon depends on, in fixed-length buckets, one character each. It is not a measurement of Railgun itself, not official Railgun status and not a safe-to-transact signal. Reference: https://docs.anon.inc/reference/railgun-liveness-history. Today's behavior that JSON Schema cannot express: every row's buckets string has (to - from) / bucketSeconds + 1 characters, so all rows have the same length; from and to are aligned to bucketSeconds; the rows are the same ones, in the same order, as GET https://api.anon.inc/api/v1/railgun/liveness; each (service, chainId) pair appears at most once.",
  "type": "object",
  "required": ["schemaVersion", "generatedAt", "bucketSeconds", "retentionDays", "from", "to", "rows"],
  "additionalProperties": true,
  "properties": {
    "schemaVersion": {
      "description": "The contract version of this endpoint. 1 today. It may change while the API is in beta; a client that does not know the value should treat the history as unreadable rather than guess.",
      "type": "integer",
      "minimum": 1,
      "examples": [1]
    },
    "generatedAt": {
      "description": "When the stored history was last written (not when it was served).",
      "allOf": [{ "$ref": "#/definitions/timestamp" }]
    },
    "bucketSeconds": {
      "description": "The length of one bucket in seconds. 300 today.",
      "type": "integer",
      "minimum": 1,
      "examples": [300]
    },
    "retentionDays": {
      "description": "The most history kept, in days. 14 today. A history is shorter than this until the monitor has recorded for that long: there is no backfill.",
      "type": "integer",
      "minimum": 1,
      "examples": [14]
    },
    "from": {
      "description": "The start of the first bucket, buckets[0]. Aligned to bucketSeconds. It is the first bucket the monitor ever recorded, or the start of the retention window if that is later.",
      "allOf": [{ "$ref": "#/definitions/timestamp" }]
    },
    "to": {
      "description": "The start of the last bucket, the one still filling. Its character can still change.",
      "allOf": [{ "$ref": "#/definitions/timestamp" }]
    },
    "rows": {
      "description": "One object per service and scope. Waku is the only shared row (chainId null).",
      "type": "array",
      "items": { "$ref": "#/definitions/row" }
    }
  },
  "definitions": {
    "timestamp": {
      "description": "UTC with a literal trailing Z: YYYY-MM-DDTHH:mm:ssZ, with optional fractional seconds (generatedAt has milliseconds).",
      "type": "string",
      "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(\\.[0-9]{1,9})?Z$",
      "examples": ["2026-10-06T14:03:11.402Z", "2026-10-06T14:00:00Z"]
    },
    "uptimeValue": {
      "description": "Uptime over a window: c / (c + k + d + u), from 0 to 1 and rounded to 4 decimals, or null when the window has fewer than 12 known buckets (one hour). null is not 0 and not 1.",
      "type": ["number", "null"],
      "minimum": 0,
      "maximum": 1
    },
    "row": {
      "type": "object",
      "required": ["service", "chainId", "buckets", "uptime"],
      "additionalProperties": true,
      "properties": {
        "service": {
          "description": "ppoi, indexer, subsquid, broadcasters and waku today. Not a closed set: new services may be added without notice. Ignore services you do not use.",
          "type": "string",
          "minLength": 1,
          "examples": ["ppoi", "indexer", "subsquid", "broadcasters", "waku"]
        },
        "chainId": {
          "description": "A chain ID, or null for a row that is not per chain (waku today). New chains may be added without notice. 11155111 (Sepolia) is a test network.",
          "type": ["integer", "null"]
        },
        "buckets": {
          "description": "One character per bucket from from to to inclusive, oldest first. Known today: c current, k catching-up, d degraded, u unavailable (the worst known status, by severity u over d over k over c, that lasted at least 60 seconds in total during the bucket, counting time in worse statuses toward it; shorter blips do not count and the bucket shows c); ? unknown (no evidence); . unmonitored; - no data (the monitor was not running or recorded no sample). Not a closed set: treat a character you do not know as no data for that bucket only.",
          "type": "string",
          "examples": ["cccccccccccccccckcccccccc"]
        },
        "uptime": {
          "description": "Uptime over the last 24 hours, 7 days and 14 days, clipped to the history that exists. Buckets with ?, . or - are left out. Other windows may be added.",
          "type": "object",
          "required": ["24h", "7d", "14d"],
          "additionalProperties": true,
          "properties": {
            "24h": { "$ref": "#/definitions/uptimeValue" },
            "7d": { "$ref": "#/definitions/uptimeValue" },
            "14d": { "$ref": "#/definitions/uptimeValue" }
          }
        }
      }
    }
  },
  "examples": [
    {
      "schemaVersion": 1,
      "generatedAt": "2026-10-06T14:03:11.402Z",
      "bucketSeconds": 300,
      "retentionDays": 14,
      "from": "2026-10-06T12:00:00Z",
      "to": "2026-10-06T14:00:00Z",
      "rows": [
        {
          "service": "ppoi",
          "chainId": 1,
          "buckets": "cccccccccccccccckcccccccc",
          "uptime": { "24h": 0.96, "7d": 0.96, "14d": 0.96 }
        },
        {
          "service": "waku",
          "chainId": null,
          "buckets": "cccccc------ccccccccccccc",
          "uptime": { "24h": 1, "7d": 1, "14d": 1 }
        }
      ]
    }
  ]
}
