{
  "openapi": "3.1.1",
  "info": {
    "title": "Burrows Tools API",
    "version": "1.0.0",
    "summary": "Two small read-only endpoints that serve this site's own pages, plus a health check.",
    "description": "The public HTTP endpoints behind Burrows Tools (https://burrows.tools). Everything else on the site runs in the visitor's browser; these are the only server-side routes there are.\n\n## Usage terms\n\n- These endpoints exist to serve the pages on this site. They are documented so that the site is legible to a person or an agent reading it, not to offer a public data service.\n- There is no SLA and no support commitment. Availability, response shapes, limits and the existence of a route may change without notice, and a route may be withdrawn.\n- No bulk or automated harvesting. /api/youtube-transcript fetches from YouTube on this site's behalf, so a client looping over video ids spends this site's request budget and can get its egress throttled or blocked upstream — a cost the caller never sees. Light, interactive use is welcome; scripted extraction is not.\n- Traffic that looks like harvesting may be rate-limited, blocked, or answered with an error, under the acceptable-use section of the Terms of Service.\n- No CORS headers are sent, on purpose. A browser on another origin cannot read these responses; that is a deliberate limit, not an oversight to work around.\n- Whatever /api/youtube-transcript returns is material YouTube published, and YouTube's own terms govern what you may do with it.\n\nFull documentation, with worked examples: https://burrows.tools/api",
    "termsOfService": "https://burrows.tools/terms",
    "contact": {
      "name": "Burrows Tools",
      "email": "burrowsapps@gmail.com",
      "url": "https://burrows.tools/api"
    }
  },
  "servers": [
    {
      "url": "https://burrows.tools",
      "description": "Production"
    }
  ],
  "externalDocs": {
    "url": "https://burrows.tools/api",
    "description": "Human documentation, with the usage terms and worked examples"
  },
  "paths": {
    "/api/geo": {
      "get": {
        "operationId": "getGeo",
        "summary": "The caller's approximate location, from Cloudflare's connection metadata.",
        "description": "Answers with what the network says about whoever asked: address, municipality, region, postal code, country, coordinates and time zone. Everything comes from the connection itself — Cloudflare's request metadata plus the CF-Connecting-IP header — so there is no third-party geolocation service between the caller and the answer.\n\nThe city is resolved from the coordinates rather than taken from Cloudflare's city label, because the two disagree: the label names the town a provider routes a connection through and the coordinates name a point. The citySource field says which one answered, and any failure in that lookup falls back to the label rather than to an error.\n\nThe answer is different for every caller, so it is never cached, and no Access-Control-Allow-Origin header is sent — a page on another origin cannot read it.",
        "tags": [
          "Caller location"
        ],
        "parameters": [],
        "responses": {
          "200": {
            "description": "The caller's location. This route has no failure mode of its own.",
            "headers": {
              "Cache-Control": {
                "description": "How long this answer may be reused. Per-visitor and transient answers are never stored.",
                "schema": {
                  "type": "string",
                  "enum": [
                    "no-store"
                  ]
                }
              },
              "Vary": {
                "description": "The response varies by caller at one URL. Stated for any cache that ignores no-store.",
                "schema": {
                  "type": "string",
                  "enum": [
                    "CF-Connecting-IP"
                  ]
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "description": "The caller's approximate location.",
                  "additionalProperties": false,
                  "required": [
                    "ip",
                    "city",
                    "region",
                    "regionCode",
                    "postalCode",
                    "country",
                    "latitude",
                    "longitude",
                    "timezone",
                    "source",
                    "citySource"
                  ],
                  "properties": {
                    "ip": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "description": "The caller's public address, IPv4 or IPv6, from CF-Connecting-IP. Null when no address was available."
                    },
                    "city": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "description": "Municipality. Named from the coordinates when they resolve, otherwise from Cloudflare's own city label — see citySource."
                    },
                    "region": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "description": "State, province, or the local first-level division."
                    },
                    "regionCode": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "description": "Subdivision code where one is published, e.g. \"TX\"."
                    },
                    "postalCode": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "description": "Zip or postal code. Frequently absent outside the United States."
                    },
                    "country": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "description": "ISO 3166-1 alpha-2 country code. Null when Cloudflare reports its XX placeholder; T1 means the request arrived over Tor."
                    },
                    "latitude": {
                      "type": [
                        "number",
                        "null"
                      ],
                      "description": "Degrees north, IP-derived."
                    },
                    "longitude": {
                      "type": [
                        "number",
                        "null"
                      ],
                      "description": "Degrees east, IP-derived."
                    },
                    "timezone": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "description": "IANA time zone name, e.g. \"America/New_York\"."
                    },
                    "source": {
                      "type": "string",
                      "enum": [
                        "cloudflare",
                        "stub"
                      ],
                      "description": "\"cloudflare\" for a real edge lookup. \"stub\" is the local development placeholder — obviously fake values, published rather than hidden so nobody mistakes them for real ones. A deployed response is always \"cloudflare\"."
                    },
                    "citySource": {
                      "type": "string",
                      "enum": [
                        "coordinates",
                        "label"
                      ],
                      "description": "\"coordinates\" means the city, region, region code, postal code and country were resolved from the latitude/longitude pair; \"label\" means they are Cloudflare's own city label, which names the town a network routes through rather than the town the caller is in. The lookup is cached and coarse, and any failure falls back to the label."
                    }
                  }
                },
                "examples": {
                  "coordinates": {
                    "summary": "Coordinates named a different municipality than the label did",
                    "value": {
                      "ip": "203.0.113.24",
                      "city": "Lake Mary",
                      "region": "Florida",
                      "regionCode": "FL",
                      "postalCode": "32746",
                      "country": "US",
                      "latitude": 28.76,
                      "longitude": -81.32,
                      "timezone": "America/New_York",
                      "source": "cloudflare",
                      "citySource": "coordinates"
                    }
                  },
                  "label": {
                    "summary": "The lookup added nothing, so Cloudflare's own label stands",
                    "value": {
                      "ip": "203.0.113.24",
                      "city": "Sanford",
                      "region": "Florida",
                      "regionCode": "FL",
                      "postalCode": "32771",
                      "country": "US",
                      "latitude": 28.8,
                      "longitude": -81.27,
                      "timezone": "America/New_York",
                      "source": "cloudflare",
                      "citySource": "label"
                    }
                  },
                  "stub": {
                    "summary": "Local development, where the edge has no location to give",
                    "value": {
                      "ip": "127.0.0.1",
                      "city": "Localhost",
                      "region": "Development",
                      "regionCode": null,
                      "postalCode": "00000",
                      "country": "XX",
                      "latitude": 0,
                      "longitude": 0,
                      "timezone": "UTC",
                      "source": "stub",
                      "citySource": "label"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/youtube-transcript": {
      "get": {
        "operationId": "getYoutubeTranscript",
        "summary": "The caption track YouTube publishes for a video, as plain text.",
        "description": "Takes a video id or any YouTube URL and returns the video's caption track as prose. It powers the /youtube-transcript tool page and nothing else.\n\nThis is the one route that talks to a third party, and it does so on this site's behalf: a single request here becomes up to four requests to YouTube from this site's egress. That is why the usage terms above are not boilerplate — a client looping over ids is spending someone else's budget and standing. Successful answers and definitive failures are cached, so a repeated lookup of the same id is close to free; a stream of fresh ids is not.\n\nYouTube changes these surfaces often, so every failure is a typed error rather than an exception. Branch on the error field, never on message, and treat upstream-changed as transient — it means nothing upstream said anything recognisable about the video, which covers an outage, a timeout and a consent wall alike.",
        "tags": [
          "YouTube transcript"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "query",
            "required": false,
            "description": "A video id, or any YouTube URL: watch links, youtu.be short links, Shorts, embeds and live URLs all parse.",
            "schema": {
              "type": "string"
            },
            "example": "dQw4w9WgXcQ"
          },
          {
            "name": "url",
            "in": "query",
            "required": false,
            "description": "Accepted as an alias for id, and read only when id is absent. Supply one of the two: with neither, the answer is bad-id.",
            "schema": {
              "type": "string"
            },
            "example": "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
          }
        ],
        "responses": {
          "200": {
            "description": "A caption track was found and converted to text.",
            "headers": {
              "Cache-Control": {
                "description": "How long this answer may be reused. Per-visitor and transient answers are never stored.",
                "schema": {
                  "type": "string",
                  "enum": [
                    "public, max-age=86400"
                  ]
                }
              },
              "X-Transcript-Cache": {
                "description": "Whether this answer came from the Worker cache. Absent on bad-id, which is refused before any cache is consulted.",
                "schema": {
                  "type": "string",
                  "enum": [
                    "HIT",
                    "MISS"
                  ]
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "description": "A transcript.",
                  "additionalProperties": false,
                  "required": [
                    "id",
                    "languageCode",
                    "language",
                    "automatic",
                    "text"
                  ],
                  "properties": {
                    "id": {
                      "type": "string",
                      "description": "The 11-character video id the request resolved to."
                    },
                    "languageCode": {
                      "type": "string",
                      "description": "BCP 47 code of the caption track that was used, e.g. \"en\"."
                    },
                    "language": {
                      "type": "string",
                      "description": "The track's name as YouTube publishes it."
                    },
                    "automatic": {
                      "type": "boolean",
                      "description": "True when the track was machine-generated: no punctuation, and occasional nonsense."
                    },
                    "text": {
                      "type": "string",
                      "description": "The caption text, joined into plain prose. No timings."
                    }
                  }
                },
                "examples": {
                  "transcript": {
                    "summary": "An automatic English track",
                    "value": {
                      "id": "dQw4w9WgXcQ",
                      "languageCode": "en",
                      "language": "English (auto-generated)",
                      "automatic": true,
                      "text": "We're no strangers to love You know the rules and so do I"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Neither id nor url parsed as a YouTube video. Refused before any network or cache work.",
            "headers": {
              "Cache-Control": {
                "description": "How long this answer may be reused. Per-visitor and transient answers are never stored.",
                "schema": {
                  "type": "string",
                  "enum": [
                    "no-store"
                  ]
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "description": "A typed failure. Every failure of this route has this shape.",
                  "additionalProperties": false,
                  "required": [
                    "error",
                    "message"
                  ],
                  "properties": {
                    "error": {
                      "type": "string",
                      "enum": [
                        "bad-id",
                        "no-captions",
                        "video-unavailable",
                        "upstream-changed"
                      ],
                      "description": "Which failure this is. Stable; safe to branch on."
                    },
                    "message": {
                      "type": "string",
                      "description": "One sentence for a person to read. Wording may change at any time — branch on error, not on this."
                    }
                  }
                },
                "examples": {
                  "bad-id": {
                    "summary": "bad-id",
                    "value": {
                      "error": "bad-id",
                      "message": "That does not look like a YouTube link or video id. Paste the full URL from your browser, or the 11-character id."
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "The video is playable and has no caption track. Held briefly so a repeated probe is not a repeated fetch. YouTube will not serve the video — private, removed, or members-only. Held as briefly as no-captions.",
            "headers": {
              "Cache-Control": {
                "description": "How long this answer may be reused. Per-visitor and transient answers are never stored.",
                "schema": {
                  "type": "string",
                  "enum": [
                    "public, max-age=600"
                  ]
                }
              },
              "X-Transcript-Cache": {
                "description": "Whether this answer came from the Worker cache. Absent on bad-id, which is refused before any cache is consulted.",
                "schema": {
                  "type": "string",
                  "enum": [
                    "HIT",
                    "MISS"
                  ]
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "description": "A typed failure. Every failure of this route has this shape.",
                  "additionalProperties": false,
                  "required": [
                    "error",
                    "message"
                  ],
                  "properties": {
                    "error": {
                      "type": "string",
                      "enum": [
                        "bad-id",
                        "no-captions",
                        "video-unavailable",
                        "upstream-changed"
                      ],
                      "description": "Which failure this is. Stable; safe to branch on."
                    },
                    "message": {
                      "type": "string",
                      "description": "One sentence for a person to read. Wording may change at any time — branch on error, not on this."
                    }
                  }
                },
                "examples": {
                  "no-captions": {
                    "summary": "no-captions",
                    "value": {
                      "error": "no-captions",
                      "message": "This video has no caption track, so there is nothing to transcribe. Creators can turn captions off, and very new, very short, or music-only videos often have none."
                    }
                  },
                  "video-unavailable": {
                    "summary": "video-unavailable",
                    "value": {
                      "error": "video-unavailable",
                      "message": "YouTube will not serve this video. Private and members-only videos cannot be transcribed; unlisted ones can, if you have the link."
                    }
                  }
                }
              }
            }
          },
          "502": {
            "description": "Nothing upstream said anything recognisable about this video. Transient, and never cached — retrying later is the right response.",
            "headers": {
              "Cache-Control": {
                "description": "How long this answer may be reused. Per-visitor and transient answers are never stored.",
                "schema": {
                  "type": "string",
                  "enum": [
                    "no-store"
                  ]
                }
              },
              "X-Transcript-Cache": {
                "description": "Whether this answer came from the Worker cache. Absent on bad-id, which is refused before any cache is consulted.",
                "schema": {
                  "type": "string",
                  "enum": [
                    "HIT",
                    "MISS"
                  ]
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "description": "A typed failure. Every failure of this route has this shape.",
                  "additionalProperties": false,
                  "required": [
                    "error",
                    "message"
                  ],
                  "properties": {
                    "error": {
                      "type": "string",
                      "enum": [
                        "bad-id",
                        "no-captions",
                        "video-unavailable",
                        "upstream-changed"
                      ],
                      "description": "Which failure this is. Stable; safe to branch on."
                    },
                    "message": {
                      "type": "string",
                      "description": "One sentence for a person to read. Wording may change at any time — branch on error, not on this."
                    }
                  }
                },
                "examples": {
                  "upstream-changed": {
                    "summary": "upstream-changed",
                    "value": {
                      "error": "upstream-changed",
                      "message": "YouTube did not return anything we recognise. This usually means they have changed their page again — it is not something you did."
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/health": {
      "get": {
        "operationId": "getHealth",
        "summary": "Liveness check: 200 and a two-field body if the Worker is answering.",
        "description": "Returns 200 with a tiny JSON body whenever the Worker is running. It reads nothing, fetches nothing, and touches no cache, so it costs one object and one JSON.stringify per request and cannot itself be the thing that is broken.\n\nIt is referenced from the API catalog as each endpoint's status link. It reports liveness only: it says the Worker answered, not that YouTube is reachable or that any particular route is healthy. Nothing about the request is echoed back, and no environment or configuration value is exposed.",
        "tags": [
          "Health"
        ],
        "parameters": [],
        "responses": {
          "200": {
            "description": "The Worker is answering.",
            "headers": {
              "Cache-Control": {
                "description": "How long this answer may be reused. Per-visitor and transient answers are never stored.",
                "schema": {
                  "type": "string",
                  "enum": [
                    "no-store"
                  ]
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "description": "Liveness.",
                  "additionalProperties": false,
                  "required": [
                    "status",
                    "buildId"
                  ],
                  "properties": {
                    "status": {
                      "type": "string",
                      "enum": [
                        "ok"
                      ],
                      "description": "Always \"ok\". The route does no work that could fail, so a non-200 here means the Worker itself is not answering — which is the only thing this endpoint can usefully tell you."
                    },
                    "buildId": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "description": "Identifies the deployed build when the runtime exposes one; null when it does not. Opaque — do not parse it."
                    }
                  }
                },
                "examples": {
                  "ok": {
                    "summary": "A deployed Worker",
                    "value": {
                      "status": "ok",
                      "buildId": "Hs8t2nJqQ1"
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}
