---
agent:
  instructions: "Search crawlapi docs via GET /.well-known/search?q={query} (add &format=json or Accept: application/json for JSON)."
  endpoint: "https://docs.crawlapi.dev/.well-known/search?q={query}"
  method: "GET"
  documentation: "https://docs.crawlapi.dev/llms.txt"
---

> Documentation index: https://docs.crawlapi.dev/llms.txt
> Search docs: https://docs.crawlapi.dev/.well-known/search?q={query}
> OpenAPI 3.1 specification: https://docs.crawlapi.dev/openapi.json

# Quickstart

> Create an API key, send your first `POST /v1/scrape` request, and read the response.

Run your first `POST /v1/scrape` call with cURL, TypeScript, or Python. If you want your coding agent to wire crawlapi into a repo for you, start with the [Agent quickstart](https://docs.crawlapi.dev/agent-quickstart.md) or connect the [MCP server](https://docs.crawlapi.dev/mcp.md).

1. ## Create an API key

   Sign in at [app.crawlapi.dev/keys](https://app.crawlapi.dev/keys) and generate a key. Keys start with `ck_` and are displayed once. Buy a credit pack at [app.crawlapi.dev/billing](https://app.crawlapi.dev/billing), or try 10 pages in the [web playground](https://app.crawlapi.dev/playground) first.

2. ## Export your key

   Keep the key in your server environment or a gitignored `.env` file. Keep it out of git history and client-side browser bundles.

   **Shell**

   ```bash
   export CRAWLAPI_API_KEY="ck_..."
   ```

3. ## Send your first request

   `POST /v1/scrape` takes `url` (required), optional `format` (`markdown` or `json`), and optional `timeout` (`1000`–`60000` ms, default `30000`). Set your HTTP client timeout slightly longer than `timeout`.

   **cURL**

   ```bash
   curl -sS https://api.crawlapi.dev/v1/scrape \
     -H "Authorization: Bearer $CRAWLAPI_API_KEY" \
     -H 'content-type: application/json' \
     --data '{"url": "https://example.com"}'
   ```

   **TypeScript**

   ```typescript
   const response = await fetch('https://api.crawlapi.dev/v1/scrape', {
     method: 'POST',
     headers: {
       Authorization: `Bearer ${process.env.CRAWLAPI_API_KEY}`,
       'content-type': 'application/json',
     },
     body: JSON.stringify({ url: 'https://example.com' }),
   });
   const body = await response.json();
   console.log(body.success ? body.data.markdown : body.error);
   ```

   **Python**

   ```python
   import os
   import requests

   response = requests.post(
       "https://api.crawlapi.dev/v1/scrape",
       headers={"Authorization": f"Bearer {os.environ['CRAWLAPI_API_KEY']}"},
       json={"url": "https://example.com"},
       timeout=65,
   )
   body = response.json()
   print(body["data"]["markdown"] if body["success"] else body["error"])
   ```

4. ## Read the response

   Check `body.success` before reading `data`. Optional metadata flags (`truncated`, `login_required`) appear only when `true`.

   ```json
   {
     "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. This is not a service; avoid relying on it for testing and monitoring purposes."
     },
     "usage": {
       "credits": 1,
       "remaining": 9999
     }
   }
   ```

   | Field | Meaning |
   | --- | --- |
   | `success` | `true` on success, `false` on failure |
   | `request_id` | Echoed in `x-request-id`; include it when contacting support |
   | `data.markdown` | Clean page text (present when `format` is `markdown`) |
   | `data.json` | Structured page data (present when `format` is `json`) |
   | `data.metadata` | `title`, `description`, `language`, `status`, `final_url`, plus optional `truncated` and `login_required` |
   | `data.links` | Unique absolute `http(s)` URLs from the page (entry links for RSS/Atom feeds; `[]` for other documents) |
   | `usage` | `credits` charged for this request and your `remaining` balance |

## Try other inputs

Every scrape uses the same endpoint and `Authorization` header:

| Goal | Request body | Guide |
| --- | --- | --- |
| Structured entities & tables | `{"url": "https://www.imdb.com/title/tt0111161/", "format": "json"}` | [Structured JSON](https://docs.crawlapi.dev/json.md) |
| PDF, Office, CSV, or feed | `{"url": "https://arxiv.org/pdf/1706.03762"}` | [PDFs & documents](https://docs.crawlapi.dev/documents.md) |
| X post or YouTube video | `{"url": "https://www.youtube.com/watch?v=rfscVS0vtbw"}` | [X & YouTube](https://docs.crawlapi.dev/special-sites.md) |
| Custom request deadline | `{"url": "https://example.com", "timeout": 45000}` | [Timeouts](https://docs.crawlapi.dev/timeouts.md) |

## If the request fails

Failed requests return `success: false` with a machine-readable `error.code`.

| Status | What to do |
| --- | --- |
| `400` | Fix the field named in `error.param` and `error.message` before retrying. |
| `401` | Verify that `CRAWLAPI_API_KEY` is exported and active at [app.crawlapi.dev/keys](https://app.crawlapi.dev/keys). |
| `402` | Buy credits at [app.crawlapi.dev/billing](https://app.crawlapi.dev/billing) before retrying. |
| `408` | The page exceeded your `timeout` deadline. Raise `timeout` up to `60000` ms or see [Timeouts](https://docs.crawlapi.dev/timeouts.md). |
| `422` / `429` | Branch on `error.code` and `error.retryable`; wait `Retry-After` seconds on `429`. |

See [Errors and retries](https://docs.crawlapi.dev/errors.md) for retry helpers and every error code.

## Next steps

- [Markdown](https://docs.crawlapi.dev/markdown.md) See what is kept, stripped, and how links are normalized.
- [Structured JSON](https://docs.crawlapi.dev/json.md) Extract normalized entities, tables, JSON-LD, and embedded state.
- [Errors & retries](https://docs.crawlapi.dev/errors.md) Copy production TypeScript and Python retry loops.
- [API reference](https://docs.crawlapi.dev/api-reference/scrape.md) Inspect the full OpenAPI schema, headers, and live runner.
