### Get Completed Tasks (Node.js) Source: https://docs.dataforseo.com/v3/keywords_data/google/ad_traffic_by_keywords/tasks_ready This Node.js example shows how to get a list of completed tasks. Install the 'dataforseo-client' package via npm. ```javascript const dfs = require('dataforseo-client'); (async () => { const client = new dfs.Client('login', 'password'); try { const response = await client.keywords_data.google.ad_traffic_by_keywords.tasksReady(); console.log(response); } catch (e) { console.error(e); } })(); ``` -------------------------------- ### Initialize HTTP Client and Get Tasks Ready (C#) Source: https://docs.dataforseo.com/v3/merchant/google/product_info/task_get/advanced Sets up an HttpClient with authorization headers for the DataForSEO API. It then fetches a list of ready tasks for Google product information. Ensure you replace 'login' and 'password' with your actual API credentials. ```csharp using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Net.Http; using System.Net.Http.Headers; using System.Text; using System.Threading.Tasks; namespace DataForSeoDemos { public static partial class Demos { public static async Task merchant_google_product_info_task_get() { 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"))) } }; // #1 - using this method you can get a list of completed tasks // GET /v3/merchant/google/product_info/tasks_ready var response = await httpClient.GetAsync("/v3/merchant/google/product_info/tasks_ready"); var tasksInfo = JsonConvert.DeserializeObject(await response.Content.ReadAsStringAsync()); var tasksResponses = new List(); // you can find the full list of the response codes here https://docs.dataforseo.com/v3/appendix/errors if (tasksInfo.status_code == 20000) { if (tasksInfo.tasks != null) { foreach (var tasks in tasksInfo.tasks) { if (tasks.result != null) { foreach (var task in tasks.result) { if (task.endpoint_advanced != null) { // #2 - using this method you can get results of each completed task // GET /v3/merchant/google/product_info/task_get/advanced/$id var taskGetResponse = await httpClient.GetAsync((string)task.endpoint_advanced); var taskResultObj = JsonConvert.DeserializeObject(await taskGetResponse.Content.ReadAsStringAsync()); if (taskResultObj.tasks != null) { var fst = taskResultObj.tasks.First; // you can find the full list of the response codes here https://docs.dataforseo.com/v3/appendix/errors if (fst.status_code >= 40000 || fst.result == null) Console.WriteLine($"error. Code: {fst.status_code} Message: {fst.status_message}"); else tasksResponses.Add(fst.result); } // #3 - another way to get the task results by id // GET /v3/merchant/google/product_info/task_get/advanced/$id /* var tasksGetResponse = await httpClient.GetAsync("/v3/merchant/google/product_info/task_get/advanced/" + (string)task.id); var taskResultObj = JsonConvert.DeserializeObject(await tasksGetResponse.Content.ReadAsStringAsync()); if (taskResultObj.tasks != null) { var fst = taskResultObj.tasks.First; ``` -------------------------------- ### Initialize HTTP Client and Get Tasks Ready (C#) Source: https://docs.dataforseo.com/v3/serp/google/images/task_get/advanced Sets up an HttpClient with authentication and retrieves a list of ready tasks for Google Images SERP. This is the first step before fetching individual task results. Ensure your API credentials are used. ```csharp 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"))) } }; // #1 - using this method you can get a list of completed tasks // GET /v3/serp/google/images/tasks_ready // in addition to 'google' and 'images' you can also set other search engine and type parameters // the full list of possible parameters is available in documentation var response = await httpClient.GetAsync("/v3/serp/google/images/tasks_ready"); var tasksInfo = JsonConvert.DeserializeObject(await response.Content.ReadAsStringAsync()); var tasksResponses = new List(); // you can find the full list of the response codes here https://docs.dataforseo.com/v3/appendix/errors if (tasksInfo.status_code == 20000) { foreach (var tasks in tasksInfo.tasks) { if (tasks.First.result != null) { foreach (var task in tasks.First.result) { if (task.endpoint_advanced != null) { // #2 - using this method you can get results of each completed task // GET /v3/serp/google/images/task_get/advanced/$id var tasksGetResponse = await httpClient.GetAsync((string)task.endpoint_advanced); var tasksResultObj = JsonConvert.DeserializeObject(await tasksGetResponse.Content.ReadAsStringAsync()); if (tasksResultObj.tasks != null) { foreach (var taskResult in tasksResultObj.tasks) { var fst = taskResult.First; // you can find the full list of the response codes here https://docs.dataforseo.com/v3/appendix/errors if (fst.status_code >= 40000 || fst.result == null) Console.WriteLine($"error. Code: {fst.status_code} Message: {fst.status_message}"); else tasksResponses.Add(fst.result); } } // #3 - another way to get the task results by id // GET /v3/serp/google/images/task_get/advanced/$id /* var tasksGetResponse = await httpClient.GetAsync("/v3/serp/google/images/task_get/advanced/" + (string)task.id); var tasksResultObj = JsonConvert.DeserializeObject(await tasksGetResponse.Content.ReadAsStringAsync()); if (tasksResultObj.tasks != null) { foreach (var taskResult in tasksResultObj.tasks) { ``` -------------------------------- ### Get Google Trends Categories List (Node.js) Source: https://docs.dataforseo.com/v3/keywords_data/google_trends/categories This Node.js example uses the axios library to perform a GET request for Google Trends categories. It includes basic error handling and logs the results to the console. Ensure axios is installed (`npm install axios`). ```javascript const axios = require('axios'); axios({ method: 'get', url: 'https://api.dataforseo.com/v3/keywords_data/google_trends/categories', auth: { username: 'login', password: 'password' }, headers: { 'content-type': 'application/json' } }).then(function (response) { var result = response['data']['tasks'][0]['result']; // Result data console.log(result); }).catch(function (error) { console.log(error); }); ``` -------------------------------- ### Get ChatGPT LLM Responses Tasks Ready (Node.js) Source: https://docs.dataforseo.com/v3/ai_optimization/chat_gpt/llm_responses/tasks_ready This Node.js example uses the axios library to make a GET request to the API. It handles authentication using the 'auth' object and logs the task results or any errors encountered. Ensure axios is installed (`npm install axios`). ```javascript const axios = require('axios'); axios({ method: 'get', url: 'https://api.dataforseo.com/v3/ai_optimization/chat_gpt/llm_responses/tasks_ready', auth: { username: 'login', password: 'password' }, headers: { 'content-type': 'application/json' } }).then(function (response) { var result = response['data']['tasks'][0]['result']; // Result data console.log(result); }).catch(function (error) { console.log(error); }); ``` -------------------------------- ### Initialize HTTP Client and Get Tasks Ready (C#) Source: https://docs.dataforseo.com/v3/serp/google/organic/task_get/advanced Sets up an HttpClient with basic authentication for the Dataforseo API. It then fetches a list of ready tasks using the `/v3/serp/google/organic/tasks_ready` endpoint. ```csharp using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Net.Http; using System.Net.Http.Headers; using System.Text; using System.Threading.Tasks; namespace DataForSeoDemos { public static partial class Demos { public static async Task serp_task_get() { 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"))) } }; // #1 - using this method you can get a list of completed tasks // GET /v3/serp/google/organic/tasks_ready // 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 response = await httpClient.GetAsync("/v3/serp/google/organic/tasks_ready"); var tasksInfo = JsonConvert.DeserializeObject(await response.Content.ReadAsStringAsync()); var tasksResponses = new List(); // you can find the full list of the response codes here https://docs.dataforseo.com/v3/appendix/errors if (tasksInfo.status_code == 20000) { if (tasksInfo.tasks != null) { foreach (var tasks in tasksInfo.tasks) { if (tasks.result != null) { foreach (var task in tasks.result) { if (task.endpoint_advanced != null) { // #2 - using this method you can get results of each completed task // GET /v3/serp/google/organic/task_get/advanced/$id var taskGetResponse = await httpClient.GetAsync((string)task.endpoint_advanced); var taskResultObj = JsonConvert.DeserializeObject(await taskGetResponse.Content.ReadAsStringAsync()); if (taskResultObj.tasks != null) { var fst = taskResultObj.tasks.First; // you can find the full list of the response codes here https://docs.dataforseo.com/v3/appendix/errors if (fst.status_code >= 40000 || fst.result == null) Console.WriteLine($"error. Code: {fst.status_code} Message: {fst.status_message}"); else tasksResponses.Add(fst.result); } // #3 - another way to get the task results by id // GET /v3/serp/google/organic/task_get/advanced/$id /* var tasksGetResponse = await httpClient.GetAsync("/v3/serp/google/organic/task_get/advanced/" + (string)task.id); var tasksResultObj = JsonConvert.DeserializeObject(await tasksGetResponse.Content.ReadAsStringAsync()); if (tasksResultObj.tasks != null) { var fst = taskResultObj.tasks.First; ``` -------------------------------- ### Get Completed Tasks - Python Example Source: https://docs.dataforseo.com/v3/keywords_data/google/ad_traffic_by_platforms/tasks_ready?php= This Python script utilizes the 'requests' library to fetch completed tasks for Ad Traffic By Platforms. Ensure you have the 'requests' library installed (`pip install requests`). ```python import requests api_url = "https://api.dataforseo.com/v3/keywords_data/google/ad_traffic_by_platforms/tasks_ready" login = "your_login" password = "your_password" response = requests.get(api_url, auth=(login, password)) # Print the result # print(response.text) ``` -------------------------------- ### Initialize HttpClient and Get Ready Tasks (C#) Source: https://docs.dataforseo.com/v3/serp/youtube/organic/task_get/advanced Sets up an HttpClient with authentication and retrieves a list of ready YouTube organic tasks. This is the first step before fetching individual task results. Ensure your API credentials are used. ```csharp 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"))) } }; // #1 - using this method you can get a list of completed tasks // GET /v3/serp/youtube/organic/tasks_ready // in addition to 'youtube' and 'organic' you can also set other search engine and type parameters // the full list of possible parameters is available in documentation var response = await httpClient.GetAsync("/v3/serp/youtube/organic/tasks_ready"); var tasksInfo = JsonConvert.DeserializeObject(await response.Content.ReadAsStringAsync()); var tasksResponses = new List(); // you can find the full list of the response codes here https://docs.dataforseo.com/v3/appendix/errors if (tasksInfo.status_code == 20000) { foreach (var tasks in tasksInfo.tasks) { if (tasks.First.result != null) { foreach (var task in tasks.First.result) { if (task.endpoint_advanced != null) { // #2 - using this method you can get results of each completed task // GET /v3/serp/youtube/organic/task_get/advanced/$id var tasksGetResponse = await httpClient.GetAsync((string)task.endpoint_advanced); var tasksResultObj = JsonConvert.DeserializeObject(await tasksGetResponse.Content.ReadAsStringAsync()); if (tasksResultObj.tasks != null) { foreach (var taskResult in tasksResultObj.tasks) { var fst = taskResult.First; // you can find the full list of the response codes here https://docs.dataforseo.com/v3/appendix/errors if (fst.status_code >= 40000 || fst.result == null) Console.WriteLine($"error. Code: {fst.status_code} Message: {fst.status_message}"); else tasksResponses.Add(fst.result); } } // #3 - another way to get the task results by id // GET /v3/serp/youtube/organic/task_get/advanced/$id /* var tasksGetResponse = await httpClient.GetAsync("/v3/serp/youtube/organic/task_get/advanced/" + (string)task.id); var tasksResultObj = JsonConvert.DeserializeObject(await tasksGetResponse.Content.ReadAsStringAsync()); if (tasksResultObj.tasks != null) { foreach (var taskResult in tasksResultObj.tasks) */ } } } } } ``` -------------------------------- ### Bash Example for Google Jobs SERP Task Get Advanced Source: https://docs.dataforseo.com/v3/serp/google/jobs/task_get/advanced?bash= This example demonstrates how to use curl to retrieve advanced results for a Google Jobs SERP task using its ID. It includes authentication and header setup. ```APIDOC ## GET /v3/serp/google/jobs/task_get/advanced/${id} ### Description Retrieves the advanced results of a completed Google Jobs SERP task. ### Method GET ### Endpoint https://api.dataforseo.com/v3/serp/google/jobs/task_get/advanced/${id} ### Parameters #### Path Parameters - **id** (string) - Required - The ID of the completed task. ### Headers - **Authorization**: Basic ${cred} - **Content-Type**: application/json ### Request Example ```bash login="login" password="password" cred="$(printf ${login}:${password} | base64)" id="02261816-2027-0066-0000-c27d02864073" curl --location --request GET "https://api.dataforseo.com/v3/serp/google/jobs/task_get/advanced/${id}" \ --header "Authorization: Basic ${cred}" \ --header "Content-Type: application/json" \ --data-raw "" ``` ``` -------------------------------- ### Initialize HTTP Client and Fetch Tasks Ready Source: https://docs.dataforseo.com/v3/serp/google/finance_ticker_search/task_get/advanced Sets up an HTTP client with authentication and fetches a list of ready tasks for Google Finance ticker search. Replace 'login' and 'password' with your actual API credentials. ```csharp 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"))) } }; // #1 - using this method you can get a list of completed tasks // GET /v3/serp/google/finance_ticker_search/tasks_ready // in addition to 'google' and 'finance_ticker_search' you can also set other search engine and type parameters // the full list of possible parameters is available in documentation var response = await httpClient.GetAsync("/v3/serp/google/finance_ticker_search/tasks_ready"); var tasksInfo = JsonConvert.DeserializeObject(await response.Content.ReadAsStringAsync()); var tasksResponses = new List(); // you can find the full list of the response codes here https://docs.dataforseo.com/v3/appendix/errors if (tasksInfo.status_code == 20000) ``` -------------------------------- ### Initialize HTTP Client and Get Tasks Ready (C#) Source: https://docs.dataforseo.com/v3/app_data/google/app_reviews/task_get/html Sets up an HttpClient with authentication for the DataForSEO API. It then makes a request to the tasks_ready endpoint to get a list of completed tasks. Ensure you replace 'login' and 'password' with your actual API credentials. ```csharp 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"))) }; // #1 - using this method you can get a list of completed tasks // GET /v3/app_data/google/app_reviews/tasks_ready var response = await httpClient.GetAsync("/v3/app_data/google/app_reviews/tasks_ready"); var tasksInfo = JsonConvert.DeserializeObject(await response.Content.ReadAsStringAsync()); var tasksResponses = new List(); // you can find the full list of the response codes here https://docs.dataforseo.com/v3/appendix/errors if (tasksInfo.status_code == 20000) { if (tasksInfo.tasks != null) { foreach (var tasks in tasksInfo.tasks) { if (tasks.result != null) { foreach (var task in tasks.result) { if (task.endpoint_html != null) { // #2 - using this method you can get results of each completed task // GET /v3/app_data/google/app_reviews/task_get/html/$id var taskGetResponse = await httpClient.GetAsync((string)task.endpoint_html); var taskResultObj = JsonConvert.DeserializeObject(await taskGetResponse.Content.ReadAsStringAsync()); if (taskResultObj.tasks != null) { var fst = taskResultObj.tasks.First; // you can find the full list of the response codes here https://docs.dataforseo.com/v3/appendix/errors if (fst.status_code >= 40000 || fst.result == null) Console.WriteLine($"error. Code: {fst.status_code} Message: {fst.status_message}"); else tasksResponses.Add(fst.result); } // #3 - another way to get the task results by id // GET /v3/app_data/google/app_reviews/task_get/html/$id /* var tasksGetResponse = await httpClient.GetAsync("/v3/app_data/google/app_reviews/task_get/html/" + (string)task.id); var taskResultObj = JsonConvert.DeserializeObject(await tasksGetResponse.Content.ReadAsStringAsync()); if (taskResultObj.tasks != null) { var fst = taskResultObj.tasks.First; // you can find the full list of the response codes here https://docs.dataforseo.com/v3/appendix/errors ``` -------------------------------- ### Get Bulk Keyword Difficulty (Node.js) Source: https://docs.dataforseo.com/v3/dataforseo_labs/google/bulk_keyword_difficulty/live This Node.js example shows how to call the Bulk Keyword Difficulty API. You will need to install the DataForSEO client library. ```javascript const dataforseo = require("dataforseo-node"); const client = new dataforseo({ "login": "login", "password": "password" }); client.keywords_data.google_keyword_difficulty({ "locations": ["United States"], "language": ["en"] }) .then(function(data) { console.log(data); }) .catch(function(error) { console.error(error); }); ``` -------------------------------- ### Get Google Finance Markets HTML Results by ID using Node.js Source: https://docs.dataforseo.com/v3/serp/google/finance_markets/task_get/html This Node.js example shows how to make a GET request to retrieve HTML results for a Google Finance Markets task using its ID. You will need to install the 'request' module. ```javascript const request = require('request'); const url = 'https://api.dataforseo.com/v3/serp/google/finance_markets/task_get/html/$id'; // Replace 'login' and 'password' with your credentials request.get(url, { auth: { user: 'login', pass: 'password' } }, (error, response, body) => { if (response.statusCode == 200) { console.log(JSON.parse(body)); } else { console.error('Error:', response.statusCode, body); } }); ``` -------------------------------- ### C# Example for Google Keyword Overview Live API Source: https://docs.dataforseo.com/v3/dataforseo_labs/google/keyword_overview/live This C# code example shows how to use the DataForSEO Labs Google Keyword Overview Live API. It includes setting up an HttpClient, authenticating with API credentials, constructing the POST request body with keyword data, sending the request, and deserializing the JSON response. Error handling is also demonstrated. ```csharp using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Net.Http; using System.Net.Http.Headers; using System.Text; using System.Threading.Tasks; namespace DataForSeoDemos { public static partial class Demos { public static async Task dataforseo_labs_google_keyword_overview_live() { 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(); postData.Add(new { keywords = new[] { "iphone" }, location_name = "United States", language_name = "English" }); // POST /v3/dataforseo_labs/google/keyword_overview/live // the full list of possible parameters is available in documentation var taskPostResponse = await httpClient.PostAsync("/v3/dataforseo_labs/google/keyword_overview/live", new StringContent(JsonConvert.SerializeObject(postData))); var result = JsonConvert.DeserializeObject(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}"); } } } ``` -------------------------------- ### Get Ready Amazon Product Tasks via Node.js Source: https://docs.dataforseo.com/v3/merchant/amazon/products/tasks_ready This Node.js example uses the axios library to make a GET request to retrieve completed Amazon product tasks. Ensure you have axios installed and replace 'login' and 'password' with your API credentials. ```javascript const axios = require('axios'); axios({ method: 'get', url: 'https://api.dataforseo.com/v3/merchant/amazon/products/tasks_ready', auth: { username: 'login', password: 'password' }, headers: { 'content-type': 'application/json' } }).then(function (response) { var result = response['data']['tasks'][0]['result']; // Result data console.log(result); }).catch(function (error) { console.log(error); }); ``` -------------------------------- ### C# Example: Fetch Google Sellers Tasks and Results Source: https://docs.dataforseo.com/v3/merchant/google/sellers/task_get/advanced Initializes an HTTP client with authentication, fetches a list of ready tasks, and then retrieves advanced results for each completed task. Includes error handling for API responses. ```csharp using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Net.Http; using System.Net.Http.Headers; using System.Text; using System.Threading.Tasks; namespace DataForSeoDemos { public static partial class Demos { public static async Task merchant_google_sellers_task_get() { 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"))) } }; // #1 - using this method you can get a list of completed tasks // GET /v3/merchant/google/sellers/tasks_ready var response = await httpClient.GetAsync("/v3/merchant/google/sellers/tasks_ready"); var tasksInfo = JsonConvert.DeserializeObject(await response.Content.ReadAsStringAsync()); var tasksResponses = new List(); // you can find the full list of the response codes here https://docs.dataforseo.com/v3/appendix/errors if (tasksInfo.status_code == 20000) { if (tasksInfo.tasks != null) { foreach (var tasks in tasksInfo.tasks) { if (tasks.result != null) { foreach (var task in tasks.result) { if (task.endpoint_advanced != null) { // #2 - using this method you can get results of each completed task // GET /v3/merchant/google/sellers/task_get/advanced/$id var taskGetResponse = await httpClient.GetAsync((string)task.endpoint_advanced); var taskResultObj = JsonConvert.DeserializeObject(await taskGetResponse.Content.ReadAsStringAsync()); if (taskResultObj.tasks != null) { var fst = taskResultObj.tasks.First; // you can find the full list of the response codes here https://docs.dataforseo.com/v3/appendix/errors if (fst.status_code >= 40000 || fst.result == null) Console.WriteLine($"error. Code: {fst.status_code} Message: {fst.status_message}"); else tasksResponses.Add(fst.result); } // #3 - another way to get the task results by id // GET /v3/merchant/google/sellers/task_get/advanced/$id /* var tasksGetResponse = await httpClient.GetAsync("/v3/merchant/google/sellers/task_get/advanced/" + (string)task.id); var taskResultObj = JsonConvert.DeserializeObject(await tasksGetResponse.Content.ReadAsStringAsync()); if (taskResultObj.tasks != null) { var fst = taskResultObj.tasks.First; // you can find the full list of the response codes here https://docs.dataforseo.com/v3/appendix/errors ``` -------------------------------- ### Get AI Models List using Node.js (axios) Source: https://docs.dataforseo.com/v3/ai_optimization/claude/llm_responses/models This Node.js example uses the 'axios' library to make a GET request to the API for a list of AI models. It includes basic error handling and logs the results. Ensure 'axios' is installed. ```javascript const axios = require('axios'); axios({ method: 'get', url: 'https://api.dataforseo.com/v3/ai_optimization/claude/llm_responses/models', auth: { username: 'login', password: 'password' }, data: [{ version: "v3" }], headers: { 'content-type': 'application/json' } }).then(function (response) { var result = response['data']['tasks'][0]['result']; // Result data console.log(result); }).catch(function (error) { console.log(error); }); ``` -------------------------------- ### C# Example for Bulk Search Volume Live API Source: https://docs.dataforseo.com/v3/keywords_data/clickstream_data/bulk_search_volume/live This C# example shows how to set up an HttpClient, authenticate using Basic Auth, construct a POST request with keyword data, send it to the API, and deserialize the JSON response. It also includes basic error checking. ```csharp using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Net.Http; using System.Net.Http.Headers; using System.Text; using System.Threading.Tasks; namespace DataForSeoDemos { public static partial class Demos { public static async Task keywords_data_clickstream_bulk_search_volume_live() { 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(); postData.Add(new { location_name = "United States", keywords = new[] { "you tube", "youtube", "youtub" } }); // POST /v3/keywords_data/clickstream_data/bulk_search_volume/live // the full list of possible parameters is available in documentation var taskPostResponse = await httpClient.PostAsync("/v3/keywords_data/clickstream_data/bulk_search_volume/live", new StringContent(JsonConvert.SerializeObject(postData))); var result = JsonConvert.DeserializeObject(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}"); } } } ``` -------------------------------- ### Initialize HTTP Client and Get Tasks Ready (C#) Source: https://docs.dataforseo.com/v3/serp/google/dataset_search/task_get/advanced Sets up an HTTP client with authentication and makes a request to the 'tasks_ready' endpoint to get a list of completed tasks. Deserializes the response and checks for errors. ```csharp using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Net.Http; using System.Net.Http.Headers; using System.Text; using System.Threading.Tasks; namespace DataForSeoDemos { public static partial class Demos { public static async Task serp_task_get() { 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"))) } }; // #1 - using this method you can get a list of completed tasks // GET /v3/serp/google/dataset_search/tasks_ready var response = await httpClient.GetAsync("/v3/serp/google/dataset_search/tasks_ready"); var tasksInfo = JsonConvert.DeserializeObject(await response.Content.ReadAsStringAsync()); var tasksResponses = new List(); // you can find the full list of the response codes here https://docs.dataforseo.com/v3/appendix/errors if (tasksInfo.status_code == 20000) { if (tasksInfo.tasks != null) { foreach (var tasks in tasksInfo.tasks) { if (tasks.result != null) { foreach (var task in tasks.result) { if (task.endpoint_advanced != null) { // #2 - using this method you can get results of each completed task // GET /v3/serp/google/dataset_search/task_get/advanced/$id var taskGetResponse = await httpClient.GetAsync((string)task.endpoint_advanced); var taskResultObj = JsonConvert.DeserializeObject(await taskGetResponse.Content.ReadAsStringAsync()); if (taskResultObj.tasks != null) { var fst = taskResultObj.tasks.First; // you can find the full list of the response codes here https://docs.dataforseo.com/v3/appendix/errors if (fst.status_code >= 40000 || fst.result == null) Console.WriteLine($"error. Code: {fst.status_code} Message: {fst.status_message}"); else tasksResponses.Add(fst.result); } // #3 - another way to get the task results by id // GET /v3/serp/google/dataset_search/task_get/advanced/$id /* var tasksGetResponse = await httpClient.GetAsync("/v3/serp/google/dataset_search/task_get/advanced/" + (string)task.id); var tasksResultObj = JsonConvert.DeserializeObject(await tasksGetResponse.Content.ReadAsStringAsync()); if (tasksResultObj.tasks != null) { var fst = taskResultObj.tasks.First; // you can find the full list of the response codes here https://docs.dataforseo.com/v3/appendix/errors ``` -------------------------------- ### Example API Call in Python Source: https://docs.dataforseo.com/v3/app_data/apple/app_list/tasks_ready This Python code snippet shows how to interact with the API to get completed tasks. Ensure you have the necessary libraries installed and replace placeholders with your credentials. ```python import json from base64 import b64encode # Using Python 3, replace 'YOUR_LOGIN' and 'YOUR_PASSWORD' with your credentials auth = b64encode(f"YOUR_LOGIN:YOUR_PASSWORD".encode()).decode() # example # You can find the list of available languages in the documentation # https://docs.dataforseo.com/v3/app_data/apple/app_list/tasks_ready/ import requests headers = { 'Authorization': f'Basic {auth}' } session = requests.Session() session.headers.update(headers) response = session.get('https://api.dataforseo.com/v3/app_data/apple/app_list/tasks_ready') # print the JSON response content print(json.dumps(response.json(), indent=4)) ``` -------------------------------- ### Get Google Search Intent Data (Node.js) Source: https://docs.dataforseo.com/v3/dataforseo_labs/google/search_intent/live This Node.js example shows how to integrate with the Dataforseo Labs Google Search Intent API. You will need to install the Dataforseo client library. ```javascript const dfs = require("dataforseo-client"); const client = new dfs.DataforseoClient("login", "password"); client.keywordsIntent.live({ "data": { "keywords": [ "keyword_1", "keyword_2" ], "language_code": "en" } }).then(function(data) { console.log(JSON.stringify(data, null, 4)); }); ``` -------------------------------- ### Initialize HTTP Client for DataForSEO API (C#) Source: https://docs.dataforseo.com/v3/keywords_data/google_ads/search_volume/task_get Sets up an HttpClient with the base API address and authorization headers. Replace 'login' and 'password' with your actual API credentials. ```csharp 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"))) } }; ``` -------------------------------- ### Set Lighthouse Task (C#) Source: https://docs.dataforseo.com/v3/on_page/lighthouse/task_post This C# example demonstrates how to set up a Lighthouse task. Ensure you replace 'YOUR_LOGIN' and 'YOUR_PASSWORD' with your API credentials. ```csharp using System; using System.Collections.Generic; using DataForSeo.Client.Models.Requests; namespace DataForSeo.Example { class Program { static void Main(string[] args) { DataForSeoClient client = new DataForSeoClient("YOUR_LOGIN", "YOUR_PASSWORD"); try { var lighthouseTaskPostResponse = client.Lighthouse.TaskPost(new LighthouseTaskPostRequest { Url = "https://www.example.com", Priority = 1 }); Console.WriteLine(lighthouseTaskPostResponse); } catch (Exception e) { Console.WriteLine("Something went wrong: " + e.Message); } return 0; } } } ``` -------------------------------- ### Get Bulk Keyword Difficulty (C#) Source: https://docs.dataforseo.com/v3/dataforseo_labs/google/bulk_keyword_difficulty/live This C# example demonstrates how to use the DataForSEO SDK to retrieve keyword difficulty scores. Ensure the SDK is installed and configured with your API credentials. ```csharp using System; using System.Collections.Generic; using System.Threading.Tasks; using DataForSeo.Client.Models.Responses; using DataForSeo.Client.Services.KeywordsData; namespace DataForSeo.Examples { class Program { static async Task Main(string[] args) { var client = new DataForSeoClient("login", "password"); try { var response = await client.KeywordsData.GoogleKeywordDifficultyAsync(new KeywordsDataGoogleKeywordDifficultyRequest { Locations = new List { "United States" }, Language = new List { "en" } }); Console.WriteLine(response); } catch (Exception e) { Console.WriteLine(e); } return 0; } } } ``` -------------------------------- ### C# Authentication Example Source: https://docs.dataforseo.com/v3/auth This example demonstrates how to set up HttpClient in C# with Basic Authentication using your API credentials. ```APIDOC ## C# Authentication Example ### Description This example demonstrates how to set up HttpClient in C# with Basic Authentication using your API credentials. ### Method N/A (HttpClient Configuration) ### Endpoint https://api.dataforseo.com/ ### Parameters #### HttpClient Configuration - **BaseAddress** (Uri) - Required - The base address for the API. - **DefaultRequestHeaders.Authorization** (AuthenticationHeaderValue) - Required - Set to `Basic` followed by your Base64 encoded credentials. ### Request Example ```csharp using System; using System.Net.Http; using System.Net.Http.Headers; using System.Text; using System.Threading.Tasks; using Newtonsoft.Json; namespace DataForSeoDemos { public static partial class Demos { public static async Task cmn_key_id() { 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")))} }; // do something } } } ``` ``` -------------------------------- ### Get Advanced App Review Task Results using Python Client Source: https://docs.dataforseo.com/v3/app_data/google/app_reviews/task_get/advanced This Python example shows how to retrieve advanced app review task results by providing the task ID to the RestClient's get method. Ensure you have the RestClient library installed and your credentials configured. ```python from client import 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") # get the task results by id # GET /v3/app_data/google/app_reviews/task_get/advanced/$id id = "06141103-2692-0309-1000-980b778b6d25" response = client.get("/v3/app_data/google/app_reviews/task_get/advanced/" + id) ``` -------------------------------- ### Setting Search Volume Tasks in PHP Source: https://docs.dataforseo.com/v3/keywords_data/google_ads/search_volume/task_post This PHP example demonstrates how to set up search volume tasks. Ensure you have your API credentials ready. ```php "https://api.dataforseo.com/v3/keywords_data/google_ads/search_volume/task_post", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "POST", CURLOPT_POSTFIELDS => json_encode(["location_name" => "United States", "keyword_grouping" => "related_keywords", "keywords" => ["keyword1", "keyword2"]]), CURLOPT_HTTPHEADER => [ "Content-Type: application/json", "Authorization: Basic YOUR_BASIC_AUTHORIZATION_HEADER" ], ]); $response = curl_exec($curl); curl_close($curl); echo $response; ?> ``` -------------------------------- ### C# Example for Fetching Locations and Languages API Data Source: https://docs.dataforseo.com/v3/ai_optimization/ai_keyword_data/locations_and_languages This C# example demonstrates how to use the HttpClient to make a GET request to the DataForSEO AI Optimization API for locations and languages. It includes authentication setup, response deserialization, and error handling based on the status code. ```csharp using Newtonsoft.Json; using System; using System.Net.Http; using System.Net.Http.Headers; using System.Text; using System.Threading.Tasks; namespace DataForSeoDemos { public static partial class Demos { public static async Task dataforseo_labs_locations_and_languages() { 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"))) } }; // using this method you can get a list of locations and languages // GET /v3/ai_optimization/ai_keyword_data/locations_and_languages var response = await httpClient.GetAsync("/v3/ai_optimization/ai_keyword_data/locations_and_languages); var result = JsonConvert.DeserializeObject(await response.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 API Call (PHP) Source: https://docs.dataforseo.com/v3/merchant/amazon/asin/tasks_ready This example demonstrates how to call the 'Tasks Ready' endpoint using PHP. Replace 'login' and 'password' with your actual API credentials. ```php merchant->amazon->asin->tasksReady(array( "limit" => 100 )); print_r($response); } catch (ResponseException $e) { echo " "; print_r($e->getMessage()); } $client->flush(); ?> ``` -------------------------------- ### Get Google App Reviews HTML by Task ID (C#) Source: https://docs.dataforseo.com/v3/app_data/google/app_reviews/task_get/html This C# example demonstrates how to retrieve HTML results for a Google App Reviews task. It requires the DataForSEO .NET SDK to be installed. ```csharp using System; using System.Collections.Generic; using DataForSeo.Client.Models.Requests; namespace DataForSeo.Examples { class Program { static void Main(string[] args) { // Using Sandbox // var client = new DataforseoClient("login", "password", true); // Using live API var client = new DataforseoClient("login", "password"); try { // get the results of the task Task taskGetResponse = client.Appdata().GetGoogleAppReviewsTaskHtmlAsync(id); Console.WriteLine(taskGetResponse.Result); } catch (AggregateException e) { Console.WriteLine("Something went wrong:"); foreach (var v in e.InnerExceptions) { Console.WriteLine(v); } } return null; } } } ```