# DataForAPI v1 — Developer & AI Agent Documentation

> One key for every data API. Real-time SERP, Keyword Volume, Google Trends, Backlinks, Search Labs, and On-Page SEO JSON over REST `/v1` and Streamable HTTP `/mcp`.

- **Base REST URL**: `https://dataforapi.com/v1`
- **Remote MCP Server**: `https://dataforapi.com/mcp` (Streamable HTTP, Protocol `2025-03-26`)
- **Interactive Playground**: `https://dataforapi.com/playground`
- **Agent Skill**: `https://dataforapi.com/skills/dataforapi/SKILL.md`
- **Zero-Dep CLI**: `https://dataforapi.com/skills/dataforapi/dfa.mjs`

---

## 1. Quickstart

```bash
curl -X POST "https://dataforapi.com/v1/serp/google/organic/live/advanced" \
  -H "Authorization: Bearer dfa_test_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '[{"keyword":"serp api","location_code":2840,"language_code":"en","depth":10}]'
```

## 2. Authentication, Keys & Precision Billing

- **Headers**: `Authorization: Bearer <KEY>`, `X-API-Key: <KEY>`, or HTTP Basic `base64(email:KEY)`.
- **Sandbox Keys (`dfa_test_...`)**: `$0.00` deterministic schema & integration testing.
- **Live Keys (`dfa_live_...`)**: Billed against your non-expiring prepaid USD balance (`1 USD = 1,000,000 micro-USD`).
- **Response Headers**: `X-Cost-USD`, `X-Saved-USD`, `X-Cache-Status` (`HIT` saves 25% on Live calls >= `$0.002`), `X-Latency-Ms`, `X-Environment`.
- **Failure Safety**: Worst-case micro-USD is pre-authorized upfront; unused row headroom and any `5xx`/timeout refund 100% automatically.

### Status Codes

| Code | HTTP | Meaning | Billed |
|---|---|---|---|
| `20000` | 200 | Ok — synchronous response or completed task retrieved. | Exact settled USD |
| `20100` | 200 | Task Created — async task queued via /task_post. | Task queue rate |
| `40000` | 400 | Validation error — invalid JSON array, parameter out of range, or SSRF blocked. | $0.00 |
| `40100` | 401 | Unauthorized — missing, revoked, or malformed API key. | $0.00 |
| `40102` | 200 | No Search Results — valid query returned zero SERP listings. | Standard SERP rate |
| `40200` | 402 | Insufficient USD balance for worst-case request pre-authorization. | $0.00 |
| `40203` | 429 | Per-key UTC daily USD spending limit reached; resets at 00:00 UTC. | $0.00 |
| `40400` | 404 | Endpoint path not found under /v1/<family>/<endpoint>. | $0.00 |
| `40401` | 404 | Async task ID not found or belongs to a different account/environment. | $0.00 |
| `40602` | 200 | Task In Queue — async task still processing; retry /task_get shortly. | $0.00 (free poll) |
| `42900` | 429 | Edge burst rate limit exceeded. | $0.00 |
| `50000` | 502 | Upstream execution error or timeout — 100% of reserved balance auto-refunded. | $0.00 (refunded) |

## 3. SERP API (`/v1/serp/*`)

### Google Organic & AI Overview SERP (Live)
- **Endpoint**: `POST /v1/serp/google/organic/live/advanced`
- **Pricing**: $0.0020 / SERP (10 results) · +$0.0020 when load_async_ai_overview=true · $0.00 Sandbox
- **Summary**: Returns real-time desktop or mobile Google search results including organic listings, AI Overviews with cited URLs, People Also Ask trees, Local 3-Packs, and Knowledge Graph modules.

| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| `keyword` | `string` | Yes | — | UTF-8 search query (up to 700 characters). |
| `location_code` | `integer` | No | 2840 | Country, state, city, or postal geo code (2840 = US, 2826 = UK, 2276 = DE, 2392 = JP). |
| `language_code` | `string` | No | "en" | ISO 639-1 language code ("en", "de", "ja", "es", "fr"). |
| `device` | `"desktop" | "mobile"` | No | "desktop" | Viewport and user-agent profile. |
| `depth` | `integer (1–100)` | No | 10 | Number of results to retrieve (billed per 10-result SERP page). |
| `load_async_ai_overview` | `boolean` | No | false | Expand dynamically rendered AI Overview markdown and source citations (+$0.0020). |
| `people_also_ask_click_depth` | `integer (0–4)` | No | 0 | Expand nested People Also Ask accordions. |
| `tag` | `string` | No | — | Optional caller correlation tag echoed back in tasks[].data.tag. |

**Request Body**:
```json
[
  {
    "keyword": "serp api",
    "location_code": 2840,
    "language_code": "en",
    "device": "desktop",
    "depth": 10,
    "load_async_ai_overview": true
  }
]
```

**Sample Response**:
```json
{
  "version": "1.0",
  "status_code": 20000,
  "status_message": "Ok.",
  "cost": 0.004,
  "tasks_count": 1,
  "tasks_error": 0,
  "tasks": [
    {
      "id": "0194b8f0-7c2a-7000-8000-000000000001",
      "status_code": 20000,
      "cost": 0.004,
      "path": [
        "v1",
        "serp",
        "google",
        "organic",
        "live",
        "advanced"
      ],
      "result": [
        {
          "keyword": "serp api",
          "se_results_count": 14800000,
          "items_count": 2,
          "items": [
            {
              "type": "organic",
              "rank_group": 1,
              "domain": "dataforapi.com",
              "title": "One Key for Every Data API | DataForAPI",
              "url": "https://dataforapi.com/"
            }
          ]
        }
      ]
    }
  ]
}
```

### Async SERP Queue (task_post → tasks_ready → task_get)
- **Endpoint**: `POST /v1/serp/google/organic/task_post`
- **Pricing**: $0.0006 Standard (priority=1) · $0.0012 Priority (priority=2) · $0.00 polling
- **Summary**: For high-volume rank tracking that does not need sub-3-second latency, submit up to 100 tasks per POST to /task_post at 70% lower cost ($0.60 per 1,000 SERPs). Poll GET /v1/serp/google/organic/tasks_ready and retrieve via GET /v1/serp/google/organic/task_get/advanced/{id} at $0.00.

| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| `keyword` | `string` | Yes | — | Search query per task object (1–100 tasks per POST array). |
| `priority` | `1 | 2` | No | 1 | 1 = Standard Queue (~45–180s, $0.0006); 2 = Priority Queue (~10–45s, $0.0012). |
| `location_code` | `integer` | No | 2840 | Target geo location code. |
| `language_code` | `string` | No | "en" | Target language code. |

**Request Body**:
```json
[
  {
    "keyword": "cloud database benchmark",
    "location_code": 2840,
    "language_code": "en",
    "priority": 1
  },
  {
    "keyword": "postgres vector index",
    "location_code": 2840,
    "language_code": "en",
    "priority": 1
  }
]
```

**Sample Response**:
```json
{
  "version": "1.0",
  "status_code": 20000,
  "cost": 0.0012,
  "tasks": [
    {
      "id": "019adcc5-fc00-7000-8000-000000000010",
      "status_code": 20100,
      "status_message": "Task Created.",
      "result": null
    }
  ]
}
```

### Bing, Google Maps, YouTube & Google News SERP
- **Endpoint**: `POST /v1/serp/{engine}/{vertical}/live/advanced`
- **Pricing**: $0.0020 Live · $0.0006 Standard Queue
- **Summary**: Use the exact same task schema across /v1/serp/bing/organic/live/advanced, /v1/serp/google/maps/live/advanced, /v1/serp/youtube/organic/live/advanced, and /v1/serp/google/news/live/advanced.

| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| `engine / vertical` | `path` | Yes | — | bing/organic, google/maps, youtube/organic, or google/news. |
| `keyword` | `string` | Yes | — | Search query. |
| `location_code` | `integer` | No | 2840 | Target geo code. |

**Request Body**:
```json
[
  {
    "keyword": "specialty coffee san francisco",
    "location_code": 2840,
    "language_code": "en"
  }
]
```

