GET/ product-segments/
List all product segments
You can return a list with all of your products’ segments. Use a returned URL to list all products added to the segment.
Results are paginated: follow next to get the next page (see Response pagination).
Request
- cURL
- JavaScript
- PHP
- Python
curl -X GET "https://<your_app_subdomain>.user.com/api/public/product-segments/" \
-H "Authorization: Token <your_64_char_api_key>" \
-H "Accept: */*; version=2"
const response = await fetch(
"https://<your_app_subdomain>.user.com/api/public/product-segments/",
{
method: "GET",
headers: {
Authorization: "Token <your_64_char_api_key>",
Accept: "*/*; version=2",
},
},
);
const data = await response.json();
console.log(data);
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://<your_app_subdomain>.user.com/api/public/product-segments/",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Token <your_64_char_api_key>",
"Accept: */*; version=2",
],
]);
$response = curl_exec($curl);
curl_close($curl);
echo $response;
import requests
response = requests.get(
"https://<your_app_subdomain>.user.com/api/public/product-segments/",
headers={
"Authorization": "Token <your_64_char_api_key>",
"Accept": "*/*; version=2",
},
)
print(response.json())
Response examples
- 200 OK
{"previous": null,"results": [{"name": "New","description": "Products added less than 7 days ago.","products": "https://<your_app_subdomain>.user.com/api/public/product-segments/1038/products/","id": 1038,"object_count": 100,"too_heavy": false,"update_interval": 240,"last_counted": "2024-10-11T10:12:32.661576Z","updated_at": "2024-10-11T10:12:32.661848Z"},{"name": "Top selling","description": "Products with more than 1000 product events.","products": "https://<your_app_subdomain>.user.com/api/public/product-segments/1039/products/","id": 1039,"object_count": 100,"too_heavy": false,"update_interval": 240,"last_counted": "2024-10-11T10:12:32.661576Z","updated_at": "2024-10-11T10:12:32.661848Z"}],"next": null,"count": 2}Response fields
Fields returned in the 200 OK response body.
- count
- Number of results across all pages. It can lag behind recent changes; see Response pagination.
- next
- URL of the next page of results. null on the last page.
- previous
- URL of the previous page of results. null on the first page.
- results
- Results on this page.
- results[].
id - ID of the segment.
- results[].
name - Name of the segment.
- results[].
description - Description of the segment; an empty string if it has none.
- results[].
products - A list of products' ids.
- results[].
object_count - Number of records in the segment at its last count.
- results[].
too_heavy trueif the last recount took too long and was stopped;object_countandlast_countedare then from the count before.- results[].
update_interval - How often the segment is recounted, in minutes:
30,60,120,240(default),1440,10080or43200. - results[].
last_counted - When the segment was last counted, ISO 8601.
- results[].
updated_at - When the segment was last saved, recounts included, ISO 8601.
- results[].
note
Errors that can come from any endpoint (401, 429, 500, 502, 504) are described in HTTP response codes.