{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/fastcrw-com/json-schema/fastcrw-com-search-response-schema.json",
  "title": "SearchResponse",
  "x-generated": "2026-10-30",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/fastcrw-com-openapi.json#/components/schemas/SearchResponse",
  "type": "object",
  "required": [
    "success",
    "data"
  ],
  "properties": {
    "success": {
      "type": "boolean"
    },
    "data": {
      "description": "Search results. On the hosted API (https://api.fastcrw.com) the results ARE the value of `data`. A self-hosted engine wraps them one level deeper as `data.results`, and carries `answer`/`citations`/`llmUsage`/`warnings` inside `data` instead of at the top level. Clients that must work against both should read `data.results` when present and fall back to `data`.",
      "anyOf": [
        {
          "title": "Flat results",
          "description": "Returned when `sources` is not set.",
          "type": "array",
          "items": {
            "$ref": "#/$defs/SearchResult"
          }
        },
        {
          "title": "Grouped results",
          "description": "Returned when `sources` is set.",
          "type": "object",
          "properties": {
            "web": {
              "type": "array",
              "items": {
                "$ref": "#/$defs/SearchResult"
              }
            },
            "news": {
              "type": "array",
              "items": {
                "$ref": "#/$defs/SearchResult"
              }
            },
            "images": {
              "type": "array",
              "items": {
                "type": "object"
              }
            }
          }
        },
        {
          "title": "Self-hosted wrapper",
          "description": "The self-hosted engine nests the flat or grouped results under `results`.",
          "type": "object",
          "required": [
            "results"
          ],
          "properties": {
            "results": {},
            "answer": {
              "type": "string"
            },
            "citations": {
              "type": "array",
              "items": {
                "type": "object"
              }
            },
            "llmUsage": {
              "type": "object"
            },
            "warnings": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          }
        }
      ]
    },
    "answer": {
      "type": "string",
      "description": "Hosted API only — synthesized answer over the top results, present when `answer: true` was set. A self-hosted engine returns this inside `data`."
    },
    "citations": {
      "type": "array",
      "description": "Hosted API only — sources for `answer`, in citation order. A self-hosted engine returns this inside `data`.",
      "items": {
        "type": "object"
      }
    },
    "llmUsage": {
      "type": "object",
      "description": "Hosted API only — token usage for the answer synthesis. A self-hosted engine returns this inside `data`."
    },
    "warnings": {
      "type": "array",
      "description": "Hosted API only — soft-failure notices (e.g. an answer leg that was rate-limited). A self-hosted engine returns this inside `data`.",
      "items": {
        "type": "string"
      }
    }
  },
  "$defs": {
    "SearchResult": {
      "type": "object",
      "required": [
        "url",
        "title"
      ],
      "properties": {
        "url": {
          "type": "string",
          "format": "uri"
        },
        "title": {
          "type": "string"
        },
        "snippet": {
          "type": "string",
          "description": "Result blurb (LLM-ready summary line)"
        },
        "description": {
          "type": "string",
          "description": "Alias of snippet (same value, kept for Firecrawl response-shape parity)"
        },
        "position": {
          "type": "integer"
        },
        "score": {
          "type": "number"
        },
        "category": {
          "type": "string",
          "description": "Search backend result category (e.g. 'general')"
        },
        "markdown": {
          "type": "string",
          "description": "Present when scrapeOptions.formats includes 'markdown'"
        }
      }
    }
  }
}