Appearance
Authentication Fresh
DataForSEO uses HTTP Basic Authentication. Your API credentials are distinct from your account password. Find them in the API Access tab of your dashboard after creating a free account.
How It Works
Your login and password are concatenated with a colon, Base64-encoded, and sent in the Authorization header on every request:
Authorization: Basic <base64(login:password)>For example, if your login is login and password is password, the Base64-encoded value is:
bG9naW46cGFzc3dvcmQ=So the full header looks like:
Authorization: Basic bG9naW46cGFzc3dvcmQ=Important rules:
- Credentials cannot be passed in URL parameters
- There is no separate login endpoint — include auth on every request
- The API password is auto-generated by DataForSEO, not the same as your dashboard password
Code Examples
curl
bash
login="your_login"
password="your_password"
cred="$(printf ${login}:${password} | base64)"
curl --location --request POST "https://api.dataforseo.com/v3/serp/google/organic/live/advanced" \
--header "Authorization: Basic ${cred}" \
--header "Content-Type: application/json" \
--data '[{"keyword":"seo tools","location_code":2840,"language_code":"en"}]'Python
python
import requests
from requests.auth import HTTPBasicAuth
import json
login = "your_login"
password = "your_password"
url = "https://api.dataforseo.com/v3/serp/google/organic/live/advanced"
payload = [{"keyword": "seo tools", "location_code": 2840, "language_code": "en"}]
response = requests.post(
url,
auth=HTTPBasicAuth(login, password),
json=payload
)
print(json.dumps(response.json(), indent=2))JavaScript (Node.js / axios)
javascript
const axios = require('axios');
const login = 'your_login';
const password = 'your_password';
axios({
method: 'post',
url: 'https://api.dataforseo.com/v3/serp/google/organic/live/advanced',
auth: {
username: login,
password: password
},
data: [
{
keyword: 'seo tools',
location_code: 2840,
language_code: 'en'
}
]
}).then(response => {
console.log(JSON.stringify(response.data, null, 2));
}).catch(error => {
console.error(error.response?.data || error.message);
});PHP
php
<?php
require('RestClient.php');
// Download RestClient from the DataForSEO PHP examples package
try {
$client = new RestClient('https://api.dataforseo.com/', null, 'your_login', 'your_password');
$post_array = [];
$post_array[] = [
'keyword' => 'seo tools',
'location_code' => 2840,
'language_code' => 'en'
];
$result = $client->post('/v3/serp/google/organic/live/advanced', $post_array);
print_r($result);
} catch (RestClientException $e) {
echo "HTTP code: {$e->getHttpCode()}\n";
echo "Error code: {$e->getCode()}\n";
echo "Message: {$e->getMessage()}\n";
}
?>Authentication Errors
| HTTP Status | Code | Meaning |
|---|---|---|
401 | — | Invalid or missing credentials |
403 | — | Account suspended or access denied |
40101 | Internal | Login or password incorrect |
If you receive a 401, check:
- You are using the API password (from the API Access tab), not your dashboard password
- The Base64 encoding is correct — whitespace or newlines will break it
- The
Authorizationheader is present on the request, not passed as a query parameter
Testing Your Credentials
A quick way to validate credentials is to call the user data endpoint:
bash
curl --location "https://api.dataforseo.com/v3/appendix/user_data" \
--header "Authorization: Basic $(printf 'your_login:your_password' | base64)"A successful response returns your account balance and usage details.