Live Business Listings Categories Aggregation Tasks
Business Listings Categories Aggregation endpoint provides results containing information about groups of related categories along with the number of entities in each category. The provided results are specific to the specified parameters.
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 POST "https://api.dataforseo.com/v3/business_data/business_listings/categories_aggregation/live"
--header "Authorization: Basic ${cred}"
--header "Content-Type: application/json"
--data-raw "[
{
"categories": [
"pizza_restaurant"
],
"description": "pizza",
"title": "pizza",
"is_claimed": true,
"location_coordinate": "53.476225,-2.243572,10",
"initial_dataset_filters": [
[
"rating.value",
">",
3
]
],
"limit": 3
}
]"
<?php
// You can download this file from here https://cdn.dataforseo.com/v3/examples/php/php_RestClient.zip?202197
require('RestClient.php');
$api_url = 'https://api.dataforseo.com/';
// Instead of 'login' and 'password' use your credentials from https://app.dataforseo.com/api-access
$client = new RestClient($api_url, null, 'login', 'password');
$post_array = array();
// simple way to get a result
$post_array[] = array(
"categories" => ["pizza_restaurant"],
"description" => "pizza",
"title" => "pizza",
"is_claimed" => true,
"location_coordinate" => "53.476225,-2.243572,10",
"initial_dataset_filters" => [
[ "rating.value",">",3 ]
],
"internal_list_limit" => 10,
"limit" => 3
);
try {
// POST /v3/business_data/business_listings/categories_aggregation/live
// the full list of possible parameters is available in documentation
$result = $client->post('/v3/business_data/business_listings/categories_aggregation/live', $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()
# simple way to set a task
post_data[len(post_data)] = dict(
categories=[
"pizza_restaurant"
],
description="pizza",
title="pizza",
is_claimed=True,
location_coordinate="53.476225,-2.243572,10",
initial_dataset_filters=[
["rating.value",">",3]
],
internal_list_limit=10,
limit=3
)
# POST /v3/business_data/business_listings/categories_aggregation/live
response = client.post("/v3/business_data/business_listings/categories_aggregation/live", 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.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;
namespace DataForSeoDemos
{
public static partial class Demos
{
public static async Task business_data_business_listings_categories_aggregation_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<object>();
// You can set only one task at a time
postData.Add(new
{
categories = new[]
{
"pizza_restaurant"
},
description = "pizza",
title = "pizza",
is_claimed = true,
location_coordinate = "53.476225,-2.243572,10",
initial_dataset_filters = new object[]
{
new object[] { "rating.value", ">", 3 }
},
limit = 3
});
// POST /v3/business_data/business_listings/categories_aggregation/live
// the full list of possible parameters is available in documentation
var taskPostResponse = await httpClient.PostAsync("/v3/business_data/business_listings/categories_aggregation/live", 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}");
}
}
}
The above command returns JSON structured like this:
All POST data should be sent in the JSON format (UTF-8 encoding). The task setting is done using the POST method. When setting a task, you should send all task parameters in the task array of the generic POST array. You can send up to 2000 API calls per minute.
Below you will find a detailed description of the fields you can use for setting a task.
Description of the fields for setting a task:
Field name
Type
Description
categories
array
business categories
optional field
the categories you specify are used to search for business listings;
if you don’t use this field, we will return business listings found in the specified location;
you can specify up to 10 categories
description
string
description of the element in SERP
optional field
the description of the business entity for which the results are collected;
can contain up to 200 characters
title
string
title of the element in SERP
optional field
the name of the business entity for which the results are collected;
can contain up to 200 characters
is_claimed
boolean
indicates whether the business is verified by its owner on Google Maps
optional field
location_coordinate
string
GPS coordinates of a location
optional field location_coordinate parameter should be specified in the “latitude,longitude,radius” format
the maximum number of decimal digits for “latitude” and “longitude”: 7
the minimum value for “radius”: 1
the maximum value for “radius”: 100000
example: 53.476225,-2.243572,200
initial_dataset_filters
array
array of results filtering parameters
optional field you can add several filters at once (8 filters maximum)
you should set a logical operator and, or between the conditions
the following operators are supported: regex, not_regex, <, <=, >, >=, =, <>, in, not_in, like, not_like
you can use the % operator with like and not_like to match any string of zero or more characters
example: ["rating.value",">",3]
you can receive the list of available filters by making a separate request to https://api.dataforseo.com/v3/business_data/business_listings/available_filters
internal_list_limit
integer
maximum number of elements within internal arrays
optional field
you can use this field to limit the number of elements within the aggregated categories
default value: 10
limit
integer
the maximum number of returned businesses
optional field
default value: 100
maximum value: 1000
offset
integer
the maximum number of returned businesses
optional field
tag
string
user-defined task identifier
optional field the character limit is 255
you can use this parameter to identify the task and match it with the result
you will find the specified tag value in the data object of the response
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 tasksarray
tasks_error
integer
the number of tasks in the tasks array returned with an error
status code of the task
generated by DataForSEO; can be within the following range: 10000-60000
status_message
string
informational message of the task
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
total_count
integer
total number of results in our database relevant to your request
count
integer
item types
the number of items in the items array
offset
integer
offset in the results array of returned categories
offset_token
string
token for subsequent requests
by specifying the unique offset_token when setting a new task, you will get the subsequent results of the initial task; offset_token values are unique for each subsequent task
items
array
encountered item types
types of search engine results encountered in the items array;
possible item types: business_category
type
string
type of element = ‘business_category’
categories
array
business categories
Google My Business general category that best describes the cluster of related categories
aggregation
object
aggregation of the category
top_categories
object
the most mentioned related categories
top categories displayed with the number of businesses in each category
top_countries
object
the most mentioned counties
country codes with the biggest number of businesses in the category
websites_count
integer
number of unique websites
count
integer
number of unique entities
top_attributes
object
the most mentioned service details
service details of a business entity displayed in a form of checks and the number of entities mentioning each attribute
top_place_topics
object
top keywords mentioned in customer reviews
contains most popular keywords related to products/services mentioned in customer reviews of a business entity and the number of reviews mentioning each keyword