Location endpoints only return countries with a default URL (e.g., /locations.ai); to obtain cities of the certain country, append the country code (for example locations/US.ai)
Supported APIs and endpoints
AI-optimized API responses are universally supported across all Live and Task GET endpoints. The APIs that benefit the most are SERP API and DataForSEO Labs API.
Example of the request for obtaining AI-optimized API response for Google Organic Live Regular SERP API:
# Instead of 'login' and 'password' use your credentials from https://app.dataforseo.com/api-access \
login="login"
password="password"
cred="$(printf ${login}:${password} | base64)"
curl --location --request POST "https://api.dataforseo.com/v3/serp/google/organic/live/regular.ai" \
--header "Authorization: Basic ${cred}" \
--header "Content-Type: application/json" \
--data-raw '[
{
"language_code": "en",
"location_code": 2840,
"keyword": "albert einstein"
}
]'
<?php
// You can download this file from here https://cdn.dataforseo.com/v3/examples/php/php_RestClient.zip
require('RestClient.php');
$api_url = 'https://api.dataforseo.com/';
try {
// Instead of 'login' and 'password' use your credentials from https://app.dataforseo.com/api-access
$client = new RestClient($api_url, null, 'login', 'password');
} catch (RestClientException $e) {
echo "\n";
print "HTTP code: {$e->getHttpCode()}\n";
print "Error code: {$e->getCode()}\n";
print "Message: {$e->getMessage()}\n";
print $e->getTraceAsString();
echo "\n";
exit();
}
$post_array = array();
// You can set only one task at a time
$post_array[] = array(
"language_code" => "en",
"location_code" => 2840,
"keyword" => mb_convert_encoding("albert einstein", "UTF-8")
);
try {
// POST /v3/serp/google/organic/live/regular
// in addition to 'google' and 'organic' you can also set other search engine and type parameters
// the full list of possible parameters is available in documentation
$result = $client->post('/v3/serp/google/organic/live/regular.ai', $post_array);
print_r($result);
// do something with post result
} catch (RestClientException $e) {
echo "\n";
print "HTTP code: {$e->getHttpCode()}\n";
print "Error code: {$e->getCode()}\n";
print "Message: {$e->getMessage()}\n";
print $e->getTraceAsString();
echo "\n";
}
$client = null;
?>
from client import RestClient
# You can download this file from here https://cdn.dataforseo.com/v3/examples/python/python_Client.zip
client = RestClient("login", "password")
post_data = dict()
# You can set only one task at a time
post_data[len(post_data)] = dict(
language_code="en",
location_code=2840,
keyword="albert einstein"
)
# POST /v3/serp/google/organic/live/regular
# in addition to 'google' and 'organic' you can also set other search engine and type parameters
# the full list of possible parameters is available in documentation
response = client.post("/v3/serp/google/organic/live/regular.ai", post_data)
# you can find the full list of the response codes here https://docs.dataforseo.com/v3/appendix/errors
if response["status_code"] == 20000:
print(response)
# do something with result
else:
print("error. Code: %d Message: %s" % (response["status_code"], response["status_message"]))
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Threading.Tasks;
namespace DataForSeoDemos
{
public static partial class Demos
{
public static async Task serp_live_regular()
{
var httpClient = new HttpClient
{
BaseAddress = new Uri("https://api.dataforseo.com/"),
// Instead of 'login' and 'password' use your credentials from https://app.dataforseo.com/api-access
//DefaultRequestHeaders = { Authorization = new AuthenticationHeaderValue("Basic", Convert.ToBase64String(Encoding.ASCII.GetBytes("login:password"))) }
};
var postData = new List<object>();
// You can set only one task at a time
postData.Add(new
{
language_code = "en",
location_code = 2840,
keyword = "albert einstein"
});
// POST /v3/serp/google/organic/live/regular.ai
// in addition to 'google' and 'organic' you can also set other search engine and type parameters
// the full list of possible parameters is available in documentation
var taskPostResponse = await httpClient.PostAsync("/v3/serp/google/organic/live/regular.ai", new StringContent(JsonConvert.SerializeObject(postData)));
var result = JsonConvert.DeserializeObject<dynamic>(await taskPostResponse.Content.ReadAsStringAsync());
// you can find the full list of the response codes here https://docs.dataforseo.com/v3/appendix/errors
if (result.status_code == 20000)
{
// do something with result
Console.WriteLine(result);
}
else
Console.WriteLine($"error. Code: {result.status_code} Message: {result.status_message}");
}
}
}
Example of the AI-optimized response of Google Organic Regular SERP API:
{
"id": "05281810-1535-0121-0000-014aadae6b3a",
"status_code": 20000,
"status_message": "Ok.",
"items": [
{
"type": "organic",
"rank_group": 1,
"rank_absolute": 2,
"domain": "en.wikipedia.org",
"title": "Albert Einstein",
"description": "Albert Einstein (14 March 1879 – 18 April 1955) was a German-born theoretical physicist who is best known for developing the theory of relativity.",
"url": "https://en.wikipedia.org/wiki/Albert_Einstein",
"breadcrumb": "https://en.wikipedia.org › wiki › Albert_Einstein"
},
{
"type": "organic",
"rank_group": 2,
"rank_absolute": 5,
"domain": "www.britannica.com",
"title": "Albert Einstein | Biography, Education, Discoveries, & Facts",
"description": "May 1, 2025 — Albert Einstein was a famous physicist. His research spanned from quantum mechanics to theories about gravity and motion. After publishing some ...",
"url": "https://www.britannica.com/biography/Albert-Einstein",
"breadcrumb": "https://www.britannica.com › ... › Physics › Physicists"
},
{
"type": "organic",
"rank_group": 3,
"rank_absolute": 7,
"domain": "www.nobelprize.org",
"title": "Albert Einstein – Biographical",
"description": "Albert Einstein was born at Ulm, in Württemberg, Germany, on March 14, 1879. Six weeks later the family moved to Munich, where he later on began his schooling ...",
"url": "https://www.nobelprize.org/prizes/physics/1921/einstein/biographical/",
"breadcrumb": "https://www.nobelprize.org › prizes › physics › biograp..."
},
{
"type": "organic",
"rank_group": 4,
"rank_absolute": 8,
"domain": "einsteinmed.edu",
"title": "Albert Einstein College of Medicine | Montefiore Einstein",
"description": "Aesthetics · Aging Brain · The AIDS Center · Allergy & Immunology · Alzheimer's Center (CEAD) · Anesthesiology · Asthma Center · Blood (Hematology)",
"url": "https://einsteinmed.edu/",
"breadcrumb": "https://einsteinmed.edu"
},
{
"type": "organic",
"rank_group": 5,
"rank_absolute": 9,
"domain": "www.instagram.com",
"title": "Albert Einstein (@alberteinstein)",
"description": "Official Instagram account of the World's Favorite Genius. Managed by CMG Worldwide, authorized representative of the Albert Einstein Estate.",
"url": "https://www.instagram.com/alberteinstein/?hl=en",
"breadcrumb": "1.9M+ followers"
},
{
"type": "organic",
"rank_group": 6,
"rank_absolute": 10,
"domain": "www.rescue.org",
"title": "7 facts about Albert Einstein that may surprise you | The IRC",
"description": "Mar 17, 2025 — 7 facts about Albert Einstein that may surprise you · 1. Einstein was a refugee · 2. He used his influence and money to help other refugees · 3.",
"url": "https://www.rescue.org/article/7-facts-about-albert-einstein-may-surprise-you",
"breadcrumb": "https://www.rescue.org › article › 7-facts-about-albert-ei..."
},
{
"type": "organic",
"rank_group": 7,
"rank_absolute": 11,
"domain": "www.goodreads.com",
"title": "Quotes by Albert Einstein (Author of Relativity)",
"description": "There are only two ways to live your life. One is as though nothing is a miracle. The other is as though everything is a miracle. Albert Einstein.",
"url": "https://www.goodreads.com/author/quotes/9810.Albert_Einstein",
"breadcrumb": "https://www.goodreads.com › author › 9810.Albert_Ei..."
},
{
"type": "organic",
"rank_group": 8,
"rank_absolute": 12,
"domain": "www.pbs.org",
"title": "A Science Odyssey: People and Discoveries: Albert Einstein",
"description": "Albert Einstein is one of the most recognized and well-known scientists of the century. His theories solved centuries-old problems in physics and rocked ...",
"url": "https://www.pbs.org/wgbh/aso/databank/entries/bpeins.html",
"breadcrumb": "https://www.pbs.org › aso › databank › entries › bpeins"
},
{
"type": "organic",
"rank_group": 9,
"rank_absolute": 13,
"domain": "kids.nationalgeographic.com",
"title": "Albert Einstein",
"description": "Albert Einstein is born in Ulm, Germany. As a child, the prodigy enjoys solving math riddles and building skyscrapers out of playing cards.",
"url": "https://kids.nationalgeographic.com/history/article/albert-einstein",
"breadcrumb": "https://kids.nationalgeographic.com › history › article"
}
]
}
Description of the dynamic fields:
path
endpoint path
specify the path to the endpoint
example: serp/google/organic/live/regular
id
task identifier
unique task identifier used in Task GET endpoints
example: 05281810-1535-0121-0000-014aadae6b3a
As a response of the API server, you will receive JSON-encoded data containing AI-optimized response array specific to the set tasks. Description of the structure of the AI-optimized API response array:
Field name
Type
Description
id
string
task identifier unique task identifier in our system in the UUID format
status_code
integer
general status code
you can find the full list of the response codes here Note: we strongly recommend designing a necessary system for handling related exceptional or error conditions
status_message
string
general informational message
you can find the full list of general informational messages here