**Sample Response**:
```json
{
  "version": "1.0",
  "status_code": 20000,
  "cost": 0.002,
  "tasks": [
    {
      "status_code": 20000,
      "path": [
        "v1",
        "serp",
        "google",
        "maps",
        "live",
        "advanced"
      ]
    }
  ]
}
```

## 4. Keywords & Trends API (`/v1/keywords_data/*`)

### Google Ads Search Volume & CPC (Batch up to 1,000)
- **Endpoint**: `POST /v1/keywords_data/google_ads/search_volume/live`
- **Pricing**: $0.0750 Live · $0.0600 Priority · $0.0500 Standard (up to 1,000 keywords per task)
- **Summary**: Returns exact 12-month average monthly search volume, mean CPC, top-of-page advertiser bid bounds, competition index (0–100), and 12 trailing monthly search buckets for up to 1,000 keywords in a single call ($0.000075/keyword Live).

| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| `keywords` | `string[]` | Yes | — | 1 to 1,000 keyword phrases per task. |
| `location_code` | `integer` | No | 2840 | Geo location code. |
| `language_code` | `string` | No | "en" | Language code. |
| `search_partners` | `boolean` | No | false | Include Google search partner network volume. |
| `date_from / date_to` | `YYYY-MM-DD` | No | — | Optional custom historical window. |

**Request Body**:
```json
[
  {
    "keywords": [
      "serp api",
      "keyword research api",
      "backlink api"
    ],
    "location_code": 2840,
    "language_code": "en"
  }
]
```

**Sample Response**:
```json
{
  "version": "1.0",
  "status_code": 20000,
  "cost": 0.075,
  "tasks": [
    {
      "status_code": 20000,
      "path": [
        "v1",
        "keywords_data",
        "google_ads",
        "search_volume",
        "live"
      ],
      "result": [
        {
          "keyword": "serp api",
          "search_volume": 14800,
          "cpc": 7.85,
          "competition": "LOW",
          "competition_index": 24
        }
      ]
    }
  ]
}
```

### Google Trends Explore (Interest Over Time & Breakout Queries)
- **Endpoint**: `POST /v1/keywords_data/google_trends/explore/live`
- **Pricing**: $0.0090 Live · $0.0045 Priority · $0.00225 Standard (up to 5 terms)
- **Summary**: Benchmarks up to 5 keywords simultaneously across customizable time windows, returning normalized 0–100 interest curves, regional breakdowns, and rising breakout queries.

| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| `keywords` | `string[]` | Yes | — | 1 to 5 comparison terms. |
| `location_code` | `integer` | No | 2840 | Country or metro code. |
| `time_range` | `string` | No | "past_12_months" | past_hour, past_7_days, past_30_days, past_12_months, past_5_years. |
| `type` | `"web" | "youtube" | "news" | "froogle"` | No | "web" | Google property. |

**Request Body**:
```json
[
  {
    "keywords": [
      "serp api",
      "mcp server"
    ],
    "location_code": 2840,
    "time_range": "past_12_months"
  }
]
```

**Sample Response**:
```json
{
  "version": "1.0",
  "status_code": 20000,
  "cost": 0.009,
  "tasks": [
    {
      "status_code": 20000,
      "path": [
        "v1",
        "keywords_data",
        "google_trends",
        "explore",
        "live"
      ],
      "result": [
        {
          "keywords": [
            "serp api",
            "mcp server"
          ],
          "items": [
            {
              "type": "google_trends_graph",
              "averages": [
                78,
                72
              ]
            }
          ]
        }
      ]
    }
  ]
}
```

## 5. Backlinks API (`/v1/backlinks/*`)

### Domain & Page Backlink Summary
- **Endpoint**: `POST /v1/backlinks/summary/live`
- **Pricing**: $0.02003 / call ($0.0200 task + 1 summary row)
- **Summary**: Returns aggregate link authority metrics for any root domain, subdomain, or exact URL: logarithmic rank (0–1,000), total backlinks, referring domains, referring subnets, TLD breakdown, and spam score.

| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| `target` | `string` | Yes | — | Root domain ("stripe.com") or full URL ("https://stripe.com/docs"). |
| `include_subdomains` | `boolean` | No | true | Aggregate links pointing to all subdomains. |

**Request Body**:
```json
[
  {
    "target": "developers.google.com",
    "include_subdomains": true
  }
]
```

**Sample Response**:
```json
{
  "version": "1.0",
  "status_code": 20000,
  "cost": 0.02003,
  "tasks": [
    {
      "status_code": 20000,
      "path": [
        "v1",
        "backlinks",
        "summary",
        "live"
      ],
      "result": [
        {
          "target": "developers.google.com",
          "rank": 892,
          "referring_domains": 194520,
          "backlinks_spam_score": 4
        }
      ]
    }
  ]
}
```

### Backlinks, Referring Domains & Anchors (Row-Settled)
- **Endpoint**: `POST /v1/backlinks/{backlinks|referring_domains|anchors}/live`
- **Pricing**: $0.0200 / task + $0.00003 per actual returned row
- **Summary**: Fetch granular inbound link rows, referring root domains, or anchor text distributions. Pre-authorizes your requested limit (1–1,000) and automatically refunds unused row headroom if fewer rows exist.

| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| `target` | `string` | Yes | — | Domain or URL to inspect. |
| `limit` | `integer (1–1000)` | No | 100 | Max rows to return (settled strictly on actual rows returned). |
| `include_subdomains` | `boolean` | No | true | Include subdomains. |

**Request Body**:
```json
[
  {
    "target": "linear.app",
    "limit": 25,
    "include_subdomains": true
  }
]
```

**Sample Response**:
```json
{
  "version": "1.0",
  "status_code": 20000,
  "cost": 0.02075,
  "tasks": [
    {
      "status_code": 20000,
      "path": [
        "v1",
        "backlinks",
        "backlinks",
        "live"
      ]
    }
  ]
}
```

## 6. Search Labs, On-Page & Appendix (`/v1/labs/*`, `/v1/on_page/*`, `/v1/appendix/*`)

### Search Labs: Ranked Keywords, Keyword Ideas & Competitors
- **Endpoint**: `POST /v1/labs/google/{ranked_keywords|keyword_ideas|serp_competitors}/live`
- **Pricing**: $0.0100 / task + $0.0001 per returned item
- **Summary**: Query every organic keyword a domain ranks for, generate semantically related keyword ideas, or map domain competitors across a seed keyword set.

| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| `target / keywords` | `string | string[]` | Yes | — | Pass target domain on ranked_keywords, or keywords[] on keyword_ideas & serp_competitors. |
| `location_code` | `integer` | No | 2840 | Geo code. |
| `language_code` | `string` | No | "en" | Language code. |
| `limit` | `integer (1–1000)` | No | 100 | Max items (unused headroom refunded automatically). |

**Request Body**:
```json
[
  {
    "target": "raycast.com",
    "location_code": 2840,
    "language_code": "en",
    "limit": 20
  }
]
```

**Sample Response**:
```json
{
  "version": "1.0",
  "status_code": 20000,
  "cost": 0.012,
  "tasks": [
    {
      "status_code": 20000,
      "path": [
        "v1",
        "labs",
        "google",
        "ranked_keywords",
        "live"
      ]
    }
  ]
}
```

### On-Page Instant Technical SEO Audit
- **Endpoint**: `POST /v1/on_page/instant_pages`
- **Pricing**: $0.00125 HTML · $0.0025 JS · $0.0035 Full Browser Rendering
- **Summary**: Audits any public HTTP/HTTPS URL in real time (private/loopback/metadata IPs blocked by SSRF guard), returning status code, canonical, meta title/description, heading hierarchy, word count, timing, and On-Page score.

| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| `url` | `string` | Yes | — | Public HTTP/HTTPS page URL to audit. |
| `enable_javascript` | `boolean` | No | false | Execute page JavaScript before extracting DOM metrics. |

**Request Body**:
```json
[
  {
    "url": "https://stripe.com/docs",
    "enable_javascript": false
  }
]
```

