Generate audiences
curl --request POST \
--url https://api.globalwebindex.com/v2/spark-api/audiences/generate \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"audiences": [
"Gen Z"
],
"location_codes": [
"s2_44"
],
"wave_codes": [
"q1_2025"
]
}
'import requests
url = "https://api.globalwebindex.com/v2/spark-api/audiences/generate"
payload = {
"audiences": ["Gen Z"],
"location_codes": ["s2_44"],
"wave_codes": ["q1_2025"]
}
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({audiences: ['Gen Z'], location_codes: ['s2_44'], wave_codes: ['q1_2025']})
};
fetch('https://api.globalwebindex.com/v2/spark-api/audiences/generate', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.globalwebindex.com/v2/spark-api/audiences/generate",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'audiences' => [
'Gen Z'
],
'location_codes' => [
's2_44'
],
'wave_codes' => [
'q1_2025'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.globalwebindex.com/v2/spark-api/audiences/generate"
payload := strings.NewReader("{\n \"audiences\": [\n \"Gen Z\"\n ],\n \"location_codes\": [\n \"s2_44\"\n ],\n \"wave_codes\": [\n \"q1_2025\"\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.globalwebindex.com/v2/spark-api/audiences/generate")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"audiences\": [\n \"Gen Z\"\n ],\n \"location_codes\": [\n \"s2_44\"\n ],\n \"wave_codes\": [\n \"q1_2025\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.globalwebindex.com/v2/spark-api/audiences/generate")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"audiences\": [\n \"Gen Z\"\n ],\n \"location_codes\": [\n \"s2_44\"\n ],\n \"wave_codes\": [\n \"q1_2025\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"audiences": [
{
"id": "259f6394-436c-4801-b83b-bbc926e8b4b9",
"name": "Generation: Gen Z",
"description": "This audience consists of individuals who are part of Gen Z.",
"is_simulated": false,
"datasets": [
"ds-core"
]
}
]
}{
"type": "https://api.globalwebindex.com/docs/spark-api/problems/invalid-request",
"title": "Invalid request",
"status": 400,
"detail": "invalid JSON body: unexpected end of JSON input",
"instance": "/v2/spark-api/audiences/search"
}{
"message": "Unauthorized"
}{
"type": "https://api.globalwebindex.com/docs/spark-api/problems/access-denied",
"title": "Access denied",
"status": 403,
"detail": "dataset access denied",
"instance": "/v2/spark-api/global-filters"
}{
"message": "Request Entity Too Large"
}{
"type": "https://api.globalwebindex.com/docs/spark-api/problems/invalid-params",
"title": "Invalid parameters",
"status": 422,
"detail": "could not validate input: prompt should be a non empty string",
"instance": "/v2/spark-api/global-filters"
}{
"type": "https://api.globalwebindex.com/docs/spark-api/problems/internal",
"title": "Internal server error",
"status": 500,
"detail": "There was an error processing your request. Please try again later.",
"instance": "/v2/spark-api/insights/generate"
}{
"type": "https://api.globalwebindex.com/docs/spark-api/problems/timeout",
"title": "Request timeout",
"status": 504,
"detail": "service is taking longer than usual to respond: please try again in a few moments",
"instance": "/v2/spark-api/insights/generate"
}Audiences
Generate audiences
Creates or matches audiences from natural-language descriptions. Reuse the returned audiences[].id values in later requests instead of generating the same audience again, so that results stay consistent.
POST
/
v2
/
spark-api
/
audiences
/
generate
Generate audiences
curl --request POST \
--url https://api.globalwebindex.com/v2/spark-api/audiences/generate \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"audiences": [
"Gen Z"
],
"location_codes": [
"s2_44"
],
"wave_codes": [
"q1_2025"
]
}
'import requests
url = "https://api.globalwebindex.com/v2/spark-api/audiences/generate"
payload = {
"audiences": ["Gen Z"],
"location_codes": ["s2_44"],
"wave_codes": ["q1_2025"]
}
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({audiences: ['Gen Z'], location_codes: ['s2_44'], wave_codes: ['q1_2025']})
};
fetch('https://api.globalwebindex.com/v2/spark-api/audiences/generate', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.globalwebindex.com/v2/spark-api/audiences/generate",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'audiences' => [
'Gen Z'
],
'location_codes' => [
's2_44'
],
'wave_codes' => [
'q1_2025'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.globalwebindex.com/v2/spark-api/audiences/generate"
payload := strings.NewReader("{\n \"audiences\": [\n \"Gen Z\"\n ],\n \"location_codes\": [\n \"s2_44\"\n ],\n \"wave_codes\": [\n \"q1_2025\"\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.globalwebindex.com/v2/spark-api/audiences/generate")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"audiences\": [\n \"Gen Z\"\n ],\n \"location_codes\": [\n \"s2_44\"\n ],\n \"wave_codes\": [\n \"q1_2025\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.globalwebindex.com/v2/spark-api/audiences/generate")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"audiences\": [\n \"Gen Z\"\n ],\n \"location_codes\": [\n \"s2_44\"\n ],\n \"wave_codes\": [\n \"q1_2025\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"audiences": [
{
"id": "259f6394-436c-4801-b83b-bbc926e8b4b9",
"name": "Generation: Gen Z",
"description": "This audience consists of individuals who are part of Gen Z.",
"is_simulated": false,
"datasets": [
"ds-core"
]
}
]
}{
"type": "https://api.globalwebindex.com/docs/spark-api/problems/invalid-request",
"title": "Invalid request",
"status": 400,
"detail": "invalid JSON body: unexpected end of JSON input",
"instance": "/v2/spark-api/audiences/search"
}{
"message": "Unauthorized"
}{
"type": "https://api.globalwebindex.com/docs/spark-api/problems/access-denied",
"title": "Access denied",
"status": 403,
"detail": "dataset access denied",
"instance": "/v2/spark-api/global-filters"
}{
"message": "Request Entity Too Large"
}{
"type": "https://api.globalwebindex.com/docs/spark-api/problems/invalid-params",
"title": "Invalid parameters",
"status": 422,
"detail": "could not validate input: prompt should be a non empty string",
"instance": "/v2/spark-api/global-filters"
}{
"type": "https://api.globalwebindex.com/docs/spark-api/problems/internal",
"title": "Internal server error",
"status": 500,
"detail": "There was an error processing your request. Please try again later.",
"instance": "/v2/spark-api/insights/generate"
}{
"type": "https://api.globalwebindex.com/docs/spark-api/problems/timeout",
"title": "Request timeout",
"status": 504,
"detail": "service is taking longer than usual to respond: please try again in a few moments",
"instance": "/v2/spark-api/insights/generate"
}Body
application/json
Was this page helpful?

