{
  "openapi": "3.1.0",
  "info": {
    "title": "Evidence8 Public Visual Search",
    "version": "1.0.0",
    "description": "Source-grounded visual retrieval with public discovery and account-metered search. Authenticated searches use one prepaid credit when results are returned; no-match and errors are free. Private/local evidence is excluded. Verify source context and rights before using candidates."
  },
  "servers": [
    {
      "url": "https://evidence8.com"
    }
  ],
  "paths": {
    "/v1/search": {
      "post": {
        "operationId": "searchVisualEvidence",
        "summary": "Find source-grounded visual candidates",
        "description": "Account API access uses a bearer key and prepaid search credits. Anonymous preview: 10 searches/day/IP when account storage is configured. Edge ceiling: 60 requests/minute/IP. Search candidates do not verify a claim.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "query"
                ],
                "properties": {
                  "query": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 500
                  },
                  "corpus": {
                    "type": "string",
                    "maxLength": 100,
                    "default": "all"
                  },
                  "candidateLimit": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 10,
                    "default": 5
                  }
                }
              },
              "example": {
                "query": "Ember electricity demand United States",
                "candidateLimit": 3
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Public retrieval response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SearchResponse"
                }
              }
            }
          },
          "400": {
            "description": "Malformed JSON or invalid options"
          },
          "405": {
            "description": "Unsupported method"
          },
          "413": {
            "description": "Body exceeds 16 KiB"
          },
          "415": {
            "description": "Use application/json"
          },
          "422": {
            "description": "Invalid query"
          },
          "429": {
            "description": "Rate limit reached"
          },
          "503": {
            "description": "Public index unavailable"
          },
          "401": {
            "description": "Invalid/revoked key or expired account session"
          },
          "402": {
            "description": "Insufficient search credits; add credits in Billing"
          }
        },
        "security": [
          {
            "EvidenceKey": []
          },
          {}
        ]
      }
    },
    "/v1/assets/{id}": {
      "get": {
        "operationId": "getVisualEvidence",
        "summary": "Read a public visual's metadata",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[a-zA-Z0-9_-]{1,250}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Public retrieval response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Visual"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Public record not found"
          },
          "429": {
            "description": "Rate limit reached"
          },
          "503": {
            "description": "Public index unavailable"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Visual": {
        "type": "object",
        "required": [
          "id",
          "title",
          "sourceUrl"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "publisher": {
            "type": [
              "string",
              "null"
            ]
          },
          "sourceUrl": {
            "type": "string",
            "format": "uri"
          },
          "assetUrl": {
            "type": [
              "string",
              "null"
            ],
            "format": "uri"
          },
          "recordUrl": {
            "type": "string",
            "format": "uri"
          },
          "rights": {
            "type": [
              "string",
              "null"
            ],
            "description": "Recorded rights context; check source terms independently."
          },
          "metadata": {
            "type": "object"
          }
        },
        "additionalProperties": true
      },
      "SearchResponse": {
        "type": "object",
        "required": [
          "status",
          "results",
          "requestId"
        ],
        "properties": {
          "status": {
            "type": "string",
            "enum": [
              "ok",
              "no_match"
            ]
          },
          "requestId": {
            "type": "string"
          },
          "total": {
            "type": "integer",
            "minimum": 0
          },
          "selected": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Visual"
              },
              {
                "type": "null"
              }
            ]
          },
          "results": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Visual"
            }
          },
          "retrieval": {
            "type": "object"
          }
        },
        "additionalProperties": true
      }
    },
    "securitySchemes": {
      "EvidenceKey": {
        "type": "http",
        "scheme": "bearer",
        "description": "An Evidence API key created in your account."
      }
    }
  }
}
