{
  "openapi": "3.1.0",
  "info": {
    "title": "Bay Geeks Speed Test API",
    "version": "1.0.0",
    "summary": "The four endpoints behind the internet speed test at https://baygeeks.com/speed-test/.",
    "description": "Measures latency, download and upload throughput between a client and the nearest Cloudflare edge. No authentication. Requests carrying an Origin header other than https://baygeeks.com, or a Sec-Fetch-Site header other than same-origin or none, are refused with 403, so the API works from the speed test page and from non-browser clients but not from other websites. Every endpoint is rate limited per IP address (about 3,000 requests a minute). Responses are never cached.",
    "contact": {
      "name": "Bay Geeks, LLC",
      "url": "https://baygeeks.com/developers/",
      "email": "support@baygeeks.com"
    }
  },
  "externalDocs": {
    "description": "Bay Geeks API documentation",
    "url": "https://baygeeks.com/developers/"
  },
  "servers": [
    { "url": "https://baygeeks.com/speed-test/api" }
  ],
  "paths": {
    "/ping": {
      "get": {
        "operationId": "ping",
        "summary": "Empty response for timing a round trip",
        "description": "Returns 204 with no body. Time repeated calls to measure latency and jitter. Also serves as a health check.",
        "responses": {
          "204": { "description": "The service is up." },
          "403": { "$ref": "#/components/responses/Forbidden" },
          "429": { "$ref": "#/components/responses/RateLimited" }
        }
      }
    },
    "/meta": {
      "get": {
        "operationId": "getMeta",
        "summary": "Facts about the caller's connection",
        "description": "The Cloudflare data center that answered and what it knows about the connection. Any field can be null.",
        "responses": {
          "200": {
            "description": "Connection facts.",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/Meta" }
              }
            }
          },
          "403": { "$ref": "#/components/responses/Forbidden" },
          "429": { "$ref": "#/components/responses/RateLimited" }
        }
      }
    },
    "/down": {
      "get": {
        "operationId": "download",
        "summary": "Download N bytes of random data",
        "description": "Streams incompressible random bytes for measuring download throughput. HEAD returns the headers only.",
        "parameters": [
          {
            "name": "bytes",
            "in": "query",
            "required": false,
            "description": "How many bytes to send. Missing or invalid values send 1 MiB; anything above 16 MiB is capped at 16 MiB.",
            "schema": { "type": "integer", "minimum": 1, "maximum": 16777216, "default": 1048576 }
          }
        ],
        "responses": {
          "200": {
            "description": "The requested number of random bytes.",
            "headers": {
              "Content-Length": { "schema": { "type": "integer" } }
            },
            "content": {
              "application/octet-stream": {
                "schema": { "type": "string", "contentMediaType": "application/octet-stream" }
              }
            }
          },
          "403": { "$ref": "#/components/responses/Forbidden" },
          "429": { "$ref": "#/components/responses/RateLimited" }
        }
      }
    },
    "/up": {
      "post": {
        "operationId": "upload",
        "summary": "Upload a body and get its size back",
        "description": "Reads and discards the request body, then reports how many bytes arrived. Use it to measure upload throughput. Bodies over 8 MiB are cut off with 413.",
        "requestBody": {
          "required": false,
          "content": {
            "application/octet-stream": {
              "schema": { "type": "string", "contentMediaType": "application/octet-stream" }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Bytes received.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["bytes"],
                  "properties": { "bytes": { "type": "integer", "minimum": 0 } }
                }
              }
            }
          },
          "403": { "$ref": "#/components/responses/Forbidden" },
          "413": {
            "description": "The body was larger than 8 MiB.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": { "type": "string", "const": "too large" },
                    "bytes": { "type": "integer" }
                  }
                }
              }
            }
          },
          "429": { "$ref": "#/components/responses/RateLimited" }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Meta": {
        "type": "object",
        "properties": {
          "colo": { "type": ["string", "null"], "description": "IATA code of the Cloudflare data center, e.g. TPA." },
          "city": { "type": ["string", "null"] },
          "region": { "type": ["string", "null"] },
          "country": { "type": ["string", "null"], "description": "ISO 3166-1 alpha-2 country code." },
          "isp": { "type": ["string", "null"], "description": "Organization that owns the caller's network." },
          "asn": { "type": ["integer", "null"] },
          "ip": { "type": ["string", "null"], "description": "The caller's public IP address." },
          "protocol": { "type": ["string", "null"], "description": "HTTP version, e.g. HTTP/2." },
          "tls": { "type": ["string", "null"], "description": "TLS version, e.g. TLSv1.3." }
        }
      },
      "Error": {
        "type": "object",
        "required": ["error"],
        "properties": { "error": { "type": "string" } }
      }
    },
    "responses": {
      "Forbidden": {
        "description": "A cross-site browser request (Origin or Sec-Fetch-Site from another site).",
        "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } }
      },
      "RateLimited": {
        "description": "Too many requests from this IP address in the last minute.",
        "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } }
      }
    }
  }
}
