Skip to main content
POST
/
v2
/
query
/
intersection
v2 Crosstab Cell Query
curl --request POST \
  --url https://api.globalwebindex.com/v2/query/intersection \
  --header 'Authorization: <api-key>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "audiences": {
    "row": {
      "id": "133",
      "name": "my_audience",
      "expression": {
        "and": [
          {
            "question": "q2",
            "datapoints": [
              "q2_1",
              "q2_2"
            ],
            "min_count": 1,
            "not": false
          },
          {
            "question": "q6",
            "datapoints": [
              "q6_2"
            ],
            "min_count": 1,
            "not": false
          }
        ]
      }
    },
    "column": {
      "id": "134",
      "name": "my_audience",
      "expression": {
        "and": [
          {
            "question": "q2",
            "datapoints": [
              "q2_1",
              "q2_2"
            ],
            "min_count": 1,
            "not": false
          },
          {
            "question": "q6",
            "datapoints": [
              "q6_2"
            ],
            "min_count": 1,
            "not": false
          }
        ]
      }
    }
  },
  "locations": [
    "s2_1",
    "s2_44"
  ],
  "waves": [
    "q1_2019",
    "q2_2019",
    "q3_2019",
    "q4_2019"
  ],
  "base_audience": {
    "id": "135",
    "name": "my_audience",
    "expression": {
      "and": [
        {
          "question": "q2",
          "datapoints": [
            "q2_1",
            "q2_2"
          ],
          "min_count": 1,
          "not": false
        },
        {
          "question": "q6",
          "datapoints": [
            "q6_2"
          ],
          "min_count": 1,
          "not": false
        }
      ]
    }
  }
}
'
import requests

url = "https://api.globalwebindex.com/v2/query/intersection"

payload = {
"audiences": {
"row": {
"id": "133",
"name": "my_audience",
"expression": { "and": [
{
"question": "q2",
"datapoints": ["q2_1", "q2_2"],
"min_count": 1,
"not": False
},
{
"question": "q6",
"datapoints": ["q6_2"],
"min_count": 1,
"not": False
}
] }
},
"column": {
"id": "134",
"name": "my_audience",
"expression": { "and": [
{
"question": "q2",
"datapoints": ["q2_1", "q2_2"],
"min_count": 1,
"not": False
},
{
"question": "q6",
"datapoints": ["q6_2"],
"min_count": 1,
"not": False
}
] }
}
},
"locations": ["s2_1", "s2_44"],
"waves": ["q1_2019", "q2_2019", "q3_2019", "q4_2019"],
"base_audience": {
"id": "135",
"name": "my_audience",
"expression": { "and": [
{
"question": "q2",
"datapoints": ["q2_1", "q2_2"],
"min_count": 1,
"not": False
},
{
"question": "q6",
"datapoints": ["q6_2"],
"min_count": 1,
"not": False
}
] }
}
}
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: {
row: {
id: '133',
name: 'my_audience',
expression: {
and: [
{question: 'q2', datapoints: ['q2_1', 'q2_2'], min_count: 1, not: false},
{question: 'q6', datapoints: ['q6_2'], min_count: 1, not: false}
]
}
},
column: {
id: '134',
name: 'my_audience',
expression: {
and: [
{question: 'q2', datapoints: ['q2_1', 'q2_2'], min_count: 1, not: false},
{question: 'q6', datapoints: ['q6_2'], min_count: 1, not: false}
]
}
}
},
locations: ['s2_1', 's2_44'],
waves: ['q1_2019', 'q2_2019', 'q3_2019', 'q4_2019'],
base_audience: {
id: '135',
name: 'my_audience',
expression: {
and: [
{question: 'q2', datapoints: ['q2_1', 'q2_2'], min_count: 1, not: false},
{question: 'q6', datapoints: ['q6_2'], min_count: 1, not: false}
]
}
}
})
};

