Instead of ‘login’ and ‘password’ use your credentials from https://app.dataforseo.com/api-access
<?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(); } try { $result = array(); // #1 - using this method you can get a list of completed tasks // GET /v3/ai_optimization/chat_gpt/llm_scraper/tasks_ready // in addition to '{{low_se_name}}' and '{{low_se_type}}' you can also set other search engine and type parameters // the full list of possible parameters is available in documentation $tasks_ready = $client->get('/v3/ai_optimization/chat_gpt/llm_scraper/tasks_ready'); // you can find the full list of the response codes here https://docs.dataforseo.com/v3/appendix/errors if (isset($tasks_ready['status_code']) AND $tasks_ready['status_code'] === 20000) { foreach ($tasks_ready['tasks'] as $task) { if (isset($task['result'])) { foreach ($task['result'] as $task_ready) { // #2 - using this method you can get results of each completed task // GET /v3/ai_optimization/chat_gpt/llm_scraper/task_get/advanced/$id if (isset($task_ready['endpoint_advanced'])) { $result[] = $client->get($task_ready['endpoint_advanced']); } // #3 - another way to get the task results by id // GET /v3/ai_optimization/chat_gpt/llm_scraper/task_get/advanced/$id /* if (isset($task_ready['id'])) { $result[] = $client->get('/v3/ai_optimization/chat_gpt/llm_scraper/task_get/advanced/' . $task_ready['id']); } */ } } } } print_r($result); // do something with 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; ?>
The above command returns JSON structured like this:
{ "version": "0.1.20250723", "status_code": 20000, "status_message": "Ok.", "time": "0.1703 sec.", "cost": 0, "tasks_count": 1, "tasks_error": 0, "tasks": [ { "id": "07231424-0696-0066-1000-8cb255c6cd3b", "status_code": 20000, "status_message": "Ok.", "time": "0.0672 sec.", "cost": 0, "result_count": 1, "path": [ "v3", "ai_optimization", "chatgpt", "llm_scraper", "task_get", "advanced", "07231424-0696-0066-1000-8cb255c6cd3b" ], "data": { "api": "ai_optimization", "function": "task_get", "se": "chatgpt", "se_type": "llm_scraper", "language_code": "en", "location_code": 2840, "keyword": "albert einstein", "device": "desktop", "os": "windows" }, "result": [ { "keyword": "albert einstein", "location_code": 2840, "language_code": "en", "check_url": "https://chatgpt.com/?q=albert%20einstein&hints=search", "datetime": "2025-08-14 09:26:26 +00:00", "markdown": "![en.wikipedia.org/wiki/al...] Interested in diving deeper? Let me know if you'd like to explore any particular facet—his papers, quotes, or maybe his influence on modern physics!\n\n", "search_results": [ { "type": "chatgpt_search_result", "url": "https://www.britannica.com/biography/Albert-Einstein?utm_source=chatgpt.com", "domain": "www.britannica.com", "title": "Albert Einstein | Biography, Education, Discoveries, & Facts | Britannica", "description": "Ask the Chatbot Games & Quizzes History & Society Science & Tech Biographies Animals & Nature Geography & Travel Arts & Culture ProCon Money Videos Albert Einstein Albert Einstein ALBERT EINSTEIN...", "breadcrumb": "britannica.com" } ], "sources": [ { "type": "chat_gpt_source", "title": "Albert Einstein", "snippet": null, "domain": "en.wikipedia.org", "url": "https://en.wikipedia.org/wiki/Albert_Einstein?utm_source=chatgpt.com", "thumbnail": null, "source_name": "Wikipedia", "publication_date": "2025-08-13 22:16:33 +00:00", "markdown": null }, { "type": "chat_gpt_source", "title": "Albert Einstein: Biography, Physicist, Nobel Prize Winner", "snippet": null, "domain": "www.biography.com", "url": "https://www.biography.com/scientists/albert-einstein?utm_source=chatgpt.com", "thumbnail": null, "source_name": "Biography", "publication_date": null, "markdown": null }, { "type": "chat_gpt_source", "title": "Annus mirabilis papers", "snippet": null, "domain": "en.wikipedia.org", "url": "https://en.wikipedia.org/wiki/Annus_mirabilis_papers?utm_source=chatgpt.com", "thumbnail": null, "source_name": "Wikipedia", "publication_date": "2025-07-06 19:19:49 +00:00", "markdown": null } ], "se_results_count": 0, "item_types": [ "chat_gpt_images", "chat_gpt_text", "chat_gpt_table", "chat_gpt_products", "chat_gpt_local_businesses", "chat_gpt_navigation_list" ], "items_count": 5, "items": [ { "type": "chat_gpt_images", "rank_group": 1, "rank_absolute": 1, "markdown": "", "items": [ { "type": "chat_gpt_images_element", "url": "https://en.wikipedia.org/wiki/Albert_Einstein?utm_source=chatgpt.com", "alt": "en.wikipedia.org/wiki/al...", "image_url": "https://upload.wikimedia.org/wikipedia/commons/thumb/1/14/Albert_Einstein_1947.jpg/960px-Albert_Einstein_1947.jpg", "markdown": "" } ] }, { "type": "chat_gpt_text", "rank_group": 1, "rank_absolute": 2, "markdown": "\n\nHere’s a classic image of **Albert Einstein**, perhaps the most iconic physicist of the 20th century.\n\n", "sources": [ { "type": "chat_gpt_source", "title": "Albert Einstein", "snippet": null, "domain": "en.wikipedia.org", "url": "https://en.wikipedia.org/wiki/Albert_Einstein?utm_source=chatgpt.com", "thumbnail": null, "source_name": "Wikipedia", "publication_date": "2025-08-13 22:16:33 +00:00", "markdown": null }, { "type": "chat_gpt_source", "title": "Albert Einstein: Biography, Physicist, Nobel Prize Winner", "snippet": null, "domain": "www.biography.com", "url": "https://www.biography.com/scientists/albert-einstein?utm_source=chatgpt.com", "thumbnail": null, "source_name": "Biography", "publication_date": null, "markdown": null }, { "type": "chat_gpt_source", "title": "Annus mirabilis papers", "snippet": null, "domain": "en.wikipedia.org", "url": "https://en.wikipedia.org/wiki/Annus_mirabilis_papers?utm_source=chatgpt.com", "thumbnail": null, "source_name": "Wikipedia", "publication_date": "2025-07-06 19:19:49 +00:00", "markdown": null } ] }, { "type": "chat_gpt_table", "rank_group": 1, "rank_absolute": 3, "text": null, "markdown": "| Contribution | Impact |\n|----------------------------------|------------------------------------------------------------------------|\n| Photoelectric Effect | Laid foundations for quantum mechanics and practical light-based tech |\n| Brownian Motion | Cemented atomic theory |\n| Special & General Relativity | Revolutionized understanding of spacetime and gravity |\n| E = mc² | Established mass-energy equivalence—key to nuclear physics |\n| Everyday tech | Powering lasers, GPS, solar cells, devices using photoelectric cells |\n\n", "table": { "table_header": [ "Contribution", "Impact" ], "table_content": [ [ "Photoelectric Effect", "Laid foundations for quantum mechanics and practical light-based tech" ], [ "Brownian Motion", "Cemented atomic theory" ], [ "Special & General Relativity", "Revolutionized understanding of spacetime and gravity" ], [ "E = mc²", "Established mass-energy equivalence—key to nuclear physics" ], [ "Everyday tech", "Powering lasers, GPS, solar cells, devices using photoelectric cells" ] ] } }, { "type": "chat_gpt_text", "rank_group": 2, "rank_absolute": 4, "markdown": "\n---\n\nEinstein’s genius extended beyond equations—he left an enduring mark on both science and society. His bold ideas continue to fuel discoveries. Interested in diving deeper? Let me know if you'd like to explore any particular facet—his papers, quotes, or maybe his influence on modern physics!\n\n", "sources": null }, { "type": "chat_gpt_products", "rank_group": 1, "rank_absolute": 2, "items": [ { "type": "chat_gpt_products_element", "product_id": "gid://shopify/p/7JnWm9ccvIQ5SklKKTC9zt", "title": "Albert Einstein Tongue Out Hoodie", "rating": null, "price": 34.95, "currency": "USD", "tag": "Playful tongue‑out design, mid‑$30s", "url": "https://absurdink.com/products/albert-einstein-tongue-out-hoodie?variant=31097782173755&utm_source=chatgpt.com", "domain": "absurdink.com", "images": [ "https://cdn.shopify.com/s/files/1/1111/4912/products/Einstein_06be2084-c169-43c6-acba-97df01fee76f.jpg?v=1725508345" ] }, { "type": "chat_gpt_products_element", "product_id": "gid://shopify/p/5ymP4aadqvedAsJ3PeFyvU", "title": "Funny Albert Einstein Quotes Hoodie: 'The measure of intelligence…'", "rating": null, "price": 49.95, "currency": "USD", "tag": "Features iconic quote, comfy and cozy (~$50)", "url": "https://www.printyourwear.com/products/funny-albert-einstein-quotes-hoodie-the-measure-of-intelligence-is-the-ability-to-change-code?variant=51537394270526&utm_source=chatgpt.com", "domain": "www.printyourwear.com", "images": [ "https://cdn.shopify.com/s/files/1/0721/2993/7726/files/ts09-17032502_hoodie-pyw__black.jpg?v=1750566345" ] }, { "type": "chat_gpt_products_element", "product_id": "gid://shopify/p/ZsqO4vxv0ViJXZxt74ePy", "title": "Einstein E=McKushed Hoodie (StonerDays)", "rating": null, "price": 59.99, "currency": "USD", "tag": "Pop‑culture twist on E=MC², ethically sourced (~$60)", "url": "https://shop.stonerdays.com/products/einstein-e-mckushed-hoodie?variant=14032863133805&utm_source=chatgpt.com", "domain": "shop.stonerdays.com", "images": [ "https://cdn.shopify.com/s/files/1/1373/4937/products/einstein-emckushed-hoodie-pullover-hoodieHoodiesforCannabisLovers.jpg?v=1725503584" ] } ] }, { "type": "chat_gpt_local_businesses", "rank_group": 1, "rank_absolute": 2, "markdown": "**[La Casa Del Caffe](http://www.lacasadelcaffe.com?utm_source=chatgpt.com)** \n**Closed · Coffee Shop · $ · 3.9 (22 reviews)** \n_1036 Morris Park Ave (at Hone Ave), Bronx, NY 10461_ \nA local favorite on Morris Park Avenue, known for great cappuccinos and one of the best places to work in the neighbourhood.\n\n**[Prince Coffee House](http://www.devollicorporation.com/?id=3&utm_source=chatgpt.com)** \n**Closed · Café · $ · 3.7 (44 reviews)** \n_2306 Arthur Ave, Bronx, NY 10458_ \nSpacious, bright interior on Arthur Ave (“Little Italy”), ample seating, stays open until 11 pm—great for late‑night study.\n\n**[Mottley Kitchen](http://www.mottleykitchen.com?utm_source=chatgpt.com)** \n**Closed · Coffee Shop · $ · 4.4 (27 reviews)** \n_402 E 140th St (Willis Ave), Bronx, NY 10454_ \nCozy breakfast‑lunch café with bookstore vibe, rooftop deck, quiet even when busy—nice for work/study.\n\n**Boogie Down Grind** \n**Closed · Coffee Shop · $ · 3.9 (12 reviews)** \n_868 Hunts Point Ave, Bronx, NY 10474_ \nCharming café with unique subway‑car design, cozy and quiet with background music and community atmosphere.", "items": [ { "type": "chat_gpt_local_businesses_element", "title": "La Casa Del Caffe", "description": "A local favorite on Morris Park Avenue, known for great cappuccinos and one of the best places to work in the neighbourhood.", "address": "1036 Morris Park Ave (at Hone Ave), Bronx, NY 10461", "phone": "+17189317816", "reviews_count": 22, "url": "http://www.lacasadelcaffe.com?utm_source=chatgpt.com", "domain": "www.lacasadelcaffe.com", "rating": { "rating_type": "Max5", "value": 3.9, "votes_count": 22, "rating_max": 5 } }, { "type": "chat_gpt_local_businesses_element", "title": "Prince Coffee House", "description": "Spacious, bright interior on Arthur Ave (“Little Italy”), ample seating, stays open until 11 pm—great for late‑night study.", "address": "2306 Arthur Ave, Bronx, NY 10458", "phone": "+13472701030", "reviews_count": 44, "url": "http://www.devollicorporation.com/?id=3&utm_source=chatgpt.com", "domain": "www.devollicorporation.com", "rating": { "rating_type": "Max5", "value": 3.7, "votes_count": 44, "rating_max": 5 } }, { "type": "chat_gpt_local_businesses_element", "title": "Mottley Kitchen", "description": "Cozy breakfast‑lunch café with bookstore vibe, rooftop deck, quiet even when busy—nice for work/study.", "address": "402 E 140th St (Willis Ave), Bronx, NY 10454", "phone": "+19293082099", "reviews_count": 27, "url": "http://www.mottleykitchen.com?utm_source=chatgpt.com", "domain": "www.mottleykitchen.com", "rating": { "rating_type": "Max5", "value": 4.4, "votes_count": 27, "rating_max": 5 } }, { "type": "chat_gpt_local_businesses_element", "title": "Boogie Down Grind", "description": "Charming café with unique subway‑car design, cozy and quiet with background music and community atmosphere.", "address": "868 Hunts Point Ave, Bronx, NY 10474", "phone": "+17189868548", "reviews_count": 12, "url": null, "domain": null, "rating": { "rating_type": "Max5", "value": 3.9, "votes_count": 12, "rating_max": 5 } } ] }, { "type": "chat_gpt_navigation_list", "rank_group": 1, "rank_absolute": 5, "title": "Further reading on Einstein", "sources": [ { "type": "chat_gpt_source", "title": "March 14, 1879: Mr. Big", "snippet": null, "domain": "www.wired.com", "url": "https://www.wired.com/2007/03/march-14-1879-mr-big?utm_source=chatgpt.com", "thumbnail": "https://media.wired.com/photos/615e2b8ce78a8cd913bbaa76/16:9/w_1280,c_limit/wired_bug.jpg", "source_name": null, "publication_date": "2007-03-14 16:00:00 +00:00", "markdown": null }, { "type": "chat_gpt_source", "title": "The Valiant Swabian", "snippet": null, "domain": "www.newyorker.com", "url": "https://www.newyorker.com/magazine/2007/04/02/the-valiant-swabian?utm_source=chatgpt.com", "thumbnail": "https://media.newyorker.com/photos/5909308aebe912338a371892/16:9/w_1280,c_limit/070402_r16064b_p646.jpg", "source_name": null, "publication_date": "2007-03-26 04:00:00 +00:00", "markdown": null } ] } ] } ] } ] }
Description of the fields for sending a request:
Field name | Type | Description |
---|---|---|
id |
string | task identifier a universally unique identifier (UUID) unique task identifier in our system you will be able to use it within 30 days to request the results of the task at any time |
As a response of the API server, you will receive JSON-encoded data containing a tasks
array with the information specific to the set tasks.
Description of the fields in the results array:
Field name | Type | Description |
---|---|---|
version |
string | the current version of the API |
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 |
time |
string | execution time, seconds |
cost |
float | total tasks cost, USD |
tasks_count |
integer | the number of tasks in the tasks array |
tasks_error |
integer | the number of tasks in the tasks array returned with an error |
tasks |
array | array of tasks |
id |
string | task identifier unique task identifier in our system in the UUID format |
status_code |
integer | status code of the task generated by DataForSEO; can be within the following range: 10000-60000 you can find the full list of the response codes here |
status_message |
string | informational message of the task you can find the full list of general informational messages here |
time |
string | execution time, seconds |
cost |
float | cost of the task, USD |
result_count |
integer | number of elements in the result array |
path |
array | URL path |
data |
object | contains the same parameters that you specified in the POST request |
result |
array | array of results |
keyword |
string | keyword received in a POST array the keyword is returned with decoded %## (plus symbol ‘+’ will be decoded to a space character) |
type |
string | search engine type in a POST array |
se_domain |
string | search engine domain in a POST array |
location_code |
integer | location code in a POST array |
language_code |
string | language code in a POST array |
check_url |
string | direct URL to search engine results you can use it to make sure that we provided exact results |
datetime |
string | date and time when the result was received in the UTC format: “yyyy-mm-dd hh-mm-ss +00:00” example: 2019-11-15 12:57:46 +00:00 |
markdown |
string | content of the element in markdown format content of the result formatted in the markdown markup language |
search_results |
array | array of search results |
type |
string | type of element = ‘chatgpt_search_result’ |
url |
string | result URL |
domain |
string | result domain |
title |
string | result title |
description |
string | result description |
breadcrumb |
string | breadcrumb |
sources |
array | array of sources |
type |
string | type of element = ‘chatgpt_source’ |
title |
string | source title |
snippet |
string | source description |
domain |
string | source domain in SERP |
url |
string | source URL |
thumbnail |
string | source thumbnail |
source_name |
string | source name |
publication_date |
string | date and time when the result was published in the format: “year-month-date:minutes:UTC_difference_hours:UTC_difference_minutes” example: 2019-11-15 12:57:46 +00:00 |
markdown |
string | content of the element in markdown format content of the result formatted in the markdown markup language |
se_results_count |
integer | total number of results |
item_types |
array | types of search results contains types of search results ( items ) found.possible item types: chatgpt_text , chatgpt_table , chatgpt_navigation_list , chatgpt_images , chatgpt_local_businesses , chatgpt_products |
items_count |
integer | the number of results returned in the items array |
items |
array | elements of ChatGPT results |
‘chatgpt_text’ element | ||
type |
string | type of element = ‘chatgpt_text’ |
rank_group |
integer | group rank in SERP position within a group of elements with identical type valuespositions of elements with different type values are omitted from rank_group |
rank_absolute |
integer | absolute rank in SERP absolute position among all the elements |
markdown |
string | content of the element in markdown format content of the result formatted in the markdown markup language |
sources |
array | array of sources |
type |
string | type of element = ‘chatgpt_source’ |
title |
string | source title |
snippet |
string | source description |
domain |
string | source domain |
url |
string | source URL |
thumbnail |
string | source thumbnail |
source_name |
string | source name |
publication_date |
string | date and time when the result was published in the format: “year-month-date:minutes:UTC_difference_hours:UTC_difference_minutes” example: 2019-11-15 12:57:46 +00:00 |
markdown |
string | content of the element in markdown format content of the result formatted in the markdown markup language |
‘chatgpt_table’ element | ||
type |
string | type of element = ‘chatgpt_table’ |
rank_group |
integer | group rank in SERP position within a group of elements with identical type valuespositions of elements with different type values are omitted from rank_group |
rank_absolute |
integer | absolute rank in SERP absolute position among all the elements in SERP |
text |
string | text of the element |
markdown |
string | content of the element in markdown format content of the result formatted in the markdown markup language |
table |
object | table present in the element the header and content of the table present in the element |
table_header |
array | content in the header of the table |
table_content |
array | array of contents of the table present in the element each array represents the table row |
‘chatgpt_navigation_list’ element | ||
type |
string | type of element = ‘chatgpt_navigation_list’ |
rank_group |
integer | group rank in SERP position within a group of elements with identical type valuespositions of elements with different type values are omitted from rank_group |
rank_absolute |
integer | absolute rank in SERP absolute position among all the elements in SERP |
title |
string | title of the element |
sources |
array | array of sources |
type |
string | type of element = ‘chatgpt_source’ |
title |
string | source title |
snippet |
string | source description |
domain |
string | source domain |
url |
string | source URL |
thumbnail |
string | source thumbnail |
source_name |
string | source name |
publication_date |
string | date and time when the result was published in the format: “year-month-date:minutes:UTC_difference_hours:UTC_difference_minutes” example: 2019-11-15 12:57:46 +00:00 |
markdown |
string | content of the element in markdown format content of the result formatted in the markdown markup language |
‘chatgpt_images’ element | ||
type |
string | type of element = ‘chatgpt_images’ |
rank_group |
integer | group rank in SERP position within a group of elements with identical type valuespositions of elements with different type values are omitted from rank_group |
rank_absolute |
integer | absolute rank in SERP absolute position among all the elements in SERP |
markdown |
string | content of the element in markdown format content of the result formatted in the markdown markup language |
items |
array | items present in the element |
type |
string | type of element = ‘images_element‘ |
alt |
string | alt tag of the image |
url |
string | relevant URL |
image_url |
string | URL of the image the URL leading to the image on the original resource or DataForSEO storage (in case the original source is not available) |
markdown |
string | content of the element in markdown format content of the result formatted in the markdown markup language |
‘chatgpt_local_businesses’ element | ||
type |
string | type of element = ‘chatgpt_local_businesses’ |
rank_group |
integer | group rank in SERP position within a group of elements with identical type valuespositions of elements with different type values are omitted from rank_group |
rank_absolute |
integer | absolute rank in SERP absolute position among all the elements in SERP |
markdown |
string | content of the element in markdown format content of the result formatted in the markdown markup language |
items |
array | items present in the element |
type |
string | type of element = ‘chatgpt_local_businesses_element‘ |
title |
string | title of the local businesses |
description |
string | description of the local businesses |
address |
string | address of the local businesses |
phone |
string | phone of the local businesses |
reviews_count |
integer | total number of reviews submitted for the local businesses |
rating |
object | rating of the corresponding local businesses popularity rate based on reviews as displayed in the results |
rating_type |
string | type of rating here you can find the following elements: Max5 , Percents , CustomMax |
value |
float | the average rating based on all reviews |
votes_count |
integer | the number of votes |
rating_max |
integer | the maximum value for a rating_type |
‘chatgpt_products’ element | ||
type |
string | type of element = ‘chatgpt_products’ |
rank_group |
integer | group rank in SERP position within a group of elements with identical type valuespositions of elements with different type values are omitted from rank_group |
rank_absolute |
integer | absolute rank in SERP absolute position among all the elements in SERP |
items |
array | items present in the element |
type |
string | type of element = ‘chatgpt_products_element‘ |
product_id |
string | product id |
title |
string | title of the product |
rating |
object | rating of the product popularity rate based on reviews and displayed in SERP |
rating_type |
string | type of rating here you can find the following elements: Max5 , Percents , CustomMax |
value |
float | the average rating based on all reviews |
votes_count |
integer | the number of votes |
rating_max |
integer | the maximum value for a rating_type |
price |
float | product price |
currency |
string | currency of the listed price ISO code of the currency applied to the price |
tag |
string | tag text |
url |
string | result URL |
domain |
string | result domain |
images |
array | image URLs of the element contains URLs leading to the images on the original resource or DataForSEO storage (in case the original source is not available) |