Appearance
SOP: Setting Up DataForSEO Fresh
Run this once before any other SOP. Takes about 10 minutes.
Step 1: Create Your Account
- Go to
dataforseo.comand click Sign Up - Choose your plan (there is a free trial with limited credits)
- Complete email verification
- Log into the dashboard
Step 2: Get Your API Credentials
- In the dashboard, navigate to API Access or Settings > API
- Copy your Login (your account email or username)
- 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_passwordLoad 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
- [ ]
curltest returnsstatus_code: 20000(not 401) - [ ]
DATAFORSEO_LOGINenvironment variable is set - [ ]
DATAFORSEO_PASSWORDenvironment variable is set - [ ] Python test script returns results without exceptions
Authentication Reference
All DataForSEO API calls use the same pattern:
| Field | Value |
|---|---|
| Auth type | HTTP Basic Auth |
| Base URL | https://api.dataforseo.com/v3/ |
| Header | Content-Type: application/json |
| Credentials | login:password (Base64-encoded by your HTTP client) |
The Python requests library handles the Base64 encoding automatically when you pass auth=HTTPBasicAuth(login, password).