fetch('https://api.globalwebindex.com/v2/query/intersection', 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/query/intersection",
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' => [
'row' => [
'id' => '133',
'name' => 'my_audience',
'expression' => [
'and' => [
[
'question' => 'q2',
'datapoints' => [
'q2_1',
'q2_2'
],
'min_count' => 1,
'not' => false
],
[
'question' => 'q6',
'datapoints' => [
'q6_2'
],
'min_count' => 1,
'not' => false
]
]
]
],
'column' => [
'id' => '134',
'name' => 'my_audience',
'expression' => [
'and' => [
[
'question' => 'q2',
'datapoints' => [
'q2_1',
'q2_2'
],
'min_count' => 1,
'not' => false
],
[
'question' => 'q6',
'datapoints' => [
'q6_2'
],
'min_count' => 1,
'not' => false
]
]
]
]
],
'locations' => [
's2_1',
's2_44'
],
'waves' => [
'q1_2019',
'q2_2019',
'q3_2019',
'q4_2019'
],
'base_audience' => [
'id' => '135',
'name' => 'my_audience',
'expression' => [
'and' => [
[
'question' => 'q2',
'datapoints' => [
'q2_1',
'q2_2'
],
'min_count' => 1,
'not' => false
],
[
'question' => 'q6',
'datapoints' => [
'q6_2'
],
'min_count' => 1,
'not' => false
]
]
]
]
]),
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/query/intersection"

payload := strings.NewReader("{\n \"audiences\": {\n \"row\": {\n \"id\": \"133\",\n \"name\": \"my_audience\",\n \"expression\": {\n \"and\": [\n {\n \"question\": \"q2\",\n \"datapoints\": [\n \"q2_1\",\n \"q2_2\"\n ],\n \"min_count\": 1,\n \"not\": false\n },\n {\n \"question\": \"q6\",\n \"datapoints\": [\n \"q6_2\"\n ],\n \"min_count\": 1,\n \"not\": false\n }\n ]\n }\n },\n \"column\": {\n \"id\": \"134\",\n \"name\": \"my_audience\",\n \"expression\": {\n \"and\": [\n {\n \"question\": \"q2\",\n \"datapoints\": [\n \"q2_1\",\n \"q2_2\"\n ],\n \"min_count\": 1,\n \"not\": false\n },\n {\n \"question\": \"q6\",\n \"datapoints\": [\n \"q6_2\"\n ],\n \"min_count\": 1,\n \"not\": false\n }\n ]\n }\n }\n },\n \"locations\": [\n \"s2_1\",\n \"s2_44\"\n ],\n \"waves\": [\n \"q1_2019\",\n \"q2_2019\",\n \"q3_2019\",\n \"q4_2019\"\n ],\n \"base_audience\": {\n \"id\": \"135\",\n \"name\": \"my_audience\",\n \"expression\": {\n \"and\": [\n {\n \"question\": \"q2\",\n \"datapoints\": [\n \"q2_1\",\n \"q2_2\"\n ],\n \"min_count\": 1,\n \"not\": false\n },\n {\n \"question\": \"q6\",\n \"datapoints\": [\n \"q6_2\"\n ],\n \"min_count\": 1,\n \"not\": false\n }\n ]\n }\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/query/intersection")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"audiences\": {\n \"row\": {\n \"id\": \"133\",\n \"name\": \"my_audience\",\n \"expression\": {\n \"and\": [\n {\n \"question\": \"q2\",\n \"datapoints\": [\n \"q2_1\",\n \"q2_2\"\n ],\n \"min_count\": 1,\n \"not\": false\n },\n {\n \"question\": \"q6\",\n \"datapoints\": [\n \"q6_2\"\n ],\n \"min_count\": 1,\n \"not\": false\n }\n ]\n }\n },\n \"column\": {\n \"id\": \"134\",\n \"name\": \"my_audience\",\n \"expression\": {\n \"and\": [\n {\n \"question\": \"q2\",\n \"datapoints\": [\n \"q2_1\",\n \"q2_2\"\n ],\n \"min_count\": 1,\n \"not\": false\n },\n {\n \"question\": \"q6\",\n \"datapoints\": [\n \"q6_2\"\n ],\n \"min_count\": 1,\n \"not\": false\n }\n ]\n }\n }\n },\n \"locations\": [\n \"s2_1\",\n \"s2_44\"\n ],\n \"waves\": [\n \"q1_2019\",\n \"q2_2019\",\n \"q3_2019\",\n \"q4_2019\"\n ],\n \"base_audience\": {\n \"id\": \"135\",\n \"name\": \"my_audience\",\n \"expression\": {\n \"and\": [\n {\n \"question\": \"q2\",\n \"datapoints\": [\n \"q2_1\",\n \"q2_2\"\n ],\n \"min_count\": 1,\n \"not\": false\n },\n {\n \"question\": \"q6\",\n \"datapoints\": [\n \"q6_2\"\n ],\n \"min_count\": 1,\n \"not\": false\n }\n ]\n }\n }\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.globalwebindex.com/v2/query/intersection")

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 \"row\": {\n \"id\": \"133\",\n \"name\": \"my_audience\",\n \"expression\": {\n \"and\": [\n {\n \"question\": \"q2\",\n \"datapoints\": [\n \"q2_1\",\n \"q2_2\"\n ],\n \"min_count\": 1,\n \"not\": false\n },\n {\n \"question\": \"q6\",\n \"datapoints\": [\n \"q6_2\"\n ],\n \"min_count\": 1,\n \"not\": false\n }\n ]\n }\n },\n \"column\": {\n \"id\": \"134\",\n \"name\": \"my_audience\",\n \"expression\": {\n \"and\": [\n {\n \"question\": \"q2\",\n \"datapoints\": [\n \"q2_1\",\n \"q2_2\"\n ],\n \"min_count\": 1,\n \"not\": false\n },\n {\n \"question\": \"q6\",\n \"datapoints\": [\n \"q6_2\"\n ],\n \"min_count\": 1,\n \"not\": false\n }\n ]\n }\n }\n },\n \"locations\": [\n \"s2_1\",\n \"s2_44\"\n ],\n \"waves\": [\n \"q1_2019\",\n \"q2_2019\",\n \"q3_2019\",\n \"q4_2019\"\n ],\n \"base_audience\": {\n \"id\": \"135\",\n \"name\": \"my_audience\",\n \"expression\": {\n \"and\": [\n {\n \"question\": \"q2\",\n \"datapoints\": [\n \"q2_1\",\n \"q2_2\"\n ],\n \"min_count\": 1,\n \"not\": false\n },\n {\n \"question\": \"q6\",\n \"datapoints\": [\n \"q6_2\"\n ],\n \"min_count\": 1,\n \"not\": false\n }\n ]\n }\n }\n}"

