{
  "openapi": "3.1.0",
  "info": {
    "title": "Headroom API",
    "version": "1",
    "description": "Read-only data on AI usage-limit resets, limit changes and news. No key. GET/HEAD only. Poll no more often than every 5 minutes. Data: Headroom, please link back."
  },
  "servers": [
    {
      "url": "/"
    }
  ],
  "paths": {
    "/api/v1/snapshot": {
      "get": {
        "summary": "Everything in one call",
        "parameters": [
          {
            "name": "If-None-Match",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "ETag": {
                "schema": {
                  "type": "string"
                }
              },
              "Cache-Control": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Envelope"
                    }
                  ],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Snapshot"
                    }
                  }
                }
              }
            }
          },
          "304": {
            "description": "Not modified (If-None-Match matched)"
          },
          "405": {
            "description": "Method not allowed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Data not built yet",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/vendors": {
      "get": {
        "summary": "Vendor list",
        "parameters": [
          {
            "name": "If-None-Match",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "ETag": {
                "schema": {
                  "type": "string"
                }
              },
              "Cache-Control": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Envelope"
                    }
                  ],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Vendor"
                      }
                    }
                  }
                }
              }
            }
          },
          "304": {
            "description": "Not modified (If-None-Match matched)"
          },
          "405": {
            "description": "Method not allowed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Data not built yet",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/status": {
      "get": {
        "summary": "Status per vendor",
        "parameters": [
          {
            "name": "If-None-Match",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "ETag": {
                "schema": {
                  "type": "string"
                }
              },
              "Cache-Control": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Envelope"
                    }
                  ],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Status"
                      }
                    }
                  }
                }
              }
            }
          },
          "304": {
            "description": "Not modified (If-None-Match matched)"
          },
          "405": {
            "description": "Method not allowed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Data not built yet",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/news": {
      "get": {
        "summary": "News, models and releases",
        "parameters": [
          {
            "name": "If-None-Match",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "ETag": {
                "schema": {
                  "type": "string"
                }
              },
              "Cache-Control": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Envelope"
                    }
                  ],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/News"
                      }
                    }
                  }
                }
              }
            }
          },
          "304": {
            "description": "Not modified (If-None-Match matched)"
          },
          "405": {
            "description": "Method not allowed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Data not built yet",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/limits": {
      "get": {
        "summary": "Limit changes",
        "parameters": [
          {
            "name": "If-None-Match",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "ETag": {
                "schema": {
                  "type": "string"
                }
              },
              "Cache-Control": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Envelope"
                    }
                  ],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Limit"
                      }
                    }
                  }
                }
              }
            }
          },
          "304": {
            "description": "Not modified (If-None-Match matched)"
          },
          "405": {
            "description": "Method not allowed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Data not built yet",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/feeds/all.atom": {
      "get": {
        "summary": "Atom feed",
        "parameters": [
          {
            "name": "If-None-Match",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "ETag": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/atom+xml": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "304": {
            "description": "Not modified (If-None-Match matched)"
          },
          "405": {
            "description": "Method not allowed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Data not built yet",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/feeds/all.rss": {
      "get": {
        "summary": "RSS feed",
        "parameters": [
          {
            "name": "If-None-Match",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "ETag": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/rss+xml": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "304": {
            "description": "Not modified (If-None-Match matched)"
          },
          "405": {
            "description": "Method not allowed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Data not built yet",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/badge/{vendor}.json": {
      "get": {
        "summary": "Shields.io endpoint badge",
        "parameters": [
          {
            "name": "vendor",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9-]+$"
            },
            "description": "Vendor id from /api/v1/vendors"
          },
          {
            "name": "If-None-Match",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "ETag": {
                "schema": {
                  "type": "string"
                }
              },
              "Cache-Control": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Badge"
                }
              }
            }
          },
          "304": {
            "description": "Not modified (If-None-Match matched)"
          },
          "405": {
            "description": "Method not allowed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Data not built yet",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/openapi.json": {
      "get": {
        "summary": "This document",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Envelope": {
        "type": "object",
        "properties": {
          "api_version": {
            "type": "string"
          },
          "generated_at": {
            "type": "string",
            "format": "date-time"
          },
          "data": {},
          "attribution": {
            "type": "string"
          }
        },
        "required": [
          "api_version",
          "generated_at",
          "data",
          "attribution"
        ],
        "additionalProperties": true
      },
      "Vendor": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "maker": {
            "type": "string"
          },
          "order": {
            "type": "integer"
          },
          "mark": {
            "type": "string"
          },
          "categories": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "reset",
                "limit",
                "model",
                "news",
                "release"
              ]
            }
          },
          "credits": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "name": {
                  "type": "string"
                },
                "url": {
                  "type": "string"
                }
              },
              "required": [
                "name",
                "url"
              ],
              "additionalProperties": true
            }
          }
        },
        "required": [
          "id",
          "name",
          "maker",
          "order",
          "mark",
          "categories",
          "credits"
        ],
        "additionalProperties": true
      },
      "Reset": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "at": {
            "type": "string",
            "format": "date-time"
          },
          "class": {
            "type": "string",
            "enum": [
              "banked",
              "regular"
            ]
          },
          "scope": {
            "type": [
              "string",
              "null"
            ]
          },
          "text": {
            "type": [
              "string",
              "null"
            ]
          },
          "url": {
            "type": [
              "string",
              "null"
            ]
          },
          "author": {
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "id",
          "at",
          "class",
          "scope",
          "text",
          "url",
          "author"
        ],
        "additionalProperties": true
      },
      "Limit": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "vendor": {
            "type": "string"
          },
          "at": {
            "type": "string",
            "format": "date-time"
          },
          "text": {
            "type": [
              "string",
              "null"
            ]
          },
          "url": {
            "type": [
              "string",
              "null"
            ]
          },
          "author": {
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "id",
          "vendor",
          "at",
          "text",
          "url",
          "author"
        ],
        "additionalProperties": true
      },
      "News": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "vendor": {
            "type": "string"
          },
          "category": {
            "type": "string",
            "enum": [
              "model",
              "news",
              "release"
            ]
          },
          "at": {
            "type": "string",
            "format": "date-time"
          },
          "title": {
            "type": "string"
          },
          "text": {
            "type": [
              "string",
              "null"
            ]
          },
          "url": {
            "type": [
              "string",
              "null"
            ]
          },
          "product": {
            "type": [
              "string",
              "null"
            ]
          },
          "version": {
            "type": [
              "string",
              "null"
            ]
          },
          "model_id": {
            "type": [
              "string",
              "null"
            ]
          },
          "notes_url": {
            "type": [
              "string",
              "null"
            ],
            "description": "The source's notes page for this model; null when absent. Always an absolute http(s) link."
          },
          "date_only": {
            "type": "boolean",
            "description": "The source gives a day, not a time: show the day of `at` only (its clock is a placeholder)."
          },
          "no_date": {
            "type": "boolean",
            "description": "The day in `at` is only an estimate (the source gives just the month): do not print a date."
          }
        },
        "required": [
          "id",
          "vendor",
          "category",
          "at",
          "title",
          "text",
          "url",
          "product",
          "version",
          "model_id",
          "notes_url",
          "date_only",
          "no_date"
        ],
        "additionalProperties": true
      },
      "Status": {
        "type": "object",
        "properties": {
          "vendor": {
            "type": "string"
          },
          "last_reset": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Reset"
              },
              {
                "type": "null"
              }
            ]
          },
          "recent_resets": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Reset"
            }
          },
          "stats": {
            "type": "object",
            "properties": {
              "count": {
                "type": "integer"
              },
              "days_since": {
                "type": [
                  "number",
                  "null"
                ]
              },
              "mean_gap_days": {
                "type": [
                  "number",
                  "null"
                ]
              },
              "longest_gap_days": {
                "type": [
                  "number",
                  "null"
                ]
              },
              "since": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "count",
              "days_since",
              "mean_gap_days",
              "longest_gap_days",
              "since"
            ],
            "additionalProperties": true
          },
          "next_reset": {
            "oneOf": [
              {
                "type": "object",
                "properties": {
                  "state": {
                    "type": "string",
                    "enum": [
                      "scheduled",
                      "announced"
                    ]
                  },
                  "at": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "url": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "author": {
                    "type": [
                      "string",
                      "null"
                    ]
                  }
                },
                "required": [
                  "state",
                  "at",
                  "url",
                  "author"
                ],
                "additionalProperties": true
              },
              {
                "type": "null"
              }
            ]
          },
          "reset_chance": {
            "oneOf": [
              {
                "type": "object",
                "properties": {
                  "percent": {
                    "type": "number"
                  },
                  "level": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "expires_at": {
                    "type": [
                      "string",
                      "null"
                    ]
                  }
                },
                "required": [
                  "percent",
                  "level",
                  "expires_at"
                ],
                "additionalProperties": true
              },
              {
                "type": "null"
              }
            ]
          },
          "freshness": {
            "type": "object",
            "properties": {
              "state": {
                "type": "string",
                "enum": [
                  "fresh",
                  "stale",
                  "unknown"
                ]
              },
              "checked_at": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "stale_after_minutes": {
                "type": "integer"
              }
            },
            "required": [
              "state",
              "checked_at",
              "stale_after_minutes"
            ],
            "additionalProperties": true
          }
        },
        "required": [
          "vendor",
          "last_reset",
          "recent_resets",
          "stats",
          "next_reset",
          "reset_chance",
          "freshness"
        ],
        "additionalProperties": true
      },
      "Snapshot": {
        "type": "object",
        "properties": {
          "vendors": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Vendor"
            }
          },
          "status": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Status"
            }
          },
          "news": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/News"
            }
          },
          "limits": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Limit"
            }
          },
          "links": {
            "type": "object",
            "additionalProperties": true,
            "description": "telegram, channel, github, contact, add_to_group, donate, other_bots"
          },
          "sources": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "name": {
                  "type": "string"
                },
                "url": {
                  "type": "string"
                },
                "covers": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                },
                "note": {
                  "type": "string"
                }
              },
              "required": [
                "name",
                "url",
                "covers"
              ],
              "additionalProperties": true
            }
          }
        },
        "required": [
          "vendors",
          "status",
          "news",
          "limits",
          "links",
          "sources"
        ],
        "additionalProperties": true
      },
      "Badge": {
        "type": "object",
        "properties": {
          "schemaVersion": {
            "type": "integer"
          },
          "label": {
            "type": "string"
          },
          "message": {
            "type": "string"
          },
          "color": {
            "type": "string"
          },
          "cacheSeconds": {
            "type": "integer"
          }
        },
        "required": [
          "schemaVersion",
          "label",
          "message",
          "color",
          "cacheSeconds"
        ],
        "additionalProperties": true
      },
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "enum": [
                  "not_built",
                  "rate_limited",
                  "method_not_allowed"
                ]
              },
              "message": {
                "type": "string"
              }
            },
            "required": [
              "code",
              "message"
            ],
            "additionalProperties": true
          }
        },
        "required": [
          "error"
        ],
        "additionalProperties": true
      }
    }
  }
}
