Scientyfic World

DataForSEO API: What It Is, Which API to Use and Your First Request

A practical guide to the DataForSEO API: which API does what, Live vs Standard requests, authentication, a tested first request in Python and common errors....
Share:

Get an AI summary of this article

DataForSEO API guide

The DataForSEO API is a set of REST APIs that return raw SEO data as JSON: live search results, keyword metrics, backlinks, on-page audits, business listings and more. There is no dashboard to log in to for analysis. You send a request, you get structured data, and you build your own tool, report or AI agent on top. This guide explains which of its APIs does what, how Live and Standard requests differ, and how to make your first request in Python, with error handling for the mistakes most people hit first.

Disclosure: some links in this article are affiliate links. If you sign up through them, scientyficworld.org may earn a commission at no extra cost to you. It does not change our recommendations.

What the DataForSEO API Is (and Isn’t)

DataForSEO sells data, not an SEO platform. Its current API version is v3, and every endpoint follows the same pattern: send a JSON array of tasks over HTTPS and read the JSON response. On 5 November 2026, its APIs page listed about 8.4 billion Google keywords and 514 million Google SERPs in its databases.

That makes it a good fit if you are building a rank tracker, an internal SEO report or a keyword workflow. It is a poor fit if you want charts and reports ready to use, because you have to build that layer yourself. SEO platforms such as Semrush and Ahrefs start from the dashboard and offer an API alongside it; with DataForSEO, the API is the product.

Which DataForSEO API Do You Need?

DataForSEO has eleven main APIs. Most projects need only one or two, so start from the job you want to do:

Your jobAPIA good first endpoint
Check who ranks for a keywordSERP API/v3/serp/google/organic/live/advanced
Get search volume from Google AdsKeywords Data API/v3/keywords_data/google_ads/search_volume/live
See Google Trends dataKeywords Data API/v3/keywords_data/google_trends/explore/live
Get volume, difficulty and intent togetherDataForSEO Labs API/v3/dataforseo_labs/google/keyword_overview/live
Score keyword difficulty in bulkDataForSEO Labs API/v3/dataforseo_labs/google/bulk_keyword_difficulty/live
Analyse a site’s backlinksBacklinks API/v3/backlinks/summary/live
Audit a page or run LighthouseOn-Page API/v3/on_page/lighthouse/live/json
See how AI assistants answer a promptAI Optimization API/v3/ai_optimization/chat_gpt/llm_responses/live

The others are Domain Analytics, Business Data, Merchant, App Data and Content Analysis. The API documentation covers every endpoint and its parameters.

A common point of confusion is the difference between the SERP API and DataForSEO Labs. The SERP API fetches a results page for your query at request time. Labs answers from DataForSEO’s own keyword and SERP databases, so it suits research across many keywords. The keyword overview docs note that its keyword metrics, based on the Google Ads API, update once a month, so do not expect them to reflect today’s search results.

Live vs Standard Requests

Many DataForSEO APIs offer two ways to get data, and mixing them up is one of the most common first errors.

LiveStandard
How it worksResults come back in the same responsePost with task_post, collect later with task_get
Best forUser-facing tools and instant answersBatch jobs and scheduled collection
Tasks per requestUsually oneUp to 100
Results storedNot stored30 days
AvailabilityLabs and Backlinks are Live onlyNot offered on every API

If you call task_post and get status 20100 (Task Created) with no data, nothing is wrong. The task was accepted, and you collect the result with task_get using the returned task ID.

Getting Your API Credentials

Create a DataForSEO account, then open the API Access tab in the dashboard. Two details cause most authentication failures:

  • Your API password is not your dashboard password. DataForSEO generates it at registration. It stays visible for 24 hours, and after that you can have it sent by email.
  • Copy your API login from the same tab. DataForSEO’s help pages describe it as your registration email, but it can be a generated string, as it was on the account we tested.

Authentication is HTTP Basic: the Authorization header contains Basic, a space and the Base64 encoding of login:password. A stray space or line break in the encoded string makes the request fail.

Your First DataForSEO API Request in Python

This script uses only the Python standard library. It defaults to the DataForSEO sandbox, which accepts the same requests on sandbox.dataforseo.com and returns generic sample data, so you can test your integration before requesting real data. It calls two endpoints: the Live Google Organic SERP endpoint and the Labs keyword overview.

First, set your credentials as environment variables:

export DATAFORSEO_LOGIN="[email protected]"
export DATAFORSEO_PASSWORD="your_api_password"

Then save this as first_request.py and run it with python3 first_request.py:

import base64
import json
import os
import urllib.error
import urllib.request

# Sandbox returns generic sample data. Change to https://api.dataforseo.com for real results.
BASE_URL = os.environ.get("DATAFORSEO_BASE_URL", "https://sandbox.dataforseo.com")
LOGIN = os.environ["DATAFORSEO_LOGIN"]
PASSWORD = os.environ["DATAFORSEO_PASSWORD"]
TOKEN = base64.b64encode(f"{LOGIN}:{PASSWORD}".encode()).decode()


def call(path, task):
    """POST one task to a Live endpoint and return its result list."""
    request = urllib.request.Request(
        BASE_URL + path,
        data=json.dumps([task]).encode(),  # The body is always an array of tasks
        headers={"Authorization": f"Basic {TOKEN}", "Content-Type": "application/json"},
        method="POST",
    )
    try:
        with urllib.request.urlopen(request, timeout=120) as response:
            body = json.load(response)
    except urllib.error.HTTPError as error:  # 401, 402, 404 and 500 still carry JSON
        body = json.load(error)

    if body["status_code"] != 20000:
        raise RuntimeError(f"Request failed: {body['status_code']} {body['status_message']}")
    task_result = body["tasks"][0]
    if task_result["status_code"] != 20000:  # HTTP 200 can still hide a task-level error
        raise RuntimeError(f"Task failed: {task_result['status_code']} {task_result['status_message']}")
    return task_result["result"]