response = http.request(request)
puts response.read_body
{
  "meta": {
    "type": "INTERSECTION"
  },
  "data": {
    "audiences": {
      "row": {
        "audience": "<string>",
        "size": 123,
        "sample": 123,
        "percentage": 123,
        "intersect_percentage": 123
      },
      "column": {
        "audience": "<string>",
        "size": 123,
        "sample": 123,
        "percentage": 123,
        "intersect_percentage": 123
      }
    },
    "base": {
      "size": 123,
      "sample": 123
    },
    "intersect": {
      "size": 123,
      "sample": 123,
      "percentage": 123,
      "index": 123
    }
  }
}

Authorizations

Authorization
string
header
required

Body

application/json

Crosstab builder query.

Audiences and filters as parameters for Crosstab Builder metrics.

audiences
object
required

Object of row and column audiences to make intersection from. If only one audience is queried then the base audience is taken as the second audience. If none audience is queried then base audience is taken for both row and column audiences.

locations
string[]

List of location codes to filter.

Example:
["s2_1", "s2_44"]
waves
string[]

List of wave codes to filter.

Example:
["q1_2019", "q2_2019", "q3_2019", "q4_2019"]
base_audience
Audience · object

Wrapper structure containing AudienceExpression.

Response

Correct results for given query.

Result of crosstab builder query.

meta
AudiencesIntersectionQueryResultsMetadata · object
required

Metadata for crosstab builder query result

data
QueryResultsData · object
required

Collection of results of crosstab builder query.