# Quickstart

> Create an API key, send your first Google SERP request with cURL, Python or Node, and read the response.

This page takes you from no key to a parsed Google results page in a few minutes.

## 1. Create an API key

1. Sign in and open **Dashboard → Developers**. You need a verified email address to create keys.
2. Create a key. It starts with `dg_` and is shown once, so copy it now. We store only a SHA-256 hash of it.
3. Put it in an environment variable so it stays out of your code:

```bash
export DATAFORGAIO_API_KEY="dg_..."
```

Your organization's wallet needs a balance for paid requests. Top it up under **Dashboard → Billing**. A request the wallet can't cover returns `40210` and costs nothing.

## 2. Send a request

This asks for the top 10 Google results for one keyword in the United States, in English, and returns them in the same response (the live mode).



```bash title="cURL"
curl -X POST "https://api.dataforgaio.com/v1/serp/google/organic/live/advanced" \
  -u "api:$DATAFORGAIO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '[{
    "keyword": "trail running shoes",
    "location_code": 2840,
    "language_code": "en",
    "depth": 10
  }]'
```

```python title="Python"
import os
import requests

res = requests.post(
    "https://api.dataforgaio.com/v1/serp/google/organic/live/advanced",
    auth=("api", os.environ["DATAFORGAIO_API_KEY"]),  # any login, your key as the password
    json=[{
        "keyword": "trail running shoes",
        "location_code": 2840,
        "language_code": "en",
        "depth": 10,
    }],
    timeout=120,
)
body = res.json()
task = body["tasks"][0]
print(task["status_code"], task["status_message"], task["cost"])
if task["status_code"] == 20000:
    for item in task["result"][0]["items"]:
        print(item["rank_absolute"], item["domain"], item["url"])
```

```js title="Node"
const auth = Buffer.from(`api:${process.env.DATAFORGAIO_API_KEY}`).toString("base64");

const res = await fetch("https://api.dataforgaio.com/v1/serp/google/organic/live/advanced", {
  method: "POST",
  headers: { Authorization: `Basic ${auth}`, "Content-Type": "application/json" },
  body: JSON.stringify([
    { keyword: "trail running shoes", location_code: 2840, language_code: "en", depth: 10 },
  ]),
});
const body = await res.json();
const task = body.tasks[0];
console.log(task.status_code, task.status_message, task.cost);
if (task.status_code === 20000) {
  for (const item of task.result[0].items) console.log(item.rank_absolute, item.domain, item.url);
}
```



`location_code` 2840 is the United States. Country codes are 2000 plus the ISO 3166-1 numeric code; see [Locations and languages](https://dataforgaio.com/docs/locations-and-languages.md).

## 3. Read the response

Every compatible endpoint returns the same envelope: request-level fields, then one entry in `tasks` per task you sent. Trimmed:

```json
{
  "version": "0.1.20261203",
  "status_code": 20000,
  "status_message": "Ok.",
  "time": "1.8412 sec.",
  "cost": 0.0018,
  "tasks_count": 1,
  "tasks_error": 0,
  "tasks": [
    {
      "id": "a275cdb0-8d25-40eb-b309-367a10f0bd5a",
      "status_code": 20000,
      "status_message": "Ok.",
      "time": "1.8398 sec.",
      "cost": 0.0018,
      "result_count": 1,
      "path": ["v1", "serp", "google", "organic", "live", "advanced"],
      "data": { "keyword": "trail running shoes", "location_code": 2840, "language_code": "en", "depth": 10 },
      "result": [
        {
          "keyword": "trail running shoes",
          "type": "organic",
          "se_domain": "google.com",
          "location_code": 2840,
          "language_code": "en",
          "check_url": "https://www.google.com/search?q=trail+running+shoes&num=10&hl=en&gl=US",
          "datetime": "2026-12-03 09:00:00 +00:00",
          "item_types": ["organic"],
          "se_results_count": 1234000,
          "pages_count": 1,
          "items_count": 10,
          "items": [
            {
              "type": "organic",
              "rank_group": 1,
              "rank_absolute": 1,
              "page": 1,
              "domain": "example.com",
              "title": "Trail running shoes",
              "url": "https://example.com/trail",
              "description": "..."
            }
          ],
          "fetched_at": "2026-12-03T09:00:00Z"
        }
      ],
      "receipt_id": "e572ab4c-3591-4e05-823f-86fb9d563688",
      "fetch_level": null,
      "upgraded": false,
      "upgrade_reason": null,
      "cache_hit": false
    }
  ]
}
```

What to check, in order:

1. **`tasks[].status_code`.** `20000` means the task returned data. Anything from `40000` up is an error for that task, and it cost $0. The top-level `status_code` only describes the request as a whole, so a request can be `20000` while one of its tasks failed. `tasks_error` counts those.
2. **`tasks[].result`.** The data, in the mirrored product's schema. Organic results are in `result[0].items`.
3. **`tasks[].cost`.** What this task cost in USD. The top-level `cost` is the sum.
4. **The last five task fields are ours.** `receipt_id`, `fetch_level`, `upgraded`, `upgrade_reason` and `cache_hit` explain how the data was fetched and billed. Clients that don't know them ignore them. See [Receipts and fetch facts](https://dataforgaio.com/docs/receipts.md).

## Next steps

- Send up to 100 tasks per request: [Making requests](https://dataforgaio.com/docs/making-requests.md).
- Pay less for scheduled work with the standard queue: [Live and queued tasks](https://dataforgaio.com/docs/task-modes.md).
- Set a ceiling on what one task may cost: [Fetch levels and Auto-upgrade](https://dataforgaio.com/docs/fetch-levels-and-auto-upgrade.md).
- Look up every field of this endpoint: [Google Organic SERP: Live Advanced](https://dataforgaio.com/docs/api/serp-google-organic-live-advanced.md).