def top_results(keyword, location_code=2840, language_code="en", depth=10):
    result = call(
        "/v3/serp/google/organic/live/advanced",
        {"keyword": keyword, "location_code": location_code, "language_code": language_code, "depth": depth},
    )
    return [
        (item["rank_group"], item.get("website_name"), item.get("breadcrumb"))
        for item in result[0]["items"]
        if item["type"] == "organic"  # Skip AI Overviews, People Also Ask and other SERP features
    ]


def keyword_metrics(keywords, location_code=2840, language_code="en"):
    result = call(
        "/v3/dataforseo_labs/google/keyword_overview/live",
        {"keywords": keywords, "location_code": location_code, "language_code": language_code},
    )
    return [
        (
            item["keyword"],
            item["keyword_info"]["search_volume"],
            item["keyword_properties"]["keyword_difficulty"],
            item["search_intent_info"]["main_intent"],
        )
        for item in result[0]["items"]
    ]


if __name__ == "__main__":
    for rank, site, address in top_results("serp api"):
        print(rank, site, address)
    for row in keyword_metrics(["serp api", "keyword research api"]):
        print(row)

Three things in this script are worth copying into your own code:

  • The body is an array, even for one task. Sending a single object returns error 40503.
  • It checks status codes at two levels. DataForSEO returns HTTP 200 for almost everything, so a request can report 20000 while the task inside it failed.
  • It filters by item type. A SERP response mixes organic results with AI Overviews, People Also Ask and other features, each with a different structure.
  • It reads the site from website_name and breadcrumb. In our tests, domain and url held Google redirect links (google.com/goto?url=...) instead of the ranking site, so check these fields in your own responses before you rely on them for rank tracking.

Before writing code, you can also try any endpoint in the API Playground inside the dashboard, which shows the full JSON response. Location 2840 is the United States. Location codes can differ between APIs, so look them up in each API’s locations endpoint rather than reusing a list.

How this was tested: on 6 November 2026 we sent both requests through the API Playground in the DataForSEO dashboard and confirmed that the real responses contain the fields this script reads. We also ran the script itself against a local mock of those responses, including a task-level error, and against the real sandbox to confirm how an authentication error is handled.

Common DataForSEO API Errors

CodeMeaningFix
40100Credentials not recognisedUse the API password, not the dashboard one, and check the encoding
40104Account not verifiedComplete verification in the dashboard
40207IP address not whitelistedAdd your IP in the API Access section
40000More than one task sent to a Live endpointSend one task per Live request
40501Missing or invalid fieldRead the field name in the message and check that endpoint’s docs
40503Invalid request structureSend an array of tasks, not a single object
40506Unknown fieldCheck for a typo in the field name
40601, 40602Task not ready yetWait and call task_get again

For rate limits, read the X-RateLimit-Limit and X-RateLimit-Remaining response headers rather than hardcoding a number, because the limit varies by endpoint.

Using an Official Client Library

Plain HTTP keeps the example easy to follow, but DataForSEO also maintains official clients for Python, TypeScript, PHP, C# and Java. The Python client on GitHub installs with pip install dataforseo-client and gives you typed request and response models, which helps if you use many endpoints. Its examples cover both Live and task-based requests.

Using the API Without Writing Code

If this fits what you are building, you can create a DataForSEO account here and start in the sandbox.

Conclusion

The DataForSEO API is a building block rather than a finished SEO tool. Pick the API that matches your job, use Live for instant answers and Standard for batches, test in the sandbox, and always check both levels of status codes. Once your first request works, the same pattern applies to every other endpoint.

What is DataForSEO?

DataForSEO is a provider of SEO data delivered through REST APIs. It offers search results, keyword metrics, backlinks, on-page audits, business data and more as JSON, for developers and agencies to build their own tools.

What is the difference between the SERP API and DataForSEO Labs?

The SERP API fetches a search results page for your query at request time. DataForSEO Labs answers from DataForSEO’s own keyword and SERP databases, which suits research across many keywords.

How do I authenticate with the DataForSEO API?

Use HTTP Basic authentication with the API login and API password shown on the API Access tab. The API password is different from your dashboard password.

Does DataForSEO have a Python library?

Yes. The official client installs with pip install dataforseo-client, and you can also call the REST API directly with any HTTP library.

Can I test the DataForSEO API without using real data?

Yes. Send the same requests to sandbox.dataforseo.com instead of api.dataforseo.com. The sandbox returns generic sample responses, which is useful for testing your integration.

Why did I get a 200 response but no data?

DataForSEO returns HTTP 200 for almost every request, so check the status_code field at both the request level and the task level. If you called task_post, you also need a separate task_get call to collect the results.

Snehasish Konger
Developed @scientyficworld.org | Technical writer @Nected | Content Developer
Connect with Snehasish Konger

On This page

Take a Pause with Intervals

A Sunday letter on building, writing, and thinking deeper as a developer — short, honest, and worth your time.

Snehasish Konger profile photo

"Hey there — I'm Snehasish. Hope this post saved you some head-scratching time! I've spent years turning technical chaos into clarity, and I'm here to be your guide through the maze of modern tech. Stick around for more lightbulb moments — we're just getting started."

Related Posts