{
  "openapi": "3.1.0",
  "info": {
    "title": "Who reads the web API",
    "version": "1.0.0",
    "description": "Check whether a web request comes from the AI agent or crawler it claims to be, and read what is known about each agent. Open and free; no key.",
    "license": {
      "name": "CC BY 4.0",
      "url": "https://creativecommons.org/licenses/by/4.0/"
    }
  },
  "servers": [
    {
      "url": "https://whoreadsthe.com"
    }
  ],
  "externalDocs": {
    "description": "Documentation",
    "url": "https://whoreadsthe.com/api"
  },
  "paths": {
    "/api/v1/identify": {
      "post": {
        "operationId": "identifyRequest",
        "summary": "Check which agent a request claims to be and the strongest check it passes",
        "description": "What you send is used for the check and is not stored. Signatures and the Cloudflare verified-bot label are not checked.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "userAgent",
                  "ip"
                ],
                "properties": {
                  "userAgent": {
                    "type": "string",
                    "maxLength": 1024,
                    "description": "The request's User-Agent header value."
                  },
                  "ip": {
                    "type": "string",
                    "description": "The IPv4 or IPv6 address the request came from."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The verdict",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IdentifyResult"
                }
              }
            }
          },
          "400": {
            "description": "The body is not valid",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "405": {
            "description": "Only POST is accepted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "The body is larger than 2,048 bytes",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Over 60 calls a minute from this address",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Paused because the daily budget is nearly used",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/course/runs": {
      "post": {
        "operationId": "startTestRun",
        "summary": "Start a test course run",
        "responses": {
          "201": {
            "description": "The run: its code, test addresses, result address and closing time",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "405": {
            "description": "Only POST is accepted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Over 5 runs a minute from this address",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Daily limit of 100 runs reached, or paused because the budget is under pressure",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/course/runs/{run}": {
      "get": {
        "operationId": "testRunResult",
        "summary": "The result of a test course run",
        "parameters": [
          {
            "name": "run",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[a-z2-7]{26}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The result",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "404": {
            "description": "No run with that code",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Over 300 calls a minute from this address",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Paused for open runs because the daily budget is nearly used",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/course/runs/{run}/codes": {
      "post": {
        "operationId": "confirmCodes",
        "summary": "Check reference codes an agent reported",
        "parameters": [
          {
            "name": "run",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[a-z2-7]{26}$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "codes"
                ],
                "properties": {
                  "codes": {
                    "type": "array",
                    "maxItems": 10,
                    "items": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The pages provably read",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "confirmed": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad body or more than 10 codes",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No run with that code",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "The run has closed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "The body is larger than 2,048 bytes",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "More than 20 submissions for this run, or over 300 calls a minute from this address",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/agents": {
      "get": {
        "operationId": "listAgents",
        "summary": "List every agent in the registry",
        "responses": {
          "200": {
            "description": "The registry",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "429": {
            "description": "Over 300 calls a minute from this address",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/agents/{id}": {
      "get": {
        "operationId": "agentProfile",
        "summary": "One agent's documented facts, observed behaviour and disagreements",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9-]+$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The agent record",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "404": {
            "description": "No agent with that id",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Over 300 calls a minute from this address",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "IdentifyResult": {
        "type": "object",
        "required": [
          "verdict",
          "agent",
          "tier",
          "strength",
          "checks",
          "ipMatches",
          "notChecked",
          "docs",
          "license"
        ],
        "properties": {
          "verdict": {
            "type": "string",
            "enum": [
              "verified",
              "claimed_only",
              "unverifiable",
              "no_claim"
            ],
            "description": "verified: a check passed. claimed_only: checks ran and none passed. unverifiable: an agent is claimed and nothing could be checked. no_claim: the user agent names no known agent."
          },
          "agent": {
            "type": [
              "object",
              "null"
            ],
            "properties": {
              "id": {
                "type": "string"
              },
              "name": {
                "type": "string"
              },
              "vendor": {
                "type": "string"
              },
              "purpose": {
                "type": "string"
              },
              "url": {
                "type": "string",
                "format": "uri"
              }
            }
          },
          "tier": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "ip_list",
              "reverse_dns",
              "vendor_network",
              null
            ]
          },
          "strength": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "strong",
              "network_only",
              null
            ]
          },
          "checks": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "check",
                "status",
                "reason"
              ],
              "properties": {
                "check": {
                  "type": "string",
                  "enum": [
                    "ip_list",
                    "reverse_dns",
                    "vendor_network"
                  ]
                },
                "status": {
                  "type": "string",
                  "enum": [
                    "passed",
                    "failed",
                    "not_checked"
                  ],
                  "description": "not_checked means the check could not run. It is never reported as failed."
                },
                "reason": {
                  "type": "string"
                },
                "listLoaded": {
                  "type": "string",
                  "format": "date",
                  "description": "For ip_list: the date the published list was last loaded."
                }
              }
            }
          },
          "ipMatches": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "id",
                "name"
              ],
              "properties": {
                "id": {
                  "type": "string"
                },
                "name": {
                  "type": "string"
                }
              }
            },
            "description": "Agents whose own published IP list contains the address."
          },
          "notChecked": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "docs": {
            "type": "string",
            "format": "uri"
          },
          "license": {
            "type": "string"
          }
        }
      },
      "Error": {
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "object",
            "required": [
              "code",
              "message"
            ],
            "properties": {
              "code": {
                "type": "string"
              },
              "message": {
                "type": "string"
              }
            }
          }
        }
      }
    }
  }
}
