> ## Documentation Index
> Fetch the complete documentation index at: https://docs.prefetch.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Quickstart

> Get an API key and make your first Prefetch API call in under 5 minutes.

> [!TIP]
>
> Using Claude, ChatGPT or Cursor? Skip the code: [connect Prefetch over MCP](https://docs.prefetch.io/mcp/overview.md) and ask in plain language. To have a coding agent do this setup for you, use the [agent quickstart](https://docs.prefetch.io/agent-quickstart.md).

**1. Get an API key**

Sign up and copy your key from the [dashboard](https://prefetch.io/dashboard). The Free plan includes 1,000 credits a month. Set the key in your shell:

```bash theme={"theme":"css-variables"}
export PREFETCH_API_KEY="your_api_key_here"
```

Keep it on your server. Don't commit it or put it in browser code.

**2. Make a request**

`/classify` tells you what kind of business a website is. It costs 5 credits.

```bash theme={"theme":"css-variables"}
curl "https://api.prefetch.io/classify?url=https://stripe.com" \
  -H "X-API-Key: $PREFETCH_API_KEY"
```

**3. Check the response**

Every response has the same envelope: `success`, then `data`, then `meta`.

```json theme={"theme":"css-variables"}
{
  "success": true,
  "data": {
    "domain": "stripe.com",
    "url": "https://stripe.com/",
    "classification": {
      "iab_id": "IAB3-4",
      "iab_parent_id": "IAB3",
      "category": "Business",
      "subcategory": "Business Software",
      "tagline_description": "A developer-first payments and financial infrastructure platform for online and in-person commerce.",
      "description": "A payments and financial-technology platform that lets businesses accept and process online and in-person payments…",
      "stock_tickers": [],
      "isins": []
    }
  },
  "meta": {
    "requestId": "a3f2c1d4-7b6e-4f2a-9c1d-8e3f2a1b4c5d",
    "durationMs": 196
  }
}
```

**4. Try more**

`/enrich` returns brand, company and industry in one call, for 12 credits:

```bash theme={"theme":"css-variables"}
curl "https://api.prefetch.io/enrich?url=https://stripe.com" \
  -H "X-API-Key: $PREFETCH_API_KEY"
```

## From your code

There's no SDK to install. Any HTTP client works:

```javascript Node.js theme={"theme":"css-variables"}
const res = await fetch("https://api.prefetch.io/classify?url=https://stripe.com", {
  headers: { "X-API-Key": process.env.PREFETCH_API_KEY },
});
const body = await res.json();

if (!body.success) {
  throw new Error(`${body.error_code}: ${body.error}`);
}

console.log(body.data.classification.category); // "Business"
```

```python Python theme={"theme":"css-variables"}
import os
import requests

r = requests.get(
    "https://api.prefetch.io/classify",
    params={"url": "https://stripe.com"},
    headers={"X-API-Key": os.environ["PREFETCH_API_KEY"]},
)
body = r.json()

if not body["success"]:
    raise Exception(f"{body['error_code']}: {body['error']}")

print(body["data"]["classification"]["category"])  # "Business"
```

```typescript TypeScript theme={"theme":"css-variables"}
type ClassifyResponse =
  | {
      success: true;
      data: {
        url: string;
        domain: string;
        classification: { category: string; subcategory: string | null; description: string };
      };
    }
  | { success: false; error: string; error_code: string; retryable: boolean };

const url = `https://api.prefetch.io/classify?url=${encodeURIComponent("https://stripe.com")}`;
const res = await fetch(url, { headers: { "X-API-Key": process.env.PREFETCH_API_KEY! } });
const body = (await res.json()) as ClassifyResponse;

if (!body.success) throw new Error(`${body.error_code}: ${body.error}`);
console.log(body.data.classification.category); // "Business"
```

## If the request fails

Errors use the same envelope, with `success: false`:

```json theme={"theme":"css-variables"}
{
  "success": false,
  "error": "The target URL could not be resolved. Please check the domain name.",
  "error_code": "DNS_RESOLUTION_FAILED",
  "retryable": false,
  "meta": {
    "requestId": "b9e1a2f3-4c5d-6e7f-8a9b-0c1d2e3f4a5b",
    "durationMs": 412
  }
}
```

Branch on `error_code`, not on the wording of `error`, which can change. `retryable` tells you whether the same request can succeed later.

| Status | What to do |
| - | - |
| `401` | No key reached the API. Check the `X-API-Key` header and that the environment variable is set. |
| `403` | The key is wrong, revoked or out of credits. Check `error_code`. |
| `422` | The site couldn't be read, for example `DNS_RESOLUTION_FAILED`. Check the URL. |
| `429` | Too many requests at once. Wait a moment and retry. See [Rate limits](https://docs.prefetch.io/concepts/rate-limits.md). |

Failed requests are never charged. See [Error handling](https://docs.prefetch.io/concepts/errors.md) for every code.

## Next steps

> [card] [Enrich a company](https://docs.prefetch.io/company-data/enrich.md)
>
> Brand, company and industry in one call.

> [card] [Scrape a page](https://docs.prefetch.io/web-data/scrape.md)
>
> Any page as markdown or structured JSON.

> [card] [Recipes](https://docs.prefetch.io/recipes/overview.md)
>
> Complete examples you can copy, or hand to a coding agent.

> [card] [Credits](https://docs.prefetch.io/concepts/credits.md)
>
> What each call costs.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.