{
  "openapi": "3.1.0",
  "info": {
    "title": "crawlapi",
    "version": "1.0.0",
    "summary": "Public web pages and documents as clean markdown or structured JSON.",
    "description": "Send a URL to `POST /v1/scrape` to receive clean markdown or structured JSON. JavaScript rendering, document parsing, and access handling run automatically. Failed requests cost `0` credits.",
    "termsOfService": "https://crawlapi.dev/terms",
    "contact": {
      "name": "crawlapi support",
      "email": "support@crawlapi.dev",
      "url": "https://docs.crawlapi.dev"
    }
  },
  "externalDocs": {
    "description": "crawlapi documentation",
    "url": "https://docs.crawlapi.dev"
  },
  "servers": [
    {
      "url": "https://api.crawlapi.dev",
      "description": "Production API"
    }
  ],
  "tags": [
    {
      "name": "Scrape",
      "description": "Read a public URL as markdown or structured JSON."
    },
    {
      "name": "Account",
      "description": "The account and key behind an API key."
    }
  ],
  "paths": {
    "/v1/scrape": {
      "post": {
        "tags": ["Scrape"],
        "operationId": "scrape",
        "summary": "Read one URL as markdown or JSON",
        "description": "Reads a public web page or document within a single `timeout` deadline and returns clean `markdown` or structured `json`. `usage.credits` reports the price charged (`1` credit per returned page).",
        "security": [
          {
            "bearer": []
          },
          {
            "apiKey": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ScrapeRequest"
              },
              "examples": {
                "markdown": {
                  "summary": "Markdown (default)",
                  "value": {
                    "url": "https://example.com"
                  }
                },
                "json": {
                  "summary": "Structured JSON",
                  "value": {
                    "url": "https://www.imdb.com/title/tt0111161/",
                    "format": "json"
                  }
                },
                "timeout": {
                  "summary": "Custom deadline",
                  "value": {
                    "url": "https://example.com",
                    "format": "markdown",
                    "timeout": 45000
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Page or document returned as `markdown` or `json`.",
            "headers": {
              "x-request-id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimit-Policy"
              },
              "RateLimit": {
                "$ref": "#/components/headers/RateLimit"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ScrapeSuccess"
                },
                "examples": {
                  "markdown": {
                    "summary": "Markdown response (1 credit)",
                    "value": {
                      "success": true,
                      "request_id": "req_1dc0a514d6ee71c4524b",
                      "data": {
                        "metadata": {
                          "title": "Example Domain",
                          "description": "",
                          "language": "en",
                          "status": 200,
                          "final_url": "https://example.com/"
                        },
                        "links": [],
                        "markdown": "# Example Domain\n\nThis domain is for use in documentation examples without needing permission."
                      },
                      "usage": {
                        "credits": 1,
                        "remaining": 9999
                      }
                    }
                  },
                  "json": {
                    "summary": "Structured JSON response (1 credit)",
                    "value": {
                      "success": true,
                      "request_id": "req_3c5a360ab9ad5ba76a75",
                      "data": {
                        "metadata": {
                          "title": "The Shawshank Redemption (1994) - IMDb",
                          "description": "Directed by Frank Darabont.",
                          "language": "en-US",
                          "status": 200,
                          "final_url": "https://www.imdb.com/title/tt0111161/"
                        },
                        "links": ["https://www.imdb.com/name/nm0000209/"],
                        "json": {
                          "structured": {
                            "type": "creative_work",
                            "source": "jsonld",
                            "creative_work": {
                              "kind": "Movie",
                              "name": "The Shawshank Redemption",
                              "date": "1994-10-14",
                              "rating": {
                                "value": 9.3,
                                "count": 3264267
                              },
                              "genre": "Drama",
                              "directors": ["Frank Darabont"],
                              "actors": ["Tim Robbins", "Morgan Freeman"],
                              "duration": "PT2H22M"
                            }
                          },
                          "tables": [
                            {
                              "source": "embedded",
                              "headers": ["name", "url"],
                              "rows": [
                                ["Tim Robbins", "https://www.imdb.com/name/nm0000209/"],
                                ["Morgan Freeman", "https://www.imdb.com/name/nm0000151/"]
                              ]
                            }
                          ],
                          "jsonld": [
                            {
                              "@context": "https://schema.org",
                              "@type": "Movie",
                              "name": "The Shawshank Redemption"
                            }
                          ],
                          "embedded": []
                        }
                      },
                      "usage": {
                        "credits": 1,
                        "remaining": 9998
                      }
                    }
                  },
                  "login_wall": {
                    "summary": "Sign-in wall (0 credits)",
                    "value": {
                      "success": true,
                      "request_id": "req_a12b34c56d78e90f1234",
                      "data": {
                        "metadata": {
                          "title": "Sign in to Example",
                          "description": "",
                          "language": "en",
                          "status": 200,
                          "final_url": "https://example.com/login",
                          "login_required": true
                        },
                        "links": [],
                        "markdown": "# Sign in to Example\n\nEnter your email and password to continue."
                      },
                      "usage": {
                        "credits": 0,
                        "remaining": 9998
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Malformed JSON, invalid or unknown request field (`INVALID_REQUEST`), or non-public or disallowed target URL (`UNSAFE_URL`).",
            "headers": {
              "x-request-id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimit-Policy"
              },
              "RateLimit": {
                "$ref": "#/components/headers/RateLimit"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Fail"
                },
                "examples": {
                  "invalid_request": {
                    "summary": "INVALID_REQUEST",
                    "value": {
                      "success": false,
                      "request_id": "req_8f10a22d4c9012ab34cd",
                      "error": {
                        "code": "INVALID_REQUEST",
                        "message": "`timeout` must be an integer between 1000 and 60000 ms.",
                        "retryable": false,
                        "doc_url": "https://docs.crawlapi.dev/errors#INVALID_REQUEST",
                        "param": "timeout"
                      }
                    }
                  },
                  "unsafe_url": {
                    "summary": "UNSAFE_URL",
                    "value": {
                      "success": false,
                      "request_id": "req_7a01bc23de45fa678901",
                      "error": {
                        "code": "UNSAFE_URL",
                        "message": "The domain 10.0.0.1 resolves to a private or reserved address.",
                        "retryable": false,
                        "doc_url": "https://docs.crawlapi.dev/errors#UNSAFE_URL"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, unknown, or revoked API key (`UNAUTHORIZED`).",
            "headers": {
              "x-request-id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "WWW-Authenticate": {
                "$ref": "#/components/headers/WWW-Authenticate"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Fail"
                },
                "examples": {
                  "unauthorized": {
                    "summary": "UNAUTHORIZED",
                    "value": {
                      "success": false,
                      "request_id": "req_112233445566778899aa",
                      "error": {
                        "code": "UNAUTHORIZED",
                        "message": "The API key is unknown or inactive; your keys are at https://app.crawlapi.dev/keys.",
                        "retryable": false,
                        "doc_url": "https://docs.crawlapi.dev/errors#UNAUTHORIZED"
                      }
                    }
                  }
                }
              }
            }
          },
          "402": {
            "description": "Account credit balance cannot cover this request (`INSUFFICIENT_CREDITS`).",
            "headers": {
              "x-request-id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimit-Policy"
              },
              "RateLimit": {
                "$ref": "#/components/headers/RateLimit"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Fail"
                },
                "examples": {
                  "insufficient_credits": {
                    "summary": "INSUFFICIENT_CREDITS",
                    "value": {
                      "success": false,
                      "request_id": "req_2233445566778899aabb",
                      "error": {
                        "code": "INSUFFICIENT_CREDITS",
                        "message": "Insufficient credits: this request needs 1 credit. Buy credits at https://app.crawlapi.dev/billing.",
                        "retryable": false,
                        "doc_url": "https://docs.crawlapi.dev/errors#INSUFFICIENT_CREDITS",
                        "required_credits": 1
                      }
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "The API key's account is suspended (`ACCOUNT_SUSPENDED`).",
            "headers": {
              "x-request-id": {
                "$ref": "#/components/headers/X-Request-Id"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Fail"
                },
                "examples": {
                  "account_suspended": {
                    "summary": "ACCOUNT_SUSPENDED",
                    "value": {
                      "success": false,
                      "request_id": "req_3344556677889900aabb",
                      "error": {
                        "code": "ACCOUNT_SUSPENDED",
                        "message": "This account is suspended.",
                        "retryable": false,
                        "doc_url": "https://docs.crawlapi.dev/errors#ACCOUNT_SUSPENDED"
                      }
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Target page does not exist (`NOT_FOUND`), or request path is not `/v1/scrape` (`ROUTE_NOT_FOUND`).",
            "headers": {
              "x-request-id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "RateLimit-Policy": {
                "description": "Account rate-limit policy sent on authenticated responses: `\"minute\"` sets `q` requests per minute (`w=60`), `\"concurrency\"` sets `q` in-flight requests at once. Present on `NOT_FOUND`, omitted on `ROUTE_NOT_FOUND`.",
                "schema": {
                  "type": "string"
                }
              },
              "RateLimit": {
                "description": "Remaining quota when the response leaves: `\"minute\";r=` requests that can start now and `t=` seconds until the next token refills (omitted when your full per-minute allowance is available); `\"concurrency\";r=` free in-flight slots. Present on `NOT_FOUND`, omitted on `ROUTE_NOT_FOUND`.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Fail"
                },
                "examples": {
                  "not_found": {
                    "summary": "NOT_FOUND (target page)",
                    "value": {
                      "success": false,
                      "request_id": "req_fe9963033461e4fcc81c",
                      "error": {
                        "code": "NOT_FOUND",
                        "message": "The site says this page does not exist (HTTP 404).",
                        "retryable": false,
                        "doc_url": "https://docs.crawlapi.dev/errors#NOT_FOUND",
                        "target_status": 404
                      }
                    }
                  },
                  "route_not_found": {
                    "summary": "ROUTE_NOT_FOUND (wrong path)",
                    "value": {
                      "success": false,
                      "request_id": "req_33445566778899aabbcc",
                      "error": {
                        "code": "ROUTE_NOT_FOUND",
                        "message": "No such route; the API is POST /v1/scrape.",
                        "retryable": false,
                        "doc_url": "https://docs.crawlapi.dev/errors#ROUTE_NOT_FOUND"
                      }
                    }
                  }
                }
              }
            }
          },
          "405": {
            "description": "HTTP method is not allowed on this route (`METHOD_NOT_ALLOWED`).",
            "headers": {
              "x-request-id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "Allow": {
                "$ref": "#/components/headers/Allow"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Fail"
                },
                "examples": {
                  "method_not_allowed": {
                    "summary": "METHOD_NOT_ALLOWED",
                    "value": {
                      "success": false,
                      "request_id": "req_445566778899aabbccdd",
                      "error": {
                        "code": "METHOD_NOT_ALLOWED",
                        "message": "Method not allowed; this path takes POST.",
                        "retryable": false,
                        "doc_url": "https://docs.crawlapi.dev/errors#METHOD_NOT_ALLOWED"
                      }
                    }
                  }
                }
              }
            }
          },
          "408": {
            "description": "Request reached its `timeout` deadline before finishing (`TIMEOUT`).",
            "headers": {
              "x-request-id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimit-Policy"
              },
              "RateLimit": {
                "$ref": "#/components/headers/RateLimit"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Fail"
                },
                "examples": {
                  "timeout": {
                    "summary": "TIMEOUT",
                    "value": {
                      "success": false,
                      "request_id": "req_5566778899aabbccddee",
                      "error": {
                        "code": "TIMEOUT",
                        "message": "The request ran out of time before the page finished loading.",
                        "retryable": true,
                        "doc_url": "https://docs.crawlapi.dev/errors#TIMEOUT"
                      }
                    }
                  }
                }
              }
            }
          },
          "410": {
            "description": "Target site reports the page has been permanently removed (`GONE`).",
            "headers": {
              "x-request-id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimit-Policy"
              },
              "RateLimit": {
                "$ref": "#/components/headers/RateLimit"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Fail"
                },
                "examples": {
                  "gone": {
                    "summary": "GONE",
                    "value": {
                      "success": false,
                      "request_id": "req_66778899aabbccddeeff",
                      "error": {
                        "code": "GONE",
                        "message": "The site says this page is gone (HTTP 410).",
                        "retryable": false,
                        "doc_url": "https://docs.crawlapi.dev/errors#GONE",
                        "target_status": 410
                      }
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "Request was valid but the target could not produce usable content: `BLOCKED`, `NO_CONTENT`, `HOST_NOT_FOUND`, `LOGIN_REQUIRED`, `UNSUPPORTED_CONTENT`, `SCANNED_PDF`, or `TARGET_ERROR`.",
            "headers": {
              "x-request-id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimit-Policy"
              },
              "RateLimit": {
                "$ref": "#/components/headers/RateLimit"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Fail"
                },
                "examples": {
                  "blocked": {
                    "summary": "BLOCKED",
                    "value": {
                      "success": false,
                      "request_id": "req_41e813f088955c316776",
                      "error": {
                        "code": "BLOCKED",
                        "message": "The site's bot protection (Akamai) refused access.",
                        "retryable": true,
                        "doc_url": "https://docs.crawlapi.dev/errors#BLOCKED",
                        "target_status": 403,
                        "vendor": "akamai"
                      }
                    }
                  },
                  "no_content": {
                    "summary": "NO_CONTENT (format=json on prose page)",
                    "value": {
                      "success": false,
                      "request_id": "req_778899aabbccddeeff00",
                      "error": {
                        "code": "NO_CONTENT",
                        "message": "The page has no structured data, so format=json has nothing to return; format=markdown returns its text.",
                        "retryable": false,
                        "doc_url": "https://docs.crawlapi.dev/errors#NO_CONTENT",
                        "target_status": 200
                      }
                    }
                  },
                  "scanned_pdf": {
                    "summary": "SCANNED_PDF",
                    "value": {
                      "success": false,
                      "request_id": "req_8899aabbccddeeff0011",
                      "error": {
                        "code": "SCANNED_PDF",
                        "message": "Most pages of this PDF are scanned images, and OCR is not supported (12 of 12 pages).",
                        "retryable": false,
                        "doc_url": "https://docs.crawlapi.dev/errors#SCANNED_PDF"
                      }
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Rate limit, concurrency limit, or temporary service load reached (`RATE_LIMITED`).",
            "headers": {
              "x-request-id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "Retry-After": {
                "$ref": "#/components/headers/Retry-After"
              },
              "RateLimit-Policy": {
                "description": "Account rate-limit policy sent on authenticated responses: `\"minute\"` sets `q` requests per minute (`w=60`), `\"concurrency\"` sets `q` in-flight requests at once.",
                "schema": {
                  "type": "string"
                }
              },
              "RateLimit": {
                "description": "Remaining quota when the response leaves: `\"minute\";r=` requests that can start now and `t=` seconds until the next token refills (omitted when your full per-minute allowance is available); `\"concurrency\";r=` free in-flight slots.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Fail"
                },
                "examples": {
                  "rate_limited": {
                    "summary": "RATE_LIMITED",
                    "value": {
                      "success": false,
                      "request_id": "req_3115cab0d43d3ab5a090",
                      "error": {
                        "code": "RATE_LIMITED",
                        "message": "This account's limit of requests at once (10) is reached; retry when one finishes.",
                        "retryable": true,
                        "doc_url": "https://docs.crawlapi.dev/errors#RATE_LIMITED"
                      }
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Service-side failure (`ENGINE_FAILED` or `INTERNAL`). Nothing was charged.",
            "headers": {
              "x-request-id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "Retry-After": {
                "description": "Whole seconds to wait before retrying. Sent on transient `INTERNAL` errors, omitted on `ENGINE_FAILED`.",
                "schema": {
                  "type": "integer",
                  "minimum": 1,
                  "example": 5
                }
              },
              "RateLimit-Policy": {
                "description": "Account rate-limit policy sent on authenticated responses: `\"minute\"` sets `q` requests per minute (`w=60`), `\"concurrency\"` sets `q` in-flight requests at once. Present when the failure occurred after authentication.",
                "schema": {
                  "type": "string"
                }
              },
              "RateLimit": {
                "description": "Remaining quota when the response leaves: `\"minute\";r=` requests that can start now and `t=` seconds until the next token refills (omitted when your full per-minute allowance is available); `\"concurrency\";r=` free in-flight slots. Present when the failure occurred after authentication.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Fail"
                },
                "examples": {
                  "engine_failed": {
                    "summary": "ENGINE_FAILED",
                    "value": {
                      "success": false,
                      "request_id": "req_99aabbccddeeff001122",
                      "error": {
                        "code": "ENGINE_FAILED",
                        "message": "This failure is on our side, not the site's; retrying the same request may work.",
                        "retryable": true,
                        "doc_url": "https://docs.crawlapi.dev/errors#ENGINE_FAILED"
                      }
                    }
                  },
                  "internal": {
                    "summary": "INTERNAL",
                    "value": {
                      "success": false,
                      "request_id": "req_aabbccddeeff00112233",
                      "error": {
                        "code": "INTERNAL",
                        "message": "Something went wrong on our side (logged as req_aabbccddeeff00112233); nothing was charged, retry in 5 s.",
                        "retryable": true,
                        "doc_url": "https://docs.crawlapi.dev/errors#INTERNAL"
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "x-codeSamples": [
          {
            "lang": "Shell",
            "label": "cURL",
            "source": "curl -sS https://api.crawlapi.dev/v1/scrape \\\n  -H \"Authorization: Bearer $CRAWLAPI_API_KEY\" \\\n  -H 'content-type: application/json' \\\n  --data '{\"url\": \"https://example.com\"}'"
          },
          {
            "lang": "TypeScript",
            "label": "TypeScript",
            "source": "const response = await fetch('https://api.crawlapi.dev/v1/scrape', {\n  method: 'POST',\n  headers: {\n    Authorization: `Bearer ${process.env.CRAWLAPI_API_KEY}`,\n    'content-type': 'application/json',\n  },\n  body: JSON.stringify({ url: 'https://example.com' }),\n});\nconst body = await response.json();\nif (!body.success) throw new Error(`${body.error.code}: ${body.error.message}`);\nconsole.log(body.data.markdown);"
          },
          {
            "lang": "Python",
            "label": "Python",
            "source": "import os\nimport requests\n\nresponse = requests.post(\n    \"https://api.crawlapi.dev/v1/scrape\",\n    headers={\"Authorization\": f\"Bearer {os.environ['CRAWLAPI_API_KEY']}\"},\n    json={\"url\": \"https://example.com\"},\n    timeout=65,\n)\nbody = response.json()\nif not body[\"success\"]:\n    raise RuntimeError(f\"{body['error']['code']}: {body['error']['message']}\")\nprint(body[\"data\"][\"markdown\"])"
          },
          {
            "lang": "Go",
            "label": "Go",
            "source": "package main\n\nimport (\n    \"bytes\"\n    \"encoding/json\"\n    \"fmt\"\n    \"net/http\"\n    \"os\"\n    \"time\"\n)\n\nfunc main() {\n    payload := []byte(`{\"url\":\"https://example.com\"}`)\n    req, err := http.NewRequest(\"POST\", \"https://api.crawlapi.dev/v1/scrape\", bytes.NewReader(payload))\n    if err != nil {\n        panic(err)\n    }\n    req.Header.Set(\"Authorization\", \"Bearer \"+os.Getenv(\"CRAWLAPI_API_KEY\"))\n    req.Header.Set(\"Content-Type\", \"application/json\")\n    client := &http.Client{Timeout: 65 * time.Second}\n    resp, err := client.Do(req)\n    if err != nil {\n        panic(err)\n    }\n    defer resp.Body.Close()\n    var body struct {\n        Success bool `json:\"success\"`\n        Data    struct{ Markdown string `json:\"markdown\"` } `json:\"data\"`\n        Error   struct{ Code, Message string } `json:\"error\"`\n    }\n    if err := json.NewDecoder(resp.Body).Decode(&body); err != nil {\n        panic(err)\n    }\n    if !body.Success {\n        panic(fmt.Sprintf(\"%s: %s\", body.Error.Code, body.Error.Message))\n    }\n    fmt.Println(body.Data.Markdown)\n}"
          },
          {
            "lang": "Ruby",
            "label": "Ruby",
            "source": "require \"json\"\nrequire \"net/http\"\nrequire \"uri\"\n\nuri = URI(\"https://api.crawlapi.dev/v1/scrape\")\nreq = Net::HTTP::Post.new(uri)\nreq[\"Authorization\"] = \"Bearer #{ENV.fetch('CRAWLAPI_API_KEY')}\"\nreq[\"Content-Type\"] = \"application/json\"\nreq.body = JSON.generate({ url: \"https://example.com\" })\n\nres = Net::HTTP.start(\n  uri.host, uri.port, use_ssl: true, read_timeout: 65\n) { |http| http.request(req) }\nbody = JSON.parse(res.body)\nraise \"#{body.dig(\"error\", \"code\")}: #{body.dig(\"error\", \"message\")}\" unless body[\"success\"]\nputs body.dig(\"data\", \"markdown\")"
          },
          {
            "lang": "PHP",
            "label": "PHP",
            "source": "<?php\n$ch = curl_init('https://api.crawlapi.dev/v1/scrape');\ncurl_setopt_array($ch, [\n    CURLOPT_POST => true,\n    CURLOPT_RETURNTRANSFER => true,\n    CURLOPT_TIMEOUT => 65,\n    CURLOPT_HTTPHEADER => [\n        'Authorization: Bearer ' . getenv('CRAWLAPI_API_KEY'),\n        'Content-Type: application/json',\n    ],\n    CURLOPT_POSTFIELDS => json_encode(['url' => 'https://example.com']),\n]);\n$raw = curl_exec($ch);\nif ($raw === false) throw new RuntimeException(curl_error($ch));\n$body = json_decode($raw, true, 512, JSON_THROW_ON_ERROR);\nif (empty($body['success']))\n    throw new RuntimeException($body['error']['code'] . ': ' . $body['error']['message']);\necho $body['data']['markdown'];"
          }
        ]
      }
    },
    "/v1/account": {
      "get": {
        "tags": ["Account"],
        "operationId": "account",
        "summary": "Read the account behind an API key",
        "description": "Returns the account's email, credit balance and holds, scrape limits, and the key that made the request. Costs no credits and takes no scrape slot; an account may make 60 account requests a minute.",
        "security": [
          {
            "bearer": []
          },
          {
            "apiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "The account and the calling key.",
            "headers": {
              "x-request-id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimit-Policy"
              },
              "RateLimit": {
                "$ref": "#/components/headers/RateLimit"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AccountSuccess"
                },
                "examples": {
                  "account": {
                    "summary": "The account of a `crawl login` key",
                    "value": {
                      "success": true,
                      "request_id": "req_0a1b2c3d4e5f60718293",
                      "data": {
                        "email": "you@example.com",
                        "credits": {
                          "balance": 9431,
                          "held": 0
                        },
                        "limits": {
                          "rate_limit_per_min": 200,
                          "max_concurrency": 10
                        },
                        "key": {
                          "id": "3f0c2a8e-6b1d-4c57-9a1e-2d8b7f4c6e10",
                          "prefix": "ck_AbCdEfG",
                          "name": "crawl on laptop",
                          "scope": "cli"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, unknown, or revoked API key (`UNAUTHORIZED`).",
            "headers": {
              "x-request-id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "WWW-Authenticate": {
                "$ref": "#/components/headers/WWW-Authenticate"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Fail"
                },
                "examples": {
                  "unauthorized": {
                    "summary": "UNAUTHORIZED",
                    "value": {
                      "success": false,
                      "request_id": "req_112233445566778899aa",
                      "error": {
                        "code": "UNAUTHORIZED",
                        "message": "The API key is unknown or inactive; your keys are at https://app.crawlapi.dev/keys.",
                        "retryable": false,
                        "doc_url": "https://docs.crawlapi.dev/errors#UNAUTHORIZED"
                      }
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "The API key's account is suspended (`ACCOUNT_SUSPENDED`).",
            "headers": {
              "x-request-id": {
                "$ref": "#/components/headers/X-Request-Id"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Fail"
                },
                "examples": {
                  "account_suspended": {
                    "summary": "ACCOUNT_SUSPENDED",
                    "value": {
                      "success": false,
                      "request_id": "req_3344556677889900aabb",
                      "error": {
                        "code": "ACCOUNT_SUSPENDED",
                        "message": "This account is suspended.",
                        "retryable": false,
                        "doc_url": "https://docs.crawlapi.dev/errors#ACCOUNT_SUSPENDED"
                      }
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Account-request limit reached (`RATE_LIMITED`).",
            "headers": {
              "x-request-id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "Retry-After": {
                "$ref": "#/components/headers/Retry-After"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Fail"
                },
                "examples": {
                  "rate_limited": {
                    "summary": "RATE_LIMITED",
                    "value": {
                      "success": false,
                      "request_id": "req_2c3d4e5f607182930415",
                      "error": {
                        "code": "RATE_LIMITED",
                        "message": "This account's limit of 60 account requests a minute is reached; retry in 1 s.",
                        "retryable": true,
                        "doc_url": "https://docs.crawlapi.dev/errors#RATE_LIMITED"
                      }
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Service-side failure (`INTERNAL`).",
            "headers": {
              "x-request-id": {
                "$ref": "#/components/headers/X-Request-Id"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Fail"
                },
                "examples": {
                  "internal": {
                    "summary": "INTERNAL",
                    "value": {
                      "success": false,
                      "request_id": "req_aabbccddeeff00112233",
                      "error": {
                        "code": "INTERNAL",
                        "message": "Something went wrong on our side (logged as req_aabbccddeeff00112233); nothing was charged, retry in 5 s.",
                        "retryable": true,
                        "doc_url": "https://docs.crawlapi.dev/errors#INTERNAL"
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/account/key": {
      "delete": {
        "tags": ["Account"],
        "operationId": "revokeKey",
        "summary": "Revoke the calling API key",
        "description": "Revokes the API key that made the request, everywhere and at once. Other keys of the account keep working.",
        "security": [
          {
            "bearer": []
          },
          {
            "apiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "The calling key was revoked.",
            "headers": {
              "x-request-id": {
                "$ref": "#/components/headers/X-Request-Id"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/KeyRevoked"
                },
                "examples": {
                  "revoked": {
                    "summary": "The calling key revoked",
                    "value": {
                      "success": true,
                      "request_id": "req_1b2c3d4e5f6071829304",
                      "revoked": true
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, unknown, or revoked API key (`UNAUTHORIZED`).",
            "headers": {
              "x-request-id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "WWW-Authenticate": {
                "$ref": "#/components/headers/WWW-Authenticate"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Fail"
                },
                "examples": {
                  "unauthorized": {
                    "summary": "UNAUTHORIZED",
                    "value": {
                      "success": false,
                      "request_id": "req_112233445566778899aa",
                      "error": {
                        "code": "UNAUTHORIZED",
                        "message": "The API key is unknown or inactive; your keys are at https://app.crawlapi.dev/keys.",
                        "retryable": false,
                        "doc_url": "https://docs.crawlapi.dev/errors#UNAUTHORIZED"
                      }
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "The API key's account is suspended (`ACCOUNT_SUSPENDED`).",
            "headers": {
              "x-request-id": {
                "$ref": "#/components/headers/X-Request-Id"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Fail"
                },
                "examples": {
                  "account_suspended": {
                    "summary": "ACCOUNT_SUSPENDED",
                    "value": {
                      "success": false,
                      "request_id": "req_3344556677889900aabb",
                      "error": {
                        "code": "ACCOUNT_SUSPENDED",
                        "message": "This account is suspended.",
                        "retryable": false,
                        "doc_url": "https://docs.crawlapi.dev/errors#ACCOUNT_SUSPENDED"
                      }
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Account-request limit reached (`RATE_LIMITED`).",
            "headers": {
              "x-request-id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "Retry-After": {
                "$ref": "#/components/headers/Retry-After"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Fail"
                },
                "examples": {
                  "rate_limited": {
                    "summary": "RATE_LIMITED",
                    "value": {
                      "success": false,
                      "request_id": "req_2c3d4e5f607182930415",
                      "error": {
                        "code": "RATE_LIMITED",
                        "message": "This account's limit of 60 account requests a minute is reached; retry in 1 s.",
                        "retryable": true,
                        "doc_url": "https://docs.crawlapi.dev/errors#RATE_LIMITED"
                      }
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Service-side failure (`INTERNAL`).",
            "headers": {
              "x-request-id": {
                "$ref": "#/components/headers/X-Request-Id"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Fail"
                },
                "examples": {
                  "internal": {
                    "summary": "INTERNAL",
                    "value": {
                      "success": false,
                      "request_id": "req_aabbccddeeff00112233",
                      "error": {
                        "code": "INTERNAL",
                        "message": "Something went wrong on our side (logged as req_aabbccddeeff00112233); nothing was charged, retry in 5 s.",
                        "retryable": true,
                        "doc_url": "https://docs.crawlapi.dev/errors#INTERNAL"
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "ScrapeRequest": {
        "type": "object",
        "properties": {
          "url": {
            "type": "string",
            "minLength": 1,
            "maxLength": 8192,
            "description": "Public `http` or `https` URL to read. Private addresses and embedded credentials return `UNSAFE_URL`.",
            "format": "uri"
          },
          "format": {
            "enum": ["markdown", "json"],
            "type": "string",
            "description": "Output format: `markdown` returns clean page text; `json` returns structured objects, tables, JSON-LD, and embedded state.",
            "default": "markdown"
          },
          "timeout": {
            "type": "integer",
            "minimum": 1000,
            "maximum": 60000,
            "description": "Overall deadline in milliseconds for the request. Defaults to `30000`.",
            "default": 30000
          }
        },
        "required": ["url"],
        "additionalProperties": false
      },
      "ScrapeSuccess": {
        "type": "object",
        "properties": {
          "success": {
            "enum": [true],
            "type": "boolean",
            "description": "Always `true` on success."
          },
          "request_id": {
            "type": "string",
            "description": "Unique request identifier, echoed in the `x-request-id` header."
          },
          "data": {
            "$ref": "#/components/schemas/ScrapeData",
            "description": "Extracted page content: `metadata`, `links`, and either `markdown` or `json`."
          },
          "usage": {
            "$ref": "#/components/schemas/Usage",
            "description": "Credits charged and remaining balance."
          }
        },
        "required": ["success", "request_id", "data", "usage"],
        "additionalProperties": false
      },
      "ScrapeData": {
        "description": "Extracted page content: either `markdown` or `json`, never both.",
        "oneOf": [
          {
            "$ref": "#/components/schemas/MarkdownScrapeData"
          },
          {
            "$ref": "#/components/schemas/JsonScrapeData"
          }
        ]
      },
      "Metadata": {
        "type": "object",
        "properties": {
          "title": {
            "type": "string",
            "description": "Page title."
          },
          "description": {
            "type": "string",
            "description": "Meta description."
          },
          "language": {
            "type": ["string", "null"],
            "description": "Declared page language, or `null` when undeclared."
          },
          "status": {
            "type": "integer",
            "description": "HTTP status code returned by the target site."
          },
          "final_url": {
            "type": "string",
            "description": "Final URL after redirects, stripped of tracking parameters (or the canonical URL for X posts and YouTube videos)."
          },
          "truncated": {
            "type": "boolean",
            "description": "Present and `true` when the response was truncated (for example at the 2 MiB output cap). Omitted when `false`."
          },
          "login_required": {
            "type": "boolean",
            "description": "Present and `true` when the target is a sign-in wall returned as its own text (`0` credits). Omitted when `false`."
          }
        },
        "required": ["title", "description", "language", "status", "final_url"],
        "additionalProperties": false
      },
      "Data": {
        "type": "object",
        "properties": {
          "structured": {
            "$ref": "#/components/schemas/Structured",
            "description": "Normalized object the page declares itself to be (most specific schema.org type, X post, or YouTube video). Omitted when the page declares none."
          },
          "tables": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Table"
            },
            "description": "Extracted data tables from the page. Always present; empty when none are found."
          },
          "jsonld": {
            "type": "array",
            "items": {},
            "description": "Raw JSON-LD blocks from the page. Always present; empty when none exist."
          },
          "embedded": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Item"
            },
            "description": "Embedded page state blobs parsed from the page, largest first. Always present; empty when none."
          }
        },
        "required": ["tables", "jsonld", "embedded"],
        "additionalProperties": false
      },
      "Structured": {
        "type": "object",
        "properties": {
          "type": {
            "enum": [
              "recipe",
              "job",
              "event",
              "software_app",
              "creative_work",
              "local_business",
              "product",
              "article",
              "faq",
              "video",
              "listing",
              "post"
            ],
            "type": "string",
            "description": "Most specific declared object type; the object sits under the matching property."
          },
          "source": {
            "enum": ["jsonld", "microdata", "opengraph", "x", "youtube"],
            "type": "string",
            "description": "Primary declaration source (`jsonld`, `microdata`, `opengraph`, `x`, `youtube`); blank fields are filled from other sources declaring the same object."
          },
          "product": {
            "$ref": "#/components/schemas/Product",
            "description": "Declared product."
          },
          "article": {
            "$ref": "#/components/schemas/Article",
            "description": "Declared article."
          },
          "listing": {
            "$ref": "#/components/schemas/Listing",
            "description": "Declared item listing."
          },
          "recipe": {
            "$ref": "#/components/schemas/Recipe",
            "description": "Declared recipe."
          },
          "software_app": {
            "$ref": "#/components/schemas/SoftwareApp",
            "description": "Declared application or game."
          },
          "creative_work": {
            "$ref": "#/components/schemas/CreativeWork",
            "description": "Declared film, series, episode, book, album, song, or podcast."
          },
          "event": {
            "$ref": "#/components/schemas/Event",
            "description": "Declared event."
          },
          "job": {
            "$ref": "#/components/schemas/Job",
            "description": "Declared job posting."
          },
          "faq": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Answered"
            },
            "description": "Declared questions and answers."
          },
          "local_business": {
            "$ref": "#/components/schemas/LocalBusiness",
            "description": "Declared business, shop, restaurant, or hotel."
          },
          "video": {
            "$ref": "#/components/schemas/Video",
            "description": "Declared video."
          },
          "post": {
            "$ref": "#/components/schemas/Post",
            "description": "X post with author, text, counts, media, thread, quoted post, article, and the replies X shows publicly."
          }
        },
        "required": ["type", "source"],
        "additionalProperties": false
      },
      "Product": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "description": "Product name."
          },
          "price": {
            "type": "number",
            "description": "Declared price as a number."
          },
          "currency": {
            "type": "string",
            "description": "Three-letter ISO currency code, upper-cased."
          },
          "availability": {
            "type": "string",
            "description": "Schema.org availability term, such as `InStock`."
          },
          "sku": {
            "type": "string",
            "description": "Declared stock-keeping unit (SKU)."
          },
          "gtin": {
            "type": "string",
            "description": "Declared Global Trade Item Number (GTIN)."
          },
          "brand": {
            "type": "string",
            "description": "Declared brand name."
          },
          "images": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Product image URLs."
          },
          "rating": {
            "$ref": "#/components/schemas/Rating",
            "description": "Declared aggregate rating."
          },
          "url": {
            "type": "string",
            "description": "Canonical product URL."
          }
        },
        "additionalProperties": false
      },
      "Rating": {
        "type": "object",
        "properties": {
          "value": {
            "type": "number",
            "description": "Average rating value."
          },
          "count": {
            "type": "integer",
            "description": "Number of ratings or reviews averaged."
          }
        },
        "additionalProperties": false
      },
      "Article": {
        "type": "object",
        "properties": {
          "title": {
            "type": "string",
            "description": "Article headline or title."
          },
          "author": {
            "type": "string",
            "description": "Declared author name(s)."
          },
          "published": {
            "type": "string",
            "description": "Publication date or timestamp."
          },
          "updated": {
            "type": "string",
            "description": "Last-modified date or timestamp."
          },
          "site": {
            "type": "string",
            "description": "Publisher or site name."
          },
          "image": {
            "type": "string",
            "description": "Lead image URL."
          }
        },
        "additionalProperties": false
      },
      "Listing": {
        "type": "object",
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ListingItem"
            },
            "description": "Listed items."
          },
          "count": {
            "type": "integer",
            "description": "Total number of items declared."
          }
        },
        "additionalProperties": false
      },
      "ListingItem": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "description": "Item name."
          },
          "url": {
            "type": "string",
            "description": "Item URL."
          },
          "price": {
            "type": "number",
            "description": "Declared item price."
          },
          "image": {
            "type": "string",
            "description": "Item image URL."
          }
        },
        "additionalProperties": false
      },
      "Recipe": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "description": "Recipe title."
          },
          "ingredients": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Ingredient lines."
          },
          "steps": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Instruction steps."
          },
          "prep_time": {
            "type": "string",
            "description": "Preparation time, typically ISO 8601 duration."
          },
          "cook_time": {
            "type": "string",
            "description": "Cooking time, typically ISO 8601 duration."
          },
          "total_time": {
            "type": "string",
            "description": "Total time, typically ISO 8601 duration."
          },
          "servings": {
            "type": "string",
            "description": "Declared yield or servings."
          },
          "nutrition": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            },
            "description": "Nutrition facts keyed by schema.org property name."
          },
          "rating": {
            "$ref": "#/components/schemas/Rating",
            "description": "Declared aggregate rating."
          },
          "author": {
            "type": "string",
            "description": "Recipe author."
          },
          "image": {
            "type": "string",
            "description": "Lead recipe image URL."
          }
        },
        "additionalProperties": false
      },
      "SoftwareApp": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "description": "Application or game name."
          },
          "os": {
            "type": "string",
            "description": "Supported operating system(s)."
          },
          "category": {
            "type": "string",
            "description": "Application category."
          },
          "price": {
            "type": "number",
            "description": "Declared price."
          },
          "currency": {
            "type": "string",
            "description": "Three-letter ISO currency code, upper-cased."
          },
          "rating": {
            "$ref": "#/components/schemas/Rating",
            "description": "Declared aggregate rating."
          },
          "developer": {
            "type": "string",
            "description": "Author, publisher, or developer name."
          }
        },
        "additionalProperties": false
      },
      "CreativeWork": {
        "type": "object",
        "properties": {
          "kind": {
            "type": "string",
            "description": "Declared schema.org type, such as `Movie`, `Book`, or `TVSeries`."
          },
          "name": {
            "type": "string",
            "description": "Title of the work."
          },
          "date": {
            "type": "string",
            "description": "Publication, creation, or release date."
          },
          "rating": {
            "$ref": "#/components/schemas/Rating",
            "description": "Declared aggregate rating."
          },
          "genre": {
            "type": "string",
            "description": "Declared genre(s)."
          },
          "directors": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Director names."
          },
          "actors": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Actor names."
          },
          "authors": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Author, creator, or artist names."
          },
          "duration": {
            "type": "string",
            "description": "Duration, typically ISO 8601 (for example `PT2H22M`)."
          },
          "image": {
            "type": "string",
            "description": "Cover or poster image URL."
          }
        },
        "additionalProperties": false
      },
      "Event": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "description": "Event name."
          },
          "start": {
            "type": "string",
            "description": "Event start date or timestamp."
          },
          "end": {
            "type": "string",
            "description": "Event end date or timestamp."
          },
          "location": {
            "type": "string",
            "description": "Venue or address as one line of text."
          },
          "organizer": {
            "type": "string",
            "description": "Event organizer name."
          },
          "price": {
            "type": "number",
            "description": "Lowest or declared ticket price."
          },
          "currency": {
            "type": "string",
            "description": "Three-letter ISO currency code, upper-cased."
          },
          "url": {
            "type": "string",
            "description": "Event URL."
          }
        },
        "additionalProperties": false
      },
      "Job": {
        "type": "object",
        "properties": {
          "title": {
            "type": "string",
            "description": "Job title."
          },
          "company": {
            "type": "string",
            "description": "Hiring organization name."
          },
          "location": {
            "type": "string",
            "description": "Job location or remote type."
          },
          "salary": {
            "type": "string",
            "description": "Declared base or estimated salary."
          },
          "posted": {
            "type": "string",
            "description": "Date the job was posted."
          },
          "employment_type": {
            "type": "string",
            "description": "Employment type, such as `FULL_TIME` or `CONTRACTOR`."
          }
        },
        "additionalProperties": false
      },
      "Answered": {
        "type": "object",
        "properties": {
          "question": {
            "type": "string",
            "description": "Question text."
          },
          "answer": {
            "type": "string",
            "description": "Accepted or suggested answer text."
          }
        },
        "additionalProperties": false
      },
      "LocalBusiness": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "description": "Business name."
          },
          "address": {
            "type": "string",
            "description": "Street address as one line of text."
          },
          "phone": {
            "type": "string",
            "description": "Declared telephone number."
          },
          "hours": {
            "type": "string",
            "description": "Declared opening hours."
          },
          "rating": {
            "$ref": "#/components/schemas/Rating",
            "description": "Declared aggregate rating."
          }
        },
        "additionalProperties": false
      },
      "Video": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "description": "Video title."
          },
          "duration": {
            "type": "string",
            "description": "Video length as an ISO 8601 duration (`PT3M33S`); omitted for live streams."
          },
          "uploaded": {
            "type": "string",
            "description": "Upload or publication date."
          },
          "thumbnail": {
            "type": "string",
            "description": "Thumbnail image URL."
          },
          "url": {
            "type": "string",
            "description": "Video URL."
          },
          "description": {
            "type": "string",
            "description": "Video description with line breaks preserved."
          },
          "channel": {
            "$ref": "#/components/schemas/Channel",
            "description": "Channel that published the video."
          },
          "views": {
            "type": "integer",
            "description": "View count."
          },
          "transcript": {
            "$ref": "#/components/schemas/Transcript",
            "description": "Video transcript when captions are available."
          }
        },
        "additionalProperties": false
      },
      "Channel": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "description": "Channel or publisher name."
          },
          "url": {
            "type": "string",
            "description": "Channel page URL."
          }
        },
        "additionalProperties": false
      },
      "Transcript": {
        "type": "object",
        "properties": {
          "language": {
            "type": "string",
            "description": "Caption language name."
          },
          "language_code": {
            "type": "string",
            "description": "Caption language code."
          },
          "generated": {
            "type": "boolean",
            "description": "Present and `true` when captions are auto-generated. Omitted when manual."
          },
          "text": {
            "type": "string",
            "description": "Full transcript text."
          },
          "segments": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TranscriptSegment"
            },
            "description": "Timestamped caption segments in order."
          }
        },
        "additionalProperties": false
      },
      "TranscriptSegment": {
        "type": "object",
        "properties": {
          "start": {
            "type": "number",
            "description": "Segment start time in seconds."
          },
          "duration": {
            "type": "number",
            "description": "Segment duration in seconds."
          },
          "text": {
            "type": "string",
            "description": "Caption text for this segment."
          }
        },
        "required": ["start", "duration", "text"],
        "additionalProperties": false
      },
      "Post": {
        "type": "object",
        "properties": {
          "author": {
            "type": "string",
            "description": "Author display name."
          },
          "handle": {
            "type": "string",
            "description": "Author X handle without the leading `@`."
          },
          "url": {
            "type": "string",
            "description": "Canonical post URL (`https://x.com/<handle>/status/<id>`)."
          },
          "published": {
            "type": "string",
            "description": "Publication timestamp in UTC."
          },
          "text": {
            "type": "string",
            "description": "Full post text with line breaks and expanded links."
          },
          "likes": {
            "type": "integer",
            "description": "Like count."
          },
          "reposts": {
            "type": "integer",
            "description": "Repost count."
          },
          "replies": {
            "type": "integer",
            "description": "Reply count."
          },
          "quotes": {
            "type": "integer",
            "description": "Quote-post count."
          },
          "bookmarks": {
            "type": "integer",
            "description": "Bookmark count."
          },
          "views": {
            "type": "integer",
            "description": "View count."
          },
          "media": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Image URLs attached to the post (video thumbnail for videos)."
          },
          "thread": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Text of the author's own consecutive replies in order."
          },
          "quoted": {
            "$ref": "#/components/schemas/Post",
            "description": "Quoted post, if the post quotes another."
          },
          "article": {
            "$ref": "#/components/schemas/PostArticle",
            "description": "X article attached to the post, if present."
          },
          "comments": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Post"
            },
            "description": "Public replies X shows under the post and its thread to a visitor who is not signed in, in X's order."
          },
          "in_reply_to": {
            "type": "string",
            "description": "For a post in `comments`: URL of the post it answers."
          }
        },
        "additionalProperties": false
      },
      "PostArticle": {
        "type": "object",
        "properties": {
          "title": {
            "type": "string",
            "description": "X article title."
          },
          "markdown": {
            "type": "string",
            "description": "X article body formatted as markdown."
          }
        },
        "additionalProperties": false
      },
      "Table": {
        "type": "object",
        "properties": {
          "source": {
            "enum": ["html", "list", "embedded", "document"],
            "type": "string",
            "description": "Origin of the table: `html` for an HTML table, `list` for repeated page cards, `embedded` for a record array in page state or JSON-LD, `document` for a document."
          },
          "headers": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Column headings, or empty if the table has none."
          },
          "rows": {
            "type": "array",
            "items": {
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            "description": "Table rows, each a list of cell strings."
          }
        },
        "required": ["source", "headers", "rows"],
        "additionalProperties": false
      },
      "Item": {
        "type": "object",
        "properties": {
          "source": {
            "enum": ["next-data", "json-script", "inline", "document"],
            "type": "string",
            "description": "Where the blob came from: `next-data`, `json-script`, `inline` JS assignment, or `document` for a JSON response."
          },
          "key": {
            "type": ["string", "null"],
            "description": "Variable name or script `id` holding the blob, or `null` if unnamed."
          },
          "bytes": {
            "type": "integer",
            "description": "Raw blob size in UTF-8 bytes."
          },
          "value": {
            "description": "Parsed JSON value (nested JSON strings decoded)."
          }
        },
        "required": ["source", "key", "bytes", "value"],
        "additionalProperties": false
      },
      "Usage": {
        "type": "object",
        "properties": {
          "credits": {
            "type": "integer",
            "description": "Credits charged for this request: `1` for a page, or `0` for a sign-in wall."
          },
          "remaining": {
            "type": "integer",
            "description": "Credit balance remaining after this request."
          }
        },
        "required": ["credits", "remaining"],
        "additionalProperties": false
      },
      "Fail": {
        "type": "object",
        "properties": {
          "success": {
            "enum": [false],
            "type": "boolean",
            "description": "Always `false` on error responses."
          },
          "request_id": {
            "type": "string",
            "description": "Unique request identifier, echoed in the `x-request-id` header."
          },
          "error": {
            "$ref": "#/components/schemas/Error",
            "description": "Structured reason for the failure and retry guidance."
          }
        },
        "required": ["success", "request_id", "error"],
        "additionalProperties": false
      },
      "Error": {
        "type": "object",
        "properties": {
          "code": {
            "enum": [
              "UNSAFE_URL",
              "HOST_NOT_FOUND",
              "NOT_FOUND",
              "GONE",
              "LOGIN_REQUIRED",
              "UNSUPPORTED_CONTENT",
              "SCANNED_PDF",
              "BLOCKED",
              "NO_CONTENT",
              "TARGET_ERROR",
              "TIMEOUT",
              "ENGINE_FAILED",
              "INSUFFICIENT_CREDITS",
              "RATE_LIMITED",
              "INVALID_REQUEST",
              "UNAUTHORIZED",
              "ACCOUNT_SUSPENDED",
              "ROUTE_NOT_FOUND",
              "METHOD_NOT_ALLOWED",
              "INTERNAL"
            ],
            "type": "string",
            "description": "Machine-readable error code. See Errors and retries."
          },
          "message": {
            "type": "string",
            "description": "Human- and agent-readable summary."
          },
          "retryable": {
            "type": "boolean",
            "description": "Whether retrying the same request may succeed. Always read this flag on the response rather than assuming from `code`."
          },
          "doc_url": {
            "type": "string",
            "description": "Link to this error code's documentation entry."
          },
          "param": {
            "type": "string",
            "description": "Request field that failed validation on `INVALID_REQUEST`, when applicable."
          },
          "required_credits": {
            "type": "integer",
            "description": "Credits required for this request on `INSUFFICIENT_CREDITS`."
          },
          "target_status": {
            "type": "integer",
            "description": "HTTP status code returned by the target site, when it answered."
          },
          "vendor": {
            "type": "string",
            "description": "Protection service that refused the page, when identified."
          }
        },
        "required": ["code", "message", "retryable", "doc_url"],
        "additionalProperties": false
      },
      "AccountSuccess": {
        "type": "object",
        "properties": {
          "success": {
            "enum": [true],
            "type": "boolean",
            "description": "Always `true` on success."
          },
          "request_id": {
            "type": "string",
            "description": "Unique request identifier, echoed in the `x-request-id` header."
          },
          "data": {
            "$ref": "#/components/schemas/AccountData",
            "description": "The account and the key that made the request."
          }
        },
        "required": ["success", "request_id", "data"],
        "additionalProperties": false
      },
      "AccountData": {
        "type": "object",
        "properties": {
          "email": {
            "type": "string",
            "description": "Email address of the account."
          },
          "credits": {
            "$ref": "#/components/schemas/AccountCredits",
            "description": "Credit balance and holds."
          },
          "limits": {
            "$ref": "#/components/schemas/AccountLimits",
            "description": "Scrape rate and concurrency."
          },
          "key": {
            "$ref": "#/components/schemas/AccountKey",
            "description": "The API key that made the request."
          }
        },
        "required": ["email", "credits", "limits", "key"],
        "additionalProperties": false
      },
      "AccountCredits": {
        "type": "object",
        "properties": {
          "balance": {
            "type": "integer",
            "description": "Credits the account can spend."
          },
          "held": {
            "type": "integer",
            "description": "Credits held by requests still running, settled when they end."
          }
        },
        "required": ["balance", "held"],
        "additionalProperties": false
      },
      "AccountLimits": {
        "type": "object",
        "properties": {
          "rate_limit_per_min": {
            "type": "integer",
            "description": "Scrape requests the account may start per minute."
          },
          "max_concurrency": {
            "type": "integer",
            "description": "Scrape requests the account may run at once."
          }
        },
        "required": ["rate_limit_per_min", "max_concurrency"],
        "additionalProperties": false
      },
      "AccountKey": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "Identifier of the API key that made the request."
          },
          "prefix": {
            "type": "string",
            "description": "First characters of the key, safe to show."
          },
          "name": {
            "type": "string",
            "description": "Name given to the key, or empty."
          },
          "scope": {
            "enum": ["scrape", "cli"],
            "type": "string",
            "description": "`scrape` for keys created on the Keys page; `cli` for the key `crawl login` collects."
          }
        },
        "required": ["id", "prefix", "name", "scope"],
        "additionalProperties": false
      },
      "KeyRevoked": {
        "type": "object",
        "properties": {
          "success": {
            "enum": [true],
            "type": "boolean",
            "description": "Always `true` on success."
          },
          "request_id": {
            "type": "string",
            "description": "Unique request identifier, echoed in the `x-request-id` header."
          },
          "revoked": {
            "type": "boolean",
            "description": "`true` when this request revoked the key; `false` when it was already revoked."
          }
        },
        "required": ["success", "request_id", "revoked"],
        "additionalProperties": false
      },
      "MarkdownScrapeData": {
        "type": "object",
        "properties": {
          "metadata": {
            "$ref": "#/components/schemas/Metadata",
            "description": "Page metadata and completion flags."
          },
          "links": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Unique absolute `http(s)` URLs from the whole page in document order (entry links for RSS/Atom feeds; empty for other documents)."
          },
          "markdown": {
            "type": "string",
            "description": "Extracted page text in markdown, up to 2 MiB. Present when `format` is `markdown`."
          }
        },
        "required": ["metadata", "links", "markdown"],
        "additionalProperties": false
      },
      "JsonScrapeData": {
        "type": "object",
        "properties": {
          "metadata": {
            "$ref": "#/components/schemas/Metadata",
            "description": "Page metadata and completion flags."
          },
          "links": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Unique absolute `http(s)` URLs from the whole page in document order (entry links for RSS/Atom feeds; empty for other documents)."
          },
          "json": {
            "$ref": "#/components/schemas/Data",
            "description": "Extracted structured data. Present when `format` is `json`."
          }
        },
        "required": ["metadata", "links", "json"],
        "additionalProperties": false
      }
    },
    "headers": {
      "X-Request-Id": {
        "description": "Unique request identifier (`req_...`). Quote this value to support.",
        "schema": {
          "type": "string",
          "example": "req_1dc0a514d6ee71c4524b"
        }
      },
      "RateLimit-Policy": {
        "description": "Account rate-limit policy sent on authenticated responses: `\"minute\"` sets `q` requests per minute (`w=60`), `\"concurrency\"` sets `q` in-flight requests at once.",
        "schema": {
          "type": "string",
          "example": "\"minute\";q=200;w=60, \"concurrency\";q=10;qu=\"concurrent-requests\""
        }
      },
      "RateLimit": {
        "description": "Remaining quota when the response leaves: `\"minute\";r=` requests that can start now and `t=` seconds until the next token refills (omitted when your full per-minute allowance is available); `\"concurrency\";r=` free in-flight slots.",
        "schema": {
          "type": "string",
          "example": "\"minute\";r=199;t=1, \"concurrency\";r=10"
        }
      },
      "Retry-After": {
        "description": "Whole seconds to wait before retrying.",
        "schema": {
          "type": "integer",
          "minimum": 1,
          "example": 1
        }
      },
      "Allow": {
        "description": "HTTP methods accepted on this route.",
        "schema": {
          "type": "string",
          "example": "POST"
        }
      },
      "WWW-Authenticate": {
        "description": "Authentication scheme expected for this endpoint.",
        "schema": {
          "type": "string",
          "example": "Bearer realm=\"crawlapi\""
        }
      }
    },
    "securitySchemes": {
      "bearer": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "ck_...",
        "description": "Send your API key in `Authorization: Bearer <key>`. Keys start with `ck_` and are created at https://app.crawlapi.dev/keys."
      },
      "apiKey": {
        "type": "apiKey",
        "in": "header",
        "name": "x-api-key",
        "description": "Alternative header for your API key (`ck_...`)."
      }
    }
  }
}
