Generate insights
curl --request POST \
--url https://api.globalwebindex.com/v2/spark-api/insights/generate \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"prompts": [
"electric car ownership"
],
"enforced_audiences": [
"259f6394-436c-4801-b83b-bbc926e8b4b9"
],
"location_codes": [
"s2_44"
],
"wave_codes": [
"q1_2025"
]
}
'import requests
url = "https://api.globalwebindex.com/v2/spark-api/insights/generate"
payload = {
"prompts": ["electric car ownership"],
"enforced_audiences": ["259f6394-436c-4801-b83b-bbc926e8b4b9"],
"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({
prompts: ['electric car ownership'],
enforced_audiences: ['259f6394-436c-4801-b83b-bbc926e8b4b9'],
location_codes: ['s2_44'],
wave_codes: ['q1_2025']
})
};
fetch('https://api.globalwebindex.com/v2/spark-api/insights/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/insights/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([
'prompts' => [
'electric car ownership'
],
'enforced_audiences' => [
'259f6394-436c-4801-b83b-bbc926e8b4b9'
],
'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/insights/generate"
payload := strings.NewReader("{\n \"prompts\": [\n \"electric car ownership\"\n ],\n \"enforced_audiences\": [\n \"259f6394-436c-4801-b83b-bbc926e8b4b9\"\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/insights/generate")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"prompts\": [\n \"electric car ownership\"\n ],\n \"enforced_audiences\": [\n \"259f6394-436c-4801-b83b-bbc926e8b4b9\"\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/insights/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 \"prompts\": [\n \"electric car ownership\"\n ],\n \"enforced_audiences\": [\n \"259f6394-436c-4801-b83b-bbc926e8b4b9\"\n ],\n \"location_codes\": [\n \"s2_44\"\n ],\n \"wave_codes\": [\n \"q1_2025\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"results": [
{
"state_id": "39890c03-c088-44ba-a452-9171aa07b96a",
"prompt": "electric car ownership",
"message": "Based on the prompt electric car ownership, the Insights tool generated the following insights:",
"has_more_insights": true,
"inaccessible_locations": [],
"insights": [
{
"id": "381d7b8b-d657-47c6-983f-8e64f7b2847e",
"text": "16% of Gen Z car owners and future purchasers say an electric vehicle enhances their style and status, making them 167% more likely to cite this advantage than the average car owner or future purchaser.",
"is_simulated": false
},
{
"id": "73d4cccf-ce6a-4a25-975a-a7a19c8ec3c1",
"text": "11% of Gen Z car owners and future purchasers value an electric vehicle’s efficient use of space, making them 140% more likely to cite it than the average car owner or future purchaser.",
"is_simulated": false
},
{
"id": "45cc5f21-9aa9-41ca-a61f-250c87b4162f",
"text": "18% of Gen Z car owners and future purchasers cite performance and handling as an electric vehicle’s main advantage, making them 102% more likely to do so than the average car owner or future purchaser.",
"is_simulated": false
}
],
"origins": {
"audiences": [
{
"description": "This audience consists of individuals who are part of Gen Z.",
"id": "259f6394-436c-4801-b83b-bbc926e8b4b9",
"is_simulated": false,
"name": "Generation: Gen Z"
}
],
"datasets": [
{
"code": "ds-core",
"is_simulated": false,
"name": "GWI Core"
},
{
"code": "ds-gwi-automotive",
"is_simulated": false,
"name": "GWI Automotive"
}
],
"locations": [
{
"code": "s2_44",
"name": "UK"
}
],
"topics": [
"electric car ownership"
],
"waves": [
{
"code": "q1_2025",
"name": "Q1 2025"
}
]
}
}
]
}{
"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"
}Insights
Generate insights
Generates insights for up to ten prompts and returns one result per prompt, in request order. A failure for an individual prompt is reported in that result (error and message) rather than as an HTTP error. insights[].url is included when your account has access to insight links on the GWI platform.
POST
/
v2
/
spark-api
/
insights
/
generate
Generate insights
curl --request POST \
--url https://api.globalwebindex.com/v2/spark-api/insights/generate \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"prompts": [
"electric car ownership"
],
"enforced_audiences": [
"259f6394-436c-4801-b83b-bbc926e8b4b9"
],
"location_codes": [
"s2_44"
],
"wave_codes": [
"q1_2025"
]
}
'import requests
url = "https://api.globalwebindex.com/v2/spark-api/insights/generate"
payload = {
"prompts": ["electric car ownership"],
"enforced_audiences": ["259f6394-436c-4801-b83b-bbc926e8b4b9"],
"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({
prompts: ['electric car ownership'],
enforced_audiences: ['259f6394-436c-4801-b83b-bbc926e8b4b9'],
location_codes: ['s2_44'],
wave_codes: ['q1_2025']
})
};
fetch('https://api.globalwebindex.com/v2/spark-api/insights/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/insights/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([
'prompts' => [
'electric car ownership'
],
'enforced_audiences' => [
'259f6394-436c-4801-b83b-bbc926e8b4b9'
],
'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/insights/generate"
payload := strings.NewReader("{\n \"prompts\": [\n \"electric car ownership\"\n ],\n \"enforced_audiences\": [\n \"259f6394-436c-4801-b83b-bbc926e8b4b9\"\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/insights/generate")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"prompts\": [\n \"electric car ownership\"\n ],\n \"enforced_audiences\": [\n \"259f6394-436c-4801-b83b-bbc926e8b4b9\"\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/insights/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 \"prompts\": [\n \"electric car ownership\"\n ],\n \"enforced_audiences\": [\n \"259f6394-436c-4801-b83b-bbc926e8b4b9\"\n ],\n \"location_codes\": [\n \"s2_44\"\n ],\n \"wave_codes\": [\n \"q1_2025\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"results": [
{
"state_id": "39890c03-c088-44ba-a452-9171aa07b96a",
"prompt": "electric car ownership",
"message": "Based on the prompt electric car ownership, the Insights tool generated the following insights:",
"has_more_insights": true,
"inaccessible_locations": [],
"insights": [
{
"id": "381d7b8b-d657-47c6-983f-8e64f7b2847e",
"text": "16% of Gen Z car owners and future purchasers say an electric vehicle enhances their style and status, making them 167% more likely to cite this advantage than the average car owner or future purchaser.",
"is_simulated": false
},
{
"id": "73d4cccf-ce6a-4a25-975a-a7a19c8ec3c1",
"text": "11% of Gen Z car owners and future purchasers value an electric vehicle’s efficient use of space, making them 140% more likely to cite it than the average car owner or future purchaser.",
"is_simulated": false
},
{
"id": "45cc5f21-9aa9-41ca-a61f-250c87b4162f",
"text": "18% of Gen Z car owners and future purchasers cite performance and handling as an electric vehicle’s main advantage, making them 102% more likely to do so than the average car owner or future purchaser.",
"is_simulated": false
}
],
"origins": {
"audiences": [
{
"description": "This audience consists of individuals who are part of Gen Z.",
"id": "259f6394-436c-4801-b83b-bbc926e8b4b9",
"is_simulated": false,
"name": "Generation: Gen Z"
}
],
"datasets": [
{
"code": "ds-core",
"is_simulated": false,
"name": "GWI Core"
},
{
"code": "ds-gwi-automotive",
"is_simulated": false,
"name": "GWI Automotive"
}
],
"locations": [
{
"code": "s2_44",
"name": "UK"
}
],
"topics": [
"electric car ownership"
],
"waves": [
{
"code": "q1_2025",
"name": "Q1 2025"
}
]
}
}
]
}{
"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?

