# Search results

`POST /v1/serp`

The top 10 organic results for one search, with a receipt recording the search URL, fetch time and a hash of the results.

Family: Crawl API

## Price

Unit: request

| Mode | Price (USD) |
|---|---|
| Live | $0.00054 |

Per search that returned results.

## Description

One search, run inline. For locations, maps, more depth or queued tasks, use the SERP API routes.

**Billing.** $0.00054 per search that returned results. A search that fails or returns nothing costs $0.

## Authentication

HTTP Basic auth: any login, with your `dg_` API key as the password. A `Bearer` token header with the key also works.

## Request

Send a JSON object.

| Field | Type | Required | Description |
|---|---|---|---|
| `keyword` | string | yes | The search, up to 700 characters. `query` and `q` are accepted too. max 700 |
| `search_engine` | string | no | Search engine. default `google`; one of `google`, `bing` |
| `country` | string | no | Two-letter country to search from. |
| `language` | string | no | Language code, for example `en` or `en-US`. |
| `device` | string | no | Device type. default `desktop`; one of `desktop`, `mobile` |
| `include_receipt` | boolean | no | Include the receipt. default `true` |
| `project_id` | string\|null | no | A project in your organization to file this under. |
| `auto_upgrade` | boolean | no | When the included route returns nothing, retry on the live route (billed at the same price). `false` stops at the included route and the search fails at $0. default `true` |
| `max_cost` | number\|null | no | The most this search may cost, USD. Below the search price, nothing runs (422 `max_cost_exceeded`). The charge never exceeds it. |
| `max_age` | integer\|null | no | Accept a cached result up to this many seconds old (0 to 86400). Default: always fetch fresh. min 0; max 86400 |

### Example request

```bash
curl -X POST "https://api.dataforgaio.com/v1/serp" \
  -u "api:$DATAFORGAIO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "keyword": "trail running shoes boulder",
  "country": "US",
  "language": "en"
}'
```

## Response

| Field | Type | Description |
|---|---|---|
| `status` | string | Always `ok` for a 2xx response. |
| `cost` | number | What the search was charged, USD. |
| `tasks_count` | integer | Always 1. |
| `tasks_error` | integer | 1 when the search failed. |
| `tasks` | array<object> | The search. |
| `tasks.id` | string | Search id, `sr_…`. |
| `tasks.status` | string | `completed` or `failed`. one of `completed`, `failed`, `processing` |
| `tasks.status_code` | integer | 200, or 502/503 when it failed. |
| `tasks.status_message` | string | Plain-language status. |
| `tasks.cost` | number | Charged, USD. |
| `tasks.content` | object | The results. Present when completed. |
| `tasks.content.query` | string | The search. |
| `tasks.content.search_engine` | string | Search engine. |
| `tasks.content.country` | string\|null | Country, lowercase. |
| `tasks.content.language` | string\|null | Language. |
| `tasks.content.device` | string | Device. |
| `tasks.content.items_count` | integer | Entries in `organic`. |
| `tasks.content.organic` | array<object> | Organic results in rank order. |
| `tasks.content.organic.position` | integer | Rank, starting at 1. |
| `tasks.content.organic.title` | string | Result title. |
| `tasks.content.organic.url` | string | Result URL. |
| `tasks.content.organic.domain` | string | Result domain. |
| `tasks.content.organic.snippet` | string | Result snippet. |
| `tasks.error` | object | Present when failed. |
| `tasks.error.http_status` | integer | Same as `status_code`. |
| `tasks.error.code` | string | Error code. |
| `tasks.receipt` | object | Provenance and cost. Present unless `include_receipt` is false. |
| `tasks.receipt.receipt_id` | string | Receipt id, `rc_…`. |
| `tasks.receipt.source_url` | string\|null | The public search URL the results correspond to. |
| `tasks.receipt.fetched_at` | string\|null | When the results were fetched, ISO 8601 UTC. |
| `tasks.receipt.http_status` | integer\|null | HTTP status of the search. |
| `tasks.receipt.content_sha256` | string\|null | SHA-256 of the results we returned. |
| `tasks.receipt.content_check` | null | Always null for a search. |
| `tasks.receipt.robots_txt` | null | Always null for a search. |
| `tasks.receipt.ai_use_signal` | null | Always null for a search. |
| `tasks.receipt.fetch_method` | string | Always `serp_api`. |
| `tasks.receipt.cache_hit` | boolean | True when a cached result (within `max_age`) answered. |
| `tasks.receipt.upgraded` | boolean | True when the live route answered after the included route didn't. |
| `tasks.receipt.unit_cost_usd` | number\|null | Charged, USD. |
| `tasks.receipt.billed_usd` | number\|null | Same as `unit_cost_usd`. |
| `tasks.receipt.currency` | string | Always `USD`. |

### Example response

```json
{
  "status": "ok",
  "cost": 0.00054,
  "tasks_count": 1,
  "tasks_error": 0,
  "tasks": [
    {
      "id": "sr_8cbb5b5c8e155c82995945f93cdad009",
      "status": "completed",
      "status_code": 200,
      "status_message": "Ok.",
      "cost": 0.00054,
      "content": {
        "query": "trail running shoes boulder",
        "search_engine": "google",
        "country": "us",
        "language": "en",
        "device": "desktop",
        "items_count": 2,
        "organic": [
          {
            "position": 1,
            "title": "Trail running shoes | Summit Running Co.",
            "url": "https://summitrunning.example/trail-shoes",
            "domain": "summitrunning.example",
            "snippet": "Every trail shoe we stock, fitted after a free gait analysis."
          },
          {
            "position": 2,
            "title": "The best trail running shoes",
            "url": "https://www.example-gear.com/best-trail-shoes",
            "domain": "www.example-gear.com",
            "snippet": "Tested on rock, mud and snow."
          }
        ]
      },
      "receipt": {
        "receipt_id": "rc_8cbb5b5c8e155c82995945f93cdad009",
        "source_url": "https://www.google.com/search?q=trail+running+shoes+boulder&num=10&gl=us&hl=en",
        "fetched_at": "2026-12-03T10:42:18Z",
        "http_status": 200,
        "content_sha256": "b085e457d70d4053268da555d16037247e5d54ee16e182e7fca462347c269520",
        "content_check": null,
        "robots_txt": null,
        "ai_use_signal": null,
        "fetch_method": "serp_api",
        "cache_hit": false,
        "upgraded": false,
        "unit_cost_usd": 0.00054,
        "billed_usd": 0.00054,
        "currency": "USD"
      }
    }
  ]
}
```

## Errors

| Code | When |
|---|---|
| invalid_request | HTTP 400. The body failed validation. `error.details` maps each field to its problem. |
| unauthorized | HTTP 401. Missing, malformed or revoked API key. |
| balance_required | HTTP 402. Your wallet balance is below the most this request could cost. Nothing ran. |
| max_cost_exceeded | HTTP 422. `max_cost` is below the price of one search. |
| rate_limited | HTTP 429. Too many requests, or too many inline requests in flight for your organization. Honor `Retry-After`. |
| upstream_error | HTTP 502. The target or search timed out or returned an error we couldn't recover from. You weren't billed. |
| not_configured | HTTP 503. The service behind this route isn't set up on this server. You weren't billed. |
