In this document, commands of version 1.0 of Gem API
are presented. The main command is the /v1/stats command,
which allows retrieving data from
the Gemius Audience study. Other commands:
are used for retrieving metadata,
which are used as parameters to the
/v1/stats command.
Data can be retrieved in json
or
csv with TAB as a columns separator
format.
/v1/open-session
Opens REST Gem API session.
Allowed methods:
Parameters:
- login - user's login
- password - user's password
-
[output] - output data format.
Optional. Errors are always reported in json format.
Possible values:
- json - rich JSON output
- csv - simple CSV output
Outputs
json
Json dictionary with fields:
- api_version - version of Gem API
- data - json dictionary with one field: session containing session key
csv
Csv file with one column and sinlge row for session key.
Examples
json
/v1/open-session?output=json
POST parameters: login="LOGIN", password="PASS".
{
"api_version": 1,
"data": {
"session": "1234567890xxxxxxxxxxxxxxxxxxxxxx"
}
}
csv
/v1/open-session?output=csv
POST parameters: login="LOGIN", password="PASS".
session
269d9108eff79edc725d7930658d785f
/v1/available-periods
List data periods available for user.
Allowed methods:
Parameters:
- session - user's session key obtained by /v1/open-session command
-
[output] - output data format.
Optional. Errors are always reported in json format.
Possible values:
- json - rich JSON output
- csv - simple CSV output
- [country] - ISO 3166-1 alfa-2 country code. Optional if user has access only to one market.
-
[period_type] - period granularity, ie daily, weekly, monthly or other.
Optional. If it is not passed, then data is returned for all period granularities.
Outputs
json
Json dictionary with fields:
- api_version - version of Gem API
-
data - json dictionary with mapping from ISO 3166-1 alfa-2 country code to json dictionary.
Each dictionary contains mapping from period granularity to json list of available periods,
for given country and period granularity. Each period is described by a json object with two fields:
- begin - date in ISO 8601 format, ‘YYYY-MM-DD’ for the begining of period,
- end - date in ISO 8601 format, ‘YYYY-MM-DD’ for the end of period.
csv
Csv file with one row for each available period.
Output has columns: begin, country,
end and period type, which meanings
correspond to the json output fields in data part.
/v1/geos
List all posible geolocations in selected period.
Allowed methods:
Parameters:
- session - user's session key obtained by /v1/open-session command
-
[output] - output data format.
Optional. Errors are always reported in json format.
Possible values:
- json - rich JSON output
- csv - simple CSV output
- [country] - ISO 3166-1 alfa-2 country code. Optional if user has access only to one market.
-
[begin] - date in ISO 8601 format, ‘YYYY-MM-DD’ for the begining of period.
Optional. If it is not passed, then data is returned for newest, available to user, daily period.
-
[end] - date in ISO 8601 format, ‘YYYY-MM-DD’ for the end of period.
Optional. If it is not passed, then data is returned for newest, available to user, daily period.
Outputs
json
Json dictionary with fields:
- api_version - version of Gem API
-
source - json object with parameters describing source of data.
Contains fields:
- country - ISO 3166-1 alfa-2 country code.
- [begin] - date in ISO 8601 format, ‘YYYY-MM-DD’ for the begining of period.
- [end] - date in ISO 8601 format, ‘YYYY-MM-DD’ for the end of period.
-
data - json list containing objects corresponding to geolocations.
Each object contains fields:
- id - geolocation identifier.
- name - geolocation name.
- children - geolocation children. Json list with structure the same as data.
csv
Csv file with one row for each available geolocation.
Output has columns: id, name,
which meanings correspond to the json output
fields in data part.
/v1/platforms
List all posible platforms in selected period.
Allowed methods:
Parameters:
- session - user's session key obtained by /v1/open-session command
-
[output] - output data format.
Optional. Errors are always reported in json format.
Possible values:
- json - rich JSON output
- csv - simple CSV output
- [country] - ISO 3166-1 alfa-2 country code. Optional if user has access only to one market.
-
[begin] - date in ISO 8601 format, ‘YYYY-MM-DD’ for the begining of period.
Optional. If it is not passed, then data is returned for newest, available to user, daily period.
-
[end] - date in ISO 8601 format, ‘YYYY-MM-DD’ for the end of period.
Optional. If it is not passed, then data is returned for newest, available to user, daily period.
/v1/metrics
List all posible metrics in selected period.
Allowed methods:
Parameters:
- session - user's session key obtained by /v1/open-session command
-
[output] - output data format.
Optional. Errors are always reported in json format.
Possible values:
- json - rich JSON output
- csv - simple CSV output
- [country] - ISO 3166-1 alfa-2 country code. Optional if user has access only to one market.
-
[begin] - date in ISO 8601 format, ‘YYYY-MM-DD’ for the begining of period.
Optional. If it is not passed, then data is returned for newest, available to user, daily period.
-
[end] - date in ISO 8601 format, ‘YYYY-MM-DD’ for the end of period.
Optional. If it is not passed, then data is returned for newest, available to user, daily period.
Outputs
json
Json dictionary with fields:
- api_version - version of Gem API
-
source - json object with parameters describing source of data.
Contains fields:
- country - ISO 3166-1 alfa-2 country code.
- [begin] - date in ISO 8601 format, ‘YYYY-MM-DD’ for the begining of period.
- [end] - date in ISO 8601 format, ‘YYYY-MM-DD’ for the end of period.
-
data - json list containing objects corresponding to metrics.
Each object contains fields:
- id - metric identifier.
- name - metric name.
-
type - metric type:
csv
Csv file with one row for each available metric.
Output has columns: id, name,
type,
which meanings correspond to the json output
fields in data part.
Examples
json
/v1/metrics?session=1234567890xxxxxxxxxxxxxxxxxxxxxx&output=json
{
"api_version": 1,
"data": [
{
"id": 7,
"name": "Real users",
"type": "n"
},
{
"id": 8,
"name": "Page views",
"type": "n"
},
{
"id": 9,
"name": "Page views per real user",
"type": "n"
},
{
"id": 11,
"name": "Time [s]",
"type": "n"
},
{
"id": 25,
"name": "Visits",
"type": "n"
},
{
"id": 100,
"name": "Affinity Index-Internet (relative)",
"type": "n"
},
{
"id": 110,
"name": "Reach-Internet",
"type": "n"
}
],
"source": {
"begin": "2017-05-25",
"country": "pl",
"end": "2017-05-26"
}
}
csv
/v1/metrics?session=1234567890xxxxxxxxxxxxxxxxxxxxxx&output=csv
id name type
7 Real users n
8 Page views n
11 Time [s] n
25 Visits n
29 Min audience duplication n
30 Min audience duplication (%) n
31 Max audience duplication n
32 Max audience duplication (%) n
100 Affinity Index-Internet (relative) n
110 Reach-Internet n
/v1/trees
List all posible trees in selected period.
Allowed methods:
Parameters:
- session - user's session key obtained by /v1/open-session command
-
[output] - output data format.
Optional. Errors are always reported in json format.
Possible values:
- json - rich JSON output
- csv - simple CSV output
- [country] - ISO 3166-1 alfa-2 country code. Optional if user has access only to one market.
-
[begin] - date in ISO 8601 format, ‘YYYY-MM-DD’ for the begining of period.
Optional. If it is not passed, then data is returned for newest, available to user, daily period.
-
[end] - date in ISO 8601 format, ‘YYYY-MM-DD’ for the end of period.
Optional. If it is not passed, then data is returned for newest, available to user, daily period.
Outputs
json
Json dictionary with fields:
- api_version - version of Gem API
-
source - json object with parameters describing source of data.
Contains fields:
- country - ISO 3166-1 alfa-2 country code.
- [begin] - date in ISO 8601 format, ‘YYYY-MM-DD’ for the begining of period.
- [end] - date in ISO 8601 format, ‘YYYY-MM-DD’ for the end of period.
-
data - json list containing objects corresponding to trees.
Each object contains fields:
- id - tree identifier.
- name - tree name.
csv
Csv file with one row for each available tree.
Output has columns: id, name
which meanings correspond to the json output
fields in data part.
Examples
json
/v1/trees?session=1234567890xxxxxxxxxxxxxxxxxxxxxx&output=json
{
"api_version": 1,
"data": [
{
"id": "59857",
"name": "Internet"
},
{
"id": "497408.1.497408.1",
"name": "Drzewko funkcjonalne ogólne"
},
{
"id": "497406.1.497406.1",
"name": "Drzewko funkcjonalne szczegółowe"
},
{
"id": "343670.1.343670.1",
"name": "Drzewko sieci"
},
{
"id": "497407.1.497407.1",
"name": "Drzewko tematyczne ogólne"
},
{
"id": "497405.1.497405.1",
"name": "Drzewko tematyczne szczegółowe"
}
],
"source": {
"begin": "2017-07-13",
"country": "pl",
"end": "2017-07-14"
}
}
csv
/v1/trees?session=1234567890xxxxxxxxxxxxxxxxxxxxxx&output=csv
id name
59857 Internet
497408.1.497408.1 Drzewko funkcjonalne ogólne
497406.1.497406.1 Drzewko funkcjonalne szczegółowe
343670.1.343670.1 Drzewko sieci
497407.1.497407.1 Drzewko tematyczne ogólne
497405.1.497405.1 Drzewko tematyczne szczegółowe
/v1/nodes
List all posible nodes in selected period.
Allowed methods:
Parameters:
- session - user's session key obtained by /v1/open-session command
-
[output] - output data format.
Optional. Errors are always reported in json format.
Possible values:
- json - rich JSON output
- csv - simple CSV output
- [country] - ISO 3166-1 alfa-2 country code. Optional if user has access only to one market.
-
[begin] - date in ISO 8601 format, ‘YYYY-MM-DD’ for the begining of period.
Optional. If it is not passed, then data is returned for newest, available to user, daily period.
-
[end] - date in ISO 8601 format, ‘YYYY-MM-DD’ for the end of period.
Optional. If it is not passed, then data is returned for newest, available to user, daily period.
-
[tree] - tree id, from which nodes will be returned
(see /v1/trees).
Optional. If it is not passed, then data is returned for all trees avaiable for given period.
Outputs
json
Json dictionary with fields:
- api_version - version of Gem API
-
source - json object with parameters describing source of data.
Contains fields:
- country - ISO 3166-1 alfa-2 country code.
- [begin] - date in ISO 8601 format, ‘YYYY-MM-DD’ for the begining of period.
- [end] - date in ISO 8601 format, ‘YYYY-MM-DD’ for the end of period.
-
data - json list containing objects corresponding to nodes.
Each object contains fields:
- id - node identifier.
- name - node name.
- audited - flag showing whether node is audited.
-
type - node type:
- k - category
- u - domains group
- w - domain
- s - service
- g - messenger
- p - other application
- c - stream
- m - stream section
- A - stream audio
- N - strem audio section
- V - stream video
- C - stream video section
- T - stream TV
- P - stream TV section
- R - stream radio
- S - stream radio section
- M - mobile node
- a - aggregate
- children - node children. Json list with structure the same as data.
csv
Csv file with one row for each available node.
Output has columns: id, name,
parent_id (id of parent node),
type, audited,
which meanings correspond to the json output
fields in data part.
Examples
json
/v1/nodes?session=1234567890xxxxxxxxxxxxxxxxxxxxxx&output=json
{
"api_version": 1,
"data": [
{
"children": [
{
"children": [
{
"children": [
{
"id": "448744",
"name": "serwis",
"type": "s",
"audited": false
}
],
"id": "59639",
"name": "domena",
"type": "w",
"audited": false
}
],
"id": "59633",
"name": "Grupa",
"type": "u",
"audited": false
}
],
"id": "59857",
"name": "Internet",
"type": "k",
"audited": false
}
],
"source": {
"begin": "2017-05-25",
"country": "pl",
"end": "2017-05-26"
}
}
csv
/v1/nodes?session=1234567890xxxxxxxxxxxxxxxxxxxxxx&output=csv
id name parent_id type audited
59857 Internet k False
59633 Grupa 59857 u False
59639 domena 59633 w False
448744 serwis 59639 s False
/v1/demography
List demography traits in selected period.
Allowed methods:
Parameters:
- session - user's session key obtained by /v1/open-session command
-
[output] - output data format.
Optional. Errors are always reported in json format.
Possible values:
- json - rich JSON output
- csv - simple CSV output
- [country] - ISO 3166-1 alfa-2 country code. Optional if user has access only to one market.
-
[begin] - date in ISO 8601 format, ‘YYYY-MM-DD’ for the begining of period.
Optional. If it is not passed, then data is returned for newest, available to user, daily period.
-
[end] - date in ISO 8601 format, ‘YYYY-MM-DD’ for the end of period.
Optional. If it is not passed, then data is returned for newest, available to user, daily period.
Outputs
json
Json dictionary with fields:
- api_version - version of Gem API
-
source - json object with parameters describing source of data.
Contains fields:
- country - ISO 3166-1 alfa-2 country code.
- [begin] - date in ISO 8601 format, ‘YYYY-MM-DD’ for the begining of period.
- [end] - date in ISO 8601 format, ‘YYYY-MM-DD’ for the end of period.
-
data - json list containing objects corresponding to demography traits.
Each object contains fields:
- id - trait identifier.
- name - trait name.
- continuous - flag showing whether trait is continuous.
-
answers - json list with possible answers.
For continuous traits, list may contain predefinied segments, described by json object
with fields:
- min - left end of segment
- max - right end of segment
Missing value for min or max means that segment is not bounded.
For discreete traits, list contain answers, described by json object
with fields:
- id - answer identifier
- name - answer name
csv
Csv file with three sections. The first one contains
data of demography traits. The second
contains data of discreete traits' values.
The third part contains default segments
for continuous traits.
The first part has one row for each available trait.
It has columns: continuous, id,
name,
which meanings correspond to the json output
fields in data part.
The second part has one row for each available
discreete trait value.
It has columns: id, name,
trait_id (id of discreete trait),
which meanings correspond to the json output
fields in data part.
The third part has one row for each available
continuous trait predefined segment.
It has columns: max, min,
trait_id (id of continuous trait),
which meanings correspond to the json output
fields in data part.
Examples
json
/v1/demography?session=1234567890xxxxxxxxxxxxxxxxxxxxxx&output=json
{
"api_version": 1,
"data": [
{
"answers": [
{
"id": 1,
"name": "kobieta"
},
{
"id": 2,
"name": "mężczyzna"
}
],
"continuous": false,
"id": 0,
"name": "Płeć"
},
{
"answers": [
{
"max": "14",
"min": "7"
},
{
"max": "24",
"min": "15"
},
{
"max": "34",
"min": "25"
},
{
"max": "44",
"min": "35"
},
{
"max": "54",
"min": "45"
},
{
"max": null,
"min": "55"
}
],
"continuous": true,
"id": 1,
"name": "Wiek"
},
],
"source": {
"begin": "2017-05-25",
"country": "pl",
"end": "2017-05-26"
}
}
csv
/v1/demography?session=1234567890xxxxxxxxxxxxxxxxxxxxxx&output=csv
continuous id name
False 0 Płeć
True 1 Wiek
id name trait_id
1 kobieta 0
2 mężczyzna 0
max min trait_id
14 7 1
24 15 1
34 25 1
44 35 1
54 45 1
55 1
/v1/stats
Shows statistics for selected parameters.
Allowed methods:
Parameters:
- session - user's session key obtained by /v1/open-session command
-
[output] - output data format.
Optional. Errors are always reported in json format.
Possible values:
- json - rich JSON output
- csv - simple CSV output
- [country] - ISO 3166-1 alfa-2 country code. Optional if user has access only to one market.
-
[begin] - date in ISO 8601 format, ‘YYYY-MM-DD’ for the begining of period.
Optional. If it is not passed, then data is returned for newest, available to user, daily period.
-
[end] - date in ISO 8601 format, ‘YYYY-MM-DD’ for the end of period.
Optional. If it is not passed, then data is returned for newest, available to user, daily period.
-
[geo] - selected geolocation. Optional. When missing, statistics are listed for all possible values.
Can be repeated to pass multiple values (see example for passing multiple values).
-
[platform] - selected platform. Optional. When missing, statistics are listed for all possible values.
Can be repeated to pass multiple values (see example for passing multiple values).
-
[node] - selected node. Optional. When missing, statistics are listed for all possible values.
Can be repeated to pass multiple values (see example for passing multiple values).
-
[metric] - selected metric. Optional. When missing, values for all metrics are shown.
Can be repeated to pass multiple values (see example for passing multiple values).
-
[target] - selected target group. Optional. When missing, statistics are listed for target group "Population".
Can be repeated to pass multiple values(see example for passing multiple values).
One target group is described by string with two parts separated by semicolon (';'):
- [name] - name of target group. It will be shown in results. Optional. When missing, definition will be used.
-
definition - definition of target group in form of equalities: {trait}={value}
joined by and (logical and) or or (logical or).
-
[strict] - boolean value if parameter errors should be reported as errors
and not as a filtered field. Optional. False by default.
See example.
-
[summary] - boolean value if stats summaries should been shown.
Summary data has empty node identifier (ie. equal to string null).
Outputs
json
Json dictionary with fields:
csv
Csv file with one row for each data point.
Output has columns: geo_id,
node_id, platform_id,
target_group,
which meanings correspond to the json output
fields in data/stats part. Moreover,
output has columns corresponding to selected
metrics. Columns are in an alphabetical order.
Examples
Example of target groups:
json
/v1/stats?session=1234567890xxxxxxxxxxxxxxxxxxxxxx&output=json&node=58751&node=58752&platform=101&target=men_25-30:0=2and1=25;30&metric=7&metric=8
{
"api_version": 1,
"data": {
"filtered": {
"geos": [],
"metrics": [],
"nodes": [],
"platforms": [],
"targets": []
},
"stats": [
{
"Page views": "3529980",
"Real users": "264953",
"geo_id": 1,
"node_id": "58751",
"platform_id": "101",
"target_group": "men_25-30"
},
{
"Page views": "-1",
"Real users": "-1",
"geo_id": 1,
"node_id": "58752",
"platform_id": "101",
"target_group": "men_25-30"
}
]
},
"source": {
"begin": "2017-05-25",
"country": "pl",
"end": "2017-05-26"
}
}
csv
/v1/stats?session=1234567890xxxxxxxxxxxxxxxxxxxxxx&output=csv&node=58751&node=58752&platform=101&target=men_25-30:0=2and1=25;30&metric=7&metric=8
Page views Real users geo_id node_id platform_id target_group
3529980 264953 1 58751 101 men_25-30
-1 -1 1 58752 101 men_25-30
The strict parameter
Lets assume, that queried period has not available
foreign statistics. By using strict parameter,
one can obtain two results.
strict=False
{
"api_version": 1,
"data": {
"filtered": {
"geos": [
2
],
"metrics": [],
"nodes": [],
"platforms": [],
"targets": []
},
"stats": [
{
"Page views": "3529980",
"Real users": "264953",
"geo_id": 1,
"node_id": "58751",
"platform_id": "101",
"target_group": "men_25-30"
},
{
"Page views": "-1",
"Real users": "-1",
"geo_id": 1,
"node_id": "58752",
"platform_id": "101",
"target_group": "men_25-30"
}
]
},
"source": {
"begin": "2017-05-25",
"country": "pl",
"end": "2017-05-26"
}
}
Csv output ignores filtered field, so user will not
see that some data was not available.
strict=True
{
"errors": {
"geo": [
"incorrect definitions of geos"
]
}
}
Even if csv output was selected, error are reported in json format.