{
  "openapi": "3.1.0",
  "info": {
    "title": "check-host.one API",
    "version": "1.0.0",
    "description": "Run ping, TCP ping, HTTP, traceroute and DNS checks from measurement servers in 100+ countries. No key needed. Rate limits: about 20 checks per minute per client, 200 per day per client, and 30 per minute per target; over-limit requests get 429 with Retry-After. AI agents can use the MCP server at https://check-host.one/mcp instead.",
    "contact": { "url": "https://check-host.one/docs" }
  },
  "servers": [{ "url": "https://check-host.one" }],
  "externalDocs": { "url": "https://check-host.one/docs#api" },
  "paths": {
    "/api/v1/measurements": {
      "post": {
        "operationId": "createMeasurement",
        "summary": "Start a check",
        "description": "Starts a check and returns its id. Poll GET /api/v1/measurements/{id} for results.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/MeasurementRequest" },
              "examples": {
                "ping": { "value": { "type": "ping", "target": "example.com", "limit": 5, "measurementOptions": { "packets": 3 } } },
                "tcpPing": { "value": { "type": "ping", "target": "example.com", "measurementOptions": { "protocol": "TCP", "port": 443 } } },
                "http": { "value": { "type": "http", "target": "example.com", "locations": [{ "country": "DE" }], "measurementOptions": { "protocol": "HTTPS", "request": { "method": "HEAD", "path": "/" } } } }
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Check started",
            "content": { "application/json": { "schema": { "type": "object", "properties": { "id": { "type": "string" }, "probesCount": { "type": "integer" } } } } }
          },
          "400": { "$ref": "#/components/responses/Error" },
          "429": { "$ref": "#/components/responses/Error" }
        }
      }
    },
    "/api/v1/measurements/{id}": {
      "get": {
        "operationId": "getMeasurement",
        "summary": "Poll a check",
        "description": "Poll about once a second until status is not in-progress. A finished check carries resultSlug, its permanent link at https://check-host.one/r/{resultSlug}.",
        "parameters": [{ "name": "id", "in": "path", "required": true, "schema": { "type": "string" } }],
        "responses": {
          "200": { "description": "Measurement", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Measurement" } } } },
          "404": { "$ref": "#/components/responses/Error" }
        }
      }
    },
    "/api/v1/results/{slug}": {
      "get": {
        "operationId": "getSavedResult",
        "summary": "Get a saved result",
        "description": "A finished check, kept for 90 days.",
        "parameters": [{ "name": "slug", "in": "path", "required": true, "schema": { "type": "string" } }],
        "responses": {
          "200": { "description": "Saved result", "content": { "application/json": { "schema": { "type": "object" } } } },
          "404": { "$ref": "#/components/responses/Error" }
        }
      }
    },
    "/api/v1/hostinfo": {
      "get": {
        "operationId": "getHostInfo",
        "summary": "ASN, operator and location of a host",
        "parameters": [{ "name": "target", "in": "query", "description": "Hostname or IP. Omit for the caller's own address.", "schema": { "type": "string" } }],
        "responses": {
          "200": { "description": "Host info", "content": { "application/json": { "schema": { "type": "object" } } } },
          "400": { "$ref": "#/components/responses/Error" }
        }
      }
    },
    "/api/v1/probes": {
      "get": {
        "operationId": "listProbes",
        "summary": "Available measurement server locations",
        "responses": { "200": { "description": "Probe locations", "content": { "application/json": { "schema": { "type": "array", "items": { "type": "object", "properties": { "location": { "type": "object" } } } } } } } }
      }
    },
    "/api/v1/stats": {
      "get": {
        "operationId": "getStats",
        "summary": "Total, today and 7-day check counts",
        "responses": { "200": { "description": "Stats", "content": { "application/json": { "schema": { "type": "object" } } } } }
      }
    },
    "/api/health": {
      "get": {
        "operationId": "health",
        "summary": "Liveness",
        "responses": { "200": { "description": "OK", "content": { "application/json": { "schema": { "type": "object", "properties": { "status": { "type": "string", "const": "ok" } } } } } } }
      }
    }
  },
  "components": {
    "schemas": {
      "MeasurementRequest": {
        "type": "object",
        "required": ["type", "target"],
        "properties": {
          "type": { "type": "string", "enum": ["ping", "http", "traceroute", "dns"] },
          "target": { "type": "string", "description": "Hostname or IP." },
          "limit": { "type": "integer", "minimum": 1, "maximum": 25, "default": 5, "description": "Number of measurement servers." },
          "locations": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "country": { "type": "string", "description": "ISO 3166-1 alpha-2 code." },
                "magic": { "type": "string", "description": "Free-form: country, city, continent, ASN or network name." }
              }
            }
          },
          "measurementOptions": {
            "type": "object",
            "description": "Per type. ping: protocol (ICMP|TCP), port, packets (1-16). http: protocol (HTTP|HTTPS|HTTP2), port, request {method, path}. traceroute: protocol (ICMP|UDP|TCP), port. dns: query {type}, resolver, protocol (UDP|TCP)."
          }
        }
      },
      "Measurement": {
        "type": "object",
        "properties": {
          "id": { "type": "string" },
          "type": { "type": "string" },
          "status": { "type": "string", "enum": ["in-progress", "finished"] },
          "target": { "type": "string" },
          "resultSlug": { "type": "string" },
          "results": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "probe": { "type": "object", "description": "city, country, network, asn, ..." },
                "result": { "type": "object", "description": "status (finished|failed|offline|in-progress), rawOutput, and per type: stats {min, avg, max, loss}, statusCode, timings, hops, answers." }
              }
            }
          }
        }
      }
    },
    "responses": {
      "Error": {
        "description": "Error",
        "content": {
          "application/json": {
            "schema": { "type": "object", "properties": { "error": { "type": "object", "properties": { "type": { "type": "string" }, "message": { "type": "string" } } } } }
          }
        }
      }
    }
  }
}
