Skip to content

SOP: Setting Up DataForSEO Fresh

Run this once before any other SOP. Takes about 10 minutes.

Step 1: Create Your Account

  1. Go to dataforseo.com and click Sign Up
  2. Choose your plan (there is a free trial with limited credits)
  3. Complete email verification
  4. Log into the dashboard

Step 2: Get Your API Credentials

  1. In the dashboard, navigate to API Access or Settings > API
  2. Copy your Login (your account email or username)
  3. Copy your Password (the API password — may differ from your login password)

DataForSEO uses HTTP Basic Auth. Your credentials are the login + password pair, Base64-encoded.

Step 3: Test Authentication with curl

Run this immediately after getting credentials. If this fails, nothing else will work.

bash
curl -X GET "https://api.dataforseo.com/v3/serp/google/organic/live/advanced" \
  -u "YOUR_LOGIN:YOUR_PASSWORD" \
  -H "Content-Type: application/json"

Expected response (even with no task body, you get a structured error — not a 401):

json
{
  "version": "0.1.20240101",
  "status_code": 20000,
  "status_message": "Ok.",
  "cost": 0,
  "tasks_count": 0,
  "tasks_error": 0,
  "tasks": []
}

If you get 401 Unauthorized — recheck your credentials. The API password is not always your account password.

Step 4: Set Up Environment Variables

Never hardcode credentials. Set them as environment variables.

Linux / macOS / WSL:

bash
export DATAFORSEO_LOGIN="your_login@email.com"
export DATAFORSEO_PASSWORD="your_api_password"

Add those lines to ~/.bashrc or ~/.zshrc for persistence.

Windows PowerShell:

powershell
$env:DATAFORSEO_LOGIN = "your_login@email.com"
$env:DATAFORSEO_PASSWORD = "your_api_password"

.env file (for projects):

DATAFORSEO_LOGIN=your_login@email.com
DATAFORSEO_PASSWORD=your_api_password

Load it in Python with python-dotenv:

python
from dotenv import load_dotenv
load_dotenv()

Step 5: Verify with a Test API Call

Run a minimal live SERP call to confirm everything is wired:

python
import os
import requests
from requests.auth import HTTPBasicAuth

login = os.environ["DATAFORSEO_LOGIN"]
password = os.environ["DATAFORSEO_PASSWORD"]

auth = HTTPBasicAuth(login, password)

payload = [
    {
        "keyword": "test keyword",
        "location_code": 2840,  # United States
        "language_code": "en",
        "device": "desktop",
        "os": "windows",
        "depth": 10
    }
]

response = requests.post(
    "https://api.dataforseo.com/v3/serp/google/organic/live/advanced",
    auth=auth,
    json=payload
)

data = response.json()
print(f"Status: {data['status_code']}")
print(f"Tasks returned: {data['tasks_count']}")

if data["tasks"]:
    task = data["tasks"][0]
    print(f"Task status: {task['status_code']}")
    if task.get("result"):
        items = task["result"][0].get("items", [])
        print(f"Results returned: {len(items)}")

Verification Checklist

Before moving to any other SOP, confirm:

  • [ ] Account created and email verified
  • [ ] API credentials copied from dashboard
  • [ ] curl test returns status_code: 20000 (not 401)
  • [ ] DATAFORSEO_LOGIN environment variable is set
  • [ ] DATAFORSEO_PASSWORD environment variable is set
  • [ ] Python test script returns results without exceptions

Authentication Reference

All DataForSEO API calls use the same pattern:

FieldValue
Auth typeHTTP Basic Auth
Base URLhttps://api.dataforseo.com/v3/
HeaderContent-Type: application/json
Credentialslogin:password (Base64-encoded by your HTTP client)

The Python requests library handles the Base64 encoding automatically when you pass auth=HTTPBasicAuth(login, password).

Internal SOP reference — not affiliated with DataForSEO.