This endpoint is designed to provide you with a list of completed tasks, which haven’t been collected yet. If you use the Standard method without specifying the postback_url, you can receive the list of id for all completed tasks using this endpoint. Then, you can collect the results using the ‘Task GET’ endpoint.
Learn more about task completion and obtaining a list of completed tasks in this help center article.
Tasks using the Standard method may take up to 72 hours to complete. If the task is not completed within this time, it is marked as failed, and the $0.01 advance is refunded. It is also important to note that if your account balance is negative, you will not receive the results even if the task is completed successfully.
Note: due to the peculiarities of our architecture the queue of completed tasks is updated with a small delay, which can be an issue for high-volume users. If your system requires collecting over 1000 tasks a minute, we recommend using pingbacks/postbacks instead, and applying the Tasks Ready endpoint only to obtain the IDs of failed postback tasks.
Instead of ‘login’ and ‘password’ use your credentials from https://app.dataforseo.com/api-access
# 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 GET "https://api.dataforseo.com/v3/ai_optimization/claude/llm_responses/tasks_ready" \
--header "Authorization: Basic ${cred}" \
--header "Content-Type: application/json" \
--data-raw ''
"""
Method: GET
Endpoint: https://api.dataforseo.com/v3/ai_optimization/claude/llm_responses/tasks_ready
@see https://docs.dataforseo.com/v3/ai_optimization/claude/llm_responses/tasks_ready
"""
import sys
import os
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '../../../../../')))
from lib.client import RestClient
from lib.config import username, password
client = RestClient(username, password)
try:
response = client.get('/v3/ai_optimization/claude/llm_responses/tasks_ready')
print(response)
# do something with get result
except Exception as e:
print(f'An error occurred: {e}')
const axios = require('axios');
axios({
method: 'get',
url: 'https://api.dataforseo.com/v3/ai_optimization/claude/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);
});
using System;
using System.Linq;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Collections.Generic;
using System.Threading.Tasks;
using Newtonsoft.Json;
namespace DataForSeoSdk;
public class AiOptimization
{
private static readonly HttpClient _httpClient;
static AiOptimization()
{
_httpClient = new HttpClient
{
BaseAddress = new Uri("https://api.dataforseo.com/")
};
_httpClient.DefaultRequestHeaders.Authorization =
new AuthenticationHeaderValue("Basic", ApiConfig.Base64Auth);
}
/// <summary>
/// Method: GET
/// Endpoint: https://api.dataforseo.com/v3/ai_optimization/claude/llm_responses/tasks_ready
/// </summary>
/// <see href="https://docs.dataforseo.com/v3/ai_optimization/claude/llm_responses/tasks_ready"/>
public static async Task ClaudeLlmResponsesTaskGet()
{
// #1 - using this method you can get a list of completed tasks
using var response = await _httpClient.GetAsync("/v3/ai_optimization/claude/llm_responses/tasks_ready");
var tasksInfo = JsonConvert.DeserializeObject<dynamic>(await response.Content.ReadAsStringAsync());
var tasksResponses = new List<object>();
// 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)
{
string taskEndpoint = null;
// #2 - using this method you can get results of each completed task
if (task.endpoint != null)
taskEndpoint = (string)task.endpoint;
if (taskEndpoint != null)
{
using var taskGetResponse = await _httpClient.GetAsync(taskEndpoint);
var taskResultObj = JsonConvert.DeserializeObject<dynamic>(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);
}
}
}
}
}
}
if (tasksResponses.Count > 0)
Console.WriteLine(JsonConvert.SerializeObject(tasksResponses, Formatting.Indented));
else
Console.WriteLine("No completed tasks");
}
else
Console.WriteLine($"error. Code: {tasksInfo.status_code} Message: {tasksInfo.status_message}");
}
The above command returns JSON structured like this:
Each separate task will remain on the list until it is collected. You can make up to 20 API calls per minute. With each API call, you can get 1000 tasks completed within three previous days. The list will not contain the tasks which have already been collected and the tasks that were not collected within the three days after completion.
Please note that if you specify the postback_url, the task will not be in the list of completed tasks. The task can only be found in the list if the request to your server failed, and your server returned HTTP code response less than 200 or higher than 300.
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 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 parameters passed in the request’s URL
result
array
array of results
id
string
task identifier of the completed task unique task identifier in our system in the UUID format