curl --request POST \
--url https://api.globalwebindex.com/v1/spark-api/generic \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"prompt": "What is the average age of social media users in Greece who access these platforms daily?"
}
'import requests
url = "https://api.globalwebindex.com/v1/spark-api/generic"
payload = { "prompt": "What is the average age of social media users in Greece who access these platforms daily?" }
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({
prompt: 'What is the average age of social media users in Greece who access these platforms daily?'
})
};
fetch('https://api.globalwebindex.com/v1/spark-api/generic', 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/v1/spark-api/generic",
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([
'prompt' => 'What is the average age of social media users in Greece who access these platforms daily?'
]),
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/v1/spark-api/generic"
payload := strings.NewReader("{\n \"prompt\": \"What is the average age of social media users in Greece who access these platforms daily?\"\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/v1/spark-api/generic")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"prompt\": \"What is the average age of social media users in Greece who access these platforms daily?\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.globalwebindex.com/v1/spark-api/generic")
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 \"prompt\": \"What is the average age of social media users in Greece who access these platforms daily?\"\n}"
response = http.request(request)
puts response.read_body{
"message": "Based on your input, here are some interesting Insights:",
"insights": [
{
"id": "75f1f21a-9157-412e-bdcf-d6af93a4f4dc",
"text": "30% of social media users in Greece who spend 3 or more hours daily on these platforms are part of Gen Z."
},
{
"id": "02e9c8a5-d42f-4a6d-b7d8-c238f2208d44",
"text": "24% of this audience falls within the age range of 16 to 24 years old."
}
],
"chat_id": "9b1507d7-16d5-4f26-8d64-69d34e23e9f0",
"sources": {
"topics": [
"Facebook usage"
],
"audiences": [
{
"id": "c95451a1-b936-42a3-9a1c-13b5b43c20a6",
"name": "Heavy social networkers",
"description": "Individuals who spend between 3 and more than 10 hours on social media on an average day."
}
],
"datasets": [
{
"code": "ds-core",
"name": "GWI Core"
}
],
"locations": [
{
"code": "s2_30",
"name": "Greece"
}
],
"waves": [
{
"code": "q3_2024",
"name": "Q3 2024"
},
{
"code": "q4_2024",
"name": "Q4 2024"
}
]
}
}{
"code": 400,
"message": "Bad request reason"
}{
"message": "Unauthorized"
}{
"code": 404,
"message": "Not found reason"
}{
"code": 422,
"message": "Unprocessable entity reason"
}{
"code": 500,
"message": "There was an error processing your request. Please try again later."
}Chat with the service
Endpoint to chat with the service using a prompt and chat ID.
curl --request POST \
--url https://api.globalwebindex.com/v1/spark-api/generic \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"prompt": "What is the average age of social media users in Greece who access these platforms daily?"
}
'import requests
url = "https://api.globalwebindex.com/v1/spark-api/generic"
payload = { "prompt": "What is the average age of social media users in Greece who access these platforms daily?" }
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({
prompt: 'What is the average age of social media users in Greece who access these platforms daily?'
})
};
fetch('https://api.globalwebindex.com/v1/spark-api/generic', 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/v1/spark-api/generic",
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([
'prompt' => 'What is the average age of social media users in Greece who access these platforms daily?'
]),
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/v1/spark-api/generic"
payload := strings.NewReader("{\n \"prompt\": \"What is the average age of social media users in Greece who access these platforms daily?\"\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/v1/spark-api/generic")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"prompt\": \"What is the average age of social media users in Greece who access these platforms daily?\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.globalwebindex.com/v1/spark-api/generic")
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 \"prompt\": \"What is the average age of social media users in Greece who access these platforms daily?\"\n}"
response = http.request(request)
puts response.read_body{
"message": "Based on your input, here are some interesting Insights:",
"insights": [
{
"id": "75f1f21a-9157-412e-bdcf-d6af93a4f4dc",
"text": "30% of social media users in Greece who spend 3 or more hours daily on these platforms are part of Gen Z."
},
{
"id": "02e9c8a5-d42f-4a6d-b7d8-c238f2208d44",
"text": "24% of this audience falls within the age range of 16 to 24 years old."
}
],
"chat_id": "9b1507d7-16d5-4f26-8d64-69d34e23e9f0",
"sources": {
"topics": [
"Facebook usage"
],
"audiences": [
{
"id": "c95451a1-b936-42a3-9a1c-13b5b43c20a6",
"name": "Heavy social networkers",
"description": "Individuals who spend between 3 and more than 10 hours on social media on an average day."
}
],
"datasets": [
{
"code": "ds-core",
"name": "GWI Core"
}
],
"locations": [
{
"code": "s2_30",
"name": "Greece"
}
],
"waves": [
{
"code": "q3_2024",
"name": "Q3 2024"
},
{
"code": "q4_2024",
"name": "Q4 2024"
}
]
}
}{
"code": 400,
"message": "Bad request reason"
}{
"message": "Unauthorized"
}{
"code": 404,
"message": "Not found reason"
}{
"code": 422,
"message": "Unprocessable entity reason"
}{
"code": 500,
"message": "There was an error processing your request. Please try again later."
}Authorizations
Body
Chat request payload.
Request payload for chat.
The chat prompt.
The chat session ID (assigned at 1st prompt).
""
Root dataset code used to scope the chat. Ignored when dataset_codes is provided.
"ds-core"
Dataset codes that must belong to the same dataset tree (root + children). Takes precedence over dataset_code when both are provided.
["ds-core", "ds-work"]
The audiences ids (UUIDs) to dock and produce insights for. These audiences are created via GWI platform and need to be shared within the organization. The list can be found using /v2/saved/audiences.
[
"00000000-0000-0000-0000-000000000000",
"00000000-0000-0000-0000-000000000001"
]
Optional. Maximum number of insights to return per query (1-20). Fewer insights may be returned when data cannot support more.
1 <= x <= 208
Response
Successful response
Was this page helpful?