**Sample Response**:
```json
{
  "version": "1.0",
  "status_code": 20000,
  "cost": 0.00125,
  "tasks": [
    {
      "status_code": 20000,
      "path": [
        "v1",
        "on_page",
        "instant_pages"
      ]
    }
  ]
}
```

### Account Balance & Daily Spend Limits
- **Endpoint**: `GET /v1/appendix/user_data`
- **Pricing**: $0.0000 (Always free)
- **Summary**: Returns your real-time prepaid USD balance, active key environment (live or sandbox), and per-key UTC daily spend limit & today’s spend.

**Sample Response**:
```json
{
  "version": "1.0",
  "status_code": 20000,
  "cost": 0,
  "tasks": [
    {
      "status_code": 20000,
      "path": [
        "v1",
        "appendix",
        "user_data"
      ],
      "result": [
        {
          "environment": "live",
          "money": {
            "balance": 50,
            "limits": {
              "day": {
                "limit": 25,
                "spent": 0.042
              }
            }
          }
        }
      ]
    }
  ]
}
```

## 7. Remote MCP Server (`/mcp`)

### Claude Code
```bash
claude mcp add --transport http dataforapi https://dataforapi.com/mcp \
  --header "Authorization: Bearer dfa_live_YOUR_KEY"
```

### Cursor / Windsurf (`mcp.json`)
```json
{
  "mcpServers": {
    "dataforapi": {
      "url": "https://dataforapi.com/mcp",
      "headers": {
        "Authorization": "Bearer dfa_live_YOUR_KEY"
      }
    }
  }
}
```

### Codex (`~/.codex/config.toml`)
```toml
[mcp_servers.dataforapi]
url = "https://dataforapi.com/mcp"
http_headers = { Authorization = "Bearer dfa_live_YOUR_KEY" }
```

### MCP Tool Catalog (8 Tools)

| Tool | Underlying v1 Route | Live Rate | Required Args | Optional Args |
|---|---|---|---|---|
| `serp_google_organic` | `POST /v1/serp/google/organic/live/advanced` | $0.0020 | `keyword: string` | `location_code=2840, language_code="en", depth=10, compact=true` |
| `serp_bing_organic` | `POST /v1/serp/bing/organic/live/advanced` | $0.0020 | `keyword: string` | `location_code=2840, language_code="en", compact=true` |
| `keywords_search_volume` | `POST /v1/keywords_data/google_ads/search_volume/live` | $0.0750 / batch | `keywords: string[] (1–1,000)` | `location_code=2840, language_code="en"` |
| `google_trends_explore` | `POST /v1/keywords_data/google_trends/explore/live` | $0.0090 | `keywords: string[] (1–5)` | `location_code=2840, time_range="past_12_months"` |
| `backlinks_summary` | `POST /v1/backlinks/summary/live` | $0.02003 | `target: string` | `include_subdomains=true` |
| `onpage_instant_audit` | `POST /v1/on_page/instant_pages` | $0.00125 | `url: string (public HTTP/S)` | `—` |
| `search_api_docs` | `Built-in catalog` | $0.00 (Free) | `—` | `query?: string` |
| `call_v1_endpoint` | `Any /v1/<family>/<endpoint>` | Endpoint rate | `path: string` | `method="POST", payload?: object[], compact=true` |

## 8. Agent Skills & CLI

Install the official skill directly into Claude Code, Codex, or Antigravity:

```bash
# Claude Code
mkdir -p ~/.claude/skills/dataforapi && curl -fsSL https://dataforapi.com/skills/dataforapi/SKILL.md -o ~/.claude/skills/dataforapi/SKILL.md

# Codex
mkdir -p ~/.codex/skills/dataforapi && curl -fsSL https://dataforapi.com/skills/dataforapi/SKILL.md -o ~/.codex/skills/dataforapi/SKILL.md

# Zero-dependency CLI
curl -fsSL https://dataforapi.com/skills/dataforapi/dfa.mjs -o dfa.mjs && DATAFORAPI_KEY=dfa_test_YOUR_KEY node dfa.mjs serp "serp api"
```
