> Documentation index: https://docs.crawlapi.dev/llms.txt
> Fetch the index before exploring further; it lists every page with its description.

# Quickstart

> Create an API key, send one request and read the page back. There is nothing to install: the API is one HTTPS endpoint.

1. ## Create a key

   Sign in at [app.crawlapi.dev/keys](https://app.crawlapi.dev/keys) and create one. It starts with `ck_` and is shown once; a lost key is revoked and replaced.

2. ## Store it, never print it

   Keep the key on the server. A page that runs in a browser calls your backend, never the API.

**Shell**

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

3. ## Send one URL

   One endpoint, three fields: `url`, `format` and `timeout`. `format` is `markdown` unless you ask for `json`.

   ```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"}'
   ```

   ```python
   import os, httpx

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

   ```javascript
   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.data.markdown);
   ```

   The request is always `POST /v1/scrape` with a JSON body; any other method answers `405`.

4. ## Read the response

   A success carries the page and what it cost.

**200 OK, 404 NOT_FOUND** (1 credit, 0 credits)

   ```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
     }
   }
   ```

   ```json
   {
     "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
     }
   }
   ```

   | Field | Holds |
   | --- | --- |
   | `success` | `true` on a success, including a sign-in wall |
   | `request_id` | also in `x-request-id`; quote it to support |
   | `data.markdown` | the page’s text, when `format` is `markdown` |
   | `data.json` | the page’s structured data, when `format` is `json` |
   | `data.metadata` | title, description, language, status, `final_url`, `truncated`, `login_required` |
   | `data.links` | every absolute URL on the page |
   | `usage` | `credits` charged and `remaining` balance |

5. ## Handle a failure

   A failed request answers `success: false` and costs nothing. Branch on `error.code`, and on `retryable` to decide whether the same request can succeed later; `error.doc_url` links to the code's entry, with what to do.

   > **Failures cost 0 credits**
   > Challenge pages, 404s and empty shells come back as a code, never as a success. See [Errors and retries](/errors).
