Search…
GraphQL
Our API primarily speaks GraphQL (GQL, for short). While explaining how GraphQL works is beyond the scope of this guide, there are excellent resources available on the interwebs.
Here we will introduce the basic request-response structure of the Sentiance GraphQL API.

Endpoint and Authorization

Our default GraphQL endpoint lives at POST https://api.sentiance.com/v2/gql and accepts the same bearer token based authorization as our REST endpoints.
We adhere to the GraphQL specification but do not support multiple operation types.
Since it is possible for a single HTTP request to encompass multiple GraphQL queries with some of them succeeding and some of them failing, the endpoint always returns a 200 OK, unless something severe enough happens on the server-side to guarantee failure of the entire response (such as a 500 status code). After checking for the 200 status code, please also check the body of the response for data and error properties.
For other environments, please ask your sales representative or [email protected] for the custom endpoint linked to your environment.
post
https://api.sentiance.com
/v2/gql
GQL Request

Introspection

While you can always discover and play around with Graphql in our Data Explorers, you might wish to programatically introspect our Schema for your own tools to parse. You can do so by firing off an Introspection Query.
1
QUERY
2
query IntrospectionQuery {
3
__schema {
4
queryType {
5
name
6
}
7
mutationType {
8
name
9
}
10
subscriptionType {
11
name
12
}
13
types {
14
...FullType
15
}
16
directives {
17
name
18
description
19
locations
20
args {
21
...InputValue
22
}
23
}
24
}
25
}
26
27
fragment FullType on __Type {
28
kind
29
name
30
description
31
fields(includeDeprecated: true) {
32
name
33
description
34
args {
35
...InputValue
36
}
37
type {
38
...TypeRef
39
}
40
isDeprecated
41
deprecationReason
42
}
43
inputFields {
44
...InputValue
45
}
46
interfaces {
47
...TypeRef
48
}
49
enumValues(includeDeprecated: true) {
50
name
51
description
52
isDeprecated
53
deprecationReason
54
}
55
possibleTypes {
56
...TypeRef
57
}
58
}
59
60
fragment InputValue on __InputValue {
61
name
62
description
63
type {
64
...TypeRef
65
}
66
defaultValue
67
}
68
69
fragment TypeRef on __Type {
70
kind
71
name
72
ofType {
73
kind
74
name
75
ofType {
76
kind
77
name
78
ofType {
79
kind
80
name
81
ofType {
82
kind
83
name
84
ofType {
85
kind
86
name
87
ofType {
88
kind
89
name
90
ofType {
91
kind
92
name
93
}
94
}
95
}
96
}
97
}
98
}
99
}
100
}
101
Copied!

Examples

Some examples of various GQL queries with example response are presented here. With GraphQL you can fetch as much or as little as you wish.

Moment Definitions

1
QUERY
2
query {
3
moment_definitions {
4
id
5
type
6
category
7
display_name
8
}
9
}
10
11
RESPONSE
12
{
13
"data": {
14
"moment_definitions": [
15
{
16
"id": "working_at_work",
17
"type": "MomentDefinition",
18
"category": "activity",
19
"display_name": "Working at work"
20
},
21
{...}
22
]
23
}
24
}
Copied!

Alpha Segments

1
QUERY
2
query {
3
segment_definitions(status: ALPHA) {
4
id
5
type
6
category
7
display_name
8
}
9
}
10
11
RESPONSE
12
{
13
"data": {
14
"segment_definitions": [
15
{
16
"id": "mobility.passenger",
17
"type": "SegmentDefinition",
18
"category": "passenger",
19
"display_name": "Passenger"
20
},
21
{...}
22
]
23
}
24
}
Copied!

User Timeline Query

1
QUERY
2
query($user_id: String!, $from:String, $to: String) {
3
user(id: $user_id) {
4
event_history(from: $from, to:$to) {
5
type
6
start
7
end
8
analysis_type
9
... on Stationary {
10
latitude
11
longitude
12
location {
13
significance
14
}
15
}
16
... on Transport {
17
mode
18
distance
19
}
20
}
21
}
22
}
23
24
VARIABLES
25
{
26
"user_id": "583e08a1cd99250700000002",
27
"from": "2019-03-22",
28
"to": "2019-03-23"
29
}
30
31
RESPONSE
32
{
33
"data": {
34
"user": {
35
"event_history": [
36
{
37
"type": "Stationary",
38
"start": "2019-03-23T19:51:49.000+01:00",
39
"end": "2019-03-25T08:30:21.000+01:00",
40
"analysis_type": "indepth",
41
"latitude": 51.78561,
42
"longitude": 42.49694,
43
"location": {
44
"significance": "home"
45
}
46
},
47
{
48
"type": "Transport",
49
"start": "2019-03-23T19:49:49.000+01:00",
50
"end": "2019-03-23T19:51:49.000+01:00",
51
"analysis_type": "indepth",
52
"mode": "walking",
53
"distance": null
54
},
55
{...}
56
]
57
}
58
}
59
}
Copied!

User Moment History

1
QUERY
2
query($user_id: String!, $from:String, $to: String) {
3
user(id: $user_id) {
4
id
5
moment_history(from: $from, to:$to) {
6
start
7
end
8
analysis_type
9
moment_definition_id
10
}
11
}
12
}
13
14
VARIABLES
15
{
16
"user_id": "583e08a1cd99250700000002",
17
"from": "2019-03-22",
18
"to": "2019-03-23"
19
}
20
21
RESPONSE
22
{
23
"data": {
24
"user": {
25
"id": "583e08a1cd99250700000002",
26
"moment_history": [
27
{
28
"start": "2019-03-23T19:51:49.000+01:00",
29
"end": "2019-03-25T08:30:21.000+01:00",
30
"analysis_type": "processed",
31
"moment_definition_id": "home"
32
},
33
{
34
"start": "2019-03-23T19:22:40.000+01:00",
35
"end": "2019-03-23T19:49:49.000+01:00",
36
"analysis_type": "processed",
37
"moment_definition_id": "shopping_routine"
38
},
39
{...}
40
]
41
}
42
}
43
}
Copied!
Last modified 5mo ago