LogoLogo
Insights
  • Introduction
  • A standard integration
  • FAQ
    • FAQ
      • Integration (FAQ)
      • Detections (FAQ)
      • Data interface (FAQ)
      • Security, Privacy and Terms of Service (FAQ)
      • Journeys and Insights (FAQ)
  • SDK
    • Getting Started
      • Android Quick Start
        • 1. Android Checklist
        • 2. Including the SDK
        • 3. Configuration
          • Sample Notification
        • 4. Initialization
        • 5. Starting Detections
        • 6. SDK Status Updates
        • 7. Permissions
        • 8. What's Next
      • iOS Quick Start
        • 1. iOS Checklist
        • 2. Installation
          • Installation with CocoaPods
          • Installation with Carthage
          • Manual Installation
        • 3. Configuration
          • Using Integration Guide
          • Manual Configuration
        • 4. Usage
        • 5. Tips and Guidelines
        • 6. What's Next
      • React Native Quick Start
        • 1. React Native Checklist
        • 2. Installation
        • 3. Configuration
        • 4. Initialization
        • 5. Usage
        • 6. What's Next
    • Appendix
      • Android
        • Android 10 Update Behavior
        • Android Battery Optimization
        • External SDK Dependencies
        • Manifest Permissions
        • Notification Management
      • iOS
        • App Store Privacy Section
        • App Store Release
        • iOS 13 permission changes
        • M1 Simulator Support
        • Swift Support
      • Control Sending Data
      • Controlled Detections
        • Automatic Detections
        • Automatic Detections with Forced Trips
        • Controlled Trips Only
        • Checking Trip Status
      • Custom User Metadata
      • Detecting Vehicle Crashes
      • Migration Guide
        • Android
        • iOS
      • React Native
      • SDK Initialization
      • User Credentials
      • User Linking
      • Xamarin
    • API Reference
      • Android
        • VehicleCrashDetection
          • VehicleCrashEvent
          • VehicleCrashListener
          • CrashCallback
        • InitState
        • MetaUserLinker
        • MetaUserLinkerAsync
        • MetaUserLinkerCallback
        • OnInitCallback
          • InitIssue
        • OnSdkStatusUpdateHandler
        • OnStartFinishedHandler
        • PoiAddress
        • PoiLocation
        • PointOfInterest
        • PoiPlace
        • ResetCallback
          • ResetFailureReason
        • SdkConfig
          • Builder
        • SdkException
        • SdkStatus
          • LocationSetting
          • Quota Status
          • StartStatus
        • Sentiance
        • SubmitDetectionsCallback
        • StationaryInfo
        • Token
        • TokenResultCallback
        • Trip
          • StartTripCallback
          • StopTripCallback
          • TransportMode
          • TripTimeoutListener
          • TripType
        • TripInfo
        • TripProfile
          • HardEvent
          • TransportSegment
          • VehicleMode
        • TripProfileConfig
          • Builder
        • TripProfileListener
        • UserActivity
        • UserActivityListener
        • UserActivityType
      • iOS
        • MetaUserLinker
        • SENTSDK
          • SENTSDKStatus
          • SENTPublicDefinitions
        • SENTConfig
        • SENTTripProcessingTripProfile
          • SENTTripProcessingTransportSegment
          • SENTTripProcessingHardEvent
          • SENTTripProcessingVehicleMode
        • SENTVehicleCrashEvent
      • React Native
    • Battery Optimization
    • How To
      • Check the Location Permissions
    • Troubleshooting
      • Android
      • iOS
        • Bundle format unrecognized, invalid, or unsuitable
        • Error: Undefined symbols for architecture arm64
    • Changelog
      • Android
      • iOS
  • Important topics
    • Authentication and Authorization
    • User linking
    • PlayStore Location Access Review
    • Privacy Report & Dashboard
    • Vehicle Crash Detection
  • Library
    • Events
    • Moments
    • Segments
    • Glossary
  • Backend
    • GraphQL
    • REST API Reference
      • Error Codes (REST API)
    • Offloads
    • Data Reference
      • Data Reference A-B
      • Data Reference C-G
      • Data Reference H-L
      • Data Reference M-P
      • Data Reference Q-T
      • Data Reference U-Z
  • Data Explorer
    • Data Explorer
      • Global (EU)
      • US
      • Australia
  • Guide
    • Firehose
    • Verifying your integration
    • SDK Standard License
    • Journeys License
    • Journeys Application
    • Journeys Privacy Policy
    • Technical & Organizational Measures
Powered by GitBook
On this page
  • Endpoint and Authorization
  • GQL Request
  • Introspection
  • Examples
  • Moment Definitions
  • Alpha Segments
  • User Timeline Query
  • User Moment History
  1. Backend

GraphQL

PreviousGlossaryNextREST API Reference

Last updated 1 year ago

This document refers to deprecated parts of the platform and has been left intact to help customers with legacy integrations. In order to access the latest platform features and documentation, please go to https://docs.sentiance.com.

Our API primarily speaks (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 as our

We adhere to the 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 for the custom endpoint linked to your environment.

GQL Request

POST https://api.sentiance.com/v2/gql

Headers

Name
Type
Description

Authorization

string

Bearer

Content-Type

string

application/json

Request Body

Name
Type
Description

query

string

The GraphQL query.

variables

object

A flat JSON object describing the variables to substitute in the query.

REQUEST 
{
  "query": "query($user_id: String!) {\n  user(id: $user_id) {\n    id\n    event_history(from: \"2019-04-01\", to:\"2019-04-02\") {\n      type\n      start\n      end\n      analysis_type\n      ... on Stationary {\n        latitude\n        longitude\n        location {\n          significance\n        }\n      }\n      ... on Transport {\n        mode\n        distance\n      }\n    }\n  }\n}",
  "variables": {
    "user_id": "5a93deb3d8e7d90600001e6f"
  }
}

RESPONSE
{
  "data": {
    "user": {
      "id": "5a93deb3d8e7d90600001e6f",
      "event_history": [
        {
          "type": "Stationary",
          "start": "2019-02-05T09:25:01.000+01:00",
          "end": null,
          "analysis_type": "indepth",
          "latitude": 51.19654,
          "longitude": 4.40794,
          "location": {
            "significance": "new"
          }
        }
      ]
    }
  }
}

Introspection

QUERY
query IntrospectionQuery {
  __schema {
    queryType {
      name
    }
    mutationType {
      name
    }
    subscriptionType {
      name
    }
    types {
      ...FullType
    }
    directives {
      name
      description
      locations
      args {
        ...InputValue
      }
    }
  }
}

fragment FullType on __Type {
  kind
  name
  description
  fields(includeDeprecated: true) {
    name
    description
    args {
      ...InputValue
    }
    type {
      ...TypeRef
    }
    isDeprecated
    deprecationReason
  }
  inputFields {
    ...InputValue
  }
  interfaces {
    ...TypeRef
  }
  enumValues(includeDeprecated: true) {
    name
    description
    isDeprecated
    deprecationReason
  }
  possibleTypes {
    ...TypeRef
  }
}

fragment InputValue on __InputValue {
  name
  description
  type {
    ...TypeRef
  }
  defaultValue
}

fragment TypeRef on __Type {
  kind
  name
  ofType {
    kind
    name
    ofType {
      kind
      name
      ofType {
        kind
        name
        ofType {
          kind
          name
          ofType {
            kind
            name
            ofType {
              kind
              name
              ofType {
                kind
                name
              }
            }
          }
        }
      }
    }
  }
}

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

QUERY
query {
  moment_definitions {
    id
    type
    category
    display_name
  } 
}

RESPONSE
{
  "data": {
    "moment_definitions": [
      {
        "id": "working_at_work",
        "type": "MomentDefinition",
        "category": "activity",
        "display_name": "Working at work"
      },
      {...}
    ]
  }
}

Alpha Segments

QUERY
query {
  segment_definitions(status: ALPHA) {
    id
    type
    category
    display_name
  } 
}

RESPONSE
{
  "data": {
    "segment_definitions": [
      {
        "id": "mobility.passenger",
        "type": "SegmentDefinition",
        "category": "passenger",
        "display_name": "Passenger"
      },
      {...}
    ]
  }
}

User Timeline Query

QUERY
query($user_id: String!, $from:String, $to: String) {
  user(id: $user_id) {
    event_history(from: $from, to:$to) {
      type
      start
      end
      analysis_type
      ... on Stationary {
        latitude
        longitude
        location {
          significance
        }
      }
      ... on Transport {
        mode
        distance
      }
    }
  }
}

VARIABLES
{ 
  "user_id": "583e08a1cd99250700000002",
  "from": "2019-03-22",
  "to": "2019-03-23"
}

RESPONSE
{
  "data": {
    "user": {
      "event_history": [
        {
          "type": "Stationary",
          "start": "2019-03-23T19:51:49.000+01:00",
          "end": "2019-03-25T08:30:21.000+01:00",
          "analysis_type": "indepth",
          "latitude": 51.78561,
          "longitude": 42.49694,
          "location": {
            "significance": "home"
          }
        },
        {
          "type": "Transport",
          "start": "2019-03-23T19:49:49.000+01:00",
          "end": "2019-03-23T19:51:49.000+01:00",
          "analysis_type": "indepth",
          "mode": "walking",
          "distance": null
        },
        {...}
      ]
    }
  }
}

User Moment History

QUERY
query($user_id: String!, $from:String, $to: String) {
  user(id: $user_id) {
    id
    moment_history(from: $from, to:$to) {
      start
      end
      analysis_type
      moment_definition_id
    }
  }
}

VARIABLES
{ 
  "user_id": "583e08a1cd99250700000002",
  "from": "2019-03-22",
  "to": "2019-03-23"
}

RESPONSE
{
  "data": {
    "user": {
      "id": "583e08a1cd99250700000002",
      "moment_history": [
        {
          "start": "2019-03-23T19:51:49.000+01:00",
          "end": "2019-03-25T08:30:21.000+01:00",
          "analysis_type": "processed",
          "moment_definition_id": "home"
        },
        {
          "start": "2019-03-23T19:22:40.000+01:00",
          "end": "2019-03-23T19:49:49.000+01:00",
          "analysis_type": "processed",
          "moment_definition_id": "shopping_routine"
        },
        {...}
      ]
    }
  }
}

While you can always discover and play around with Graphql in our , you might wish to programatically introspect our Schema for your own tools to parse. You can do so by firing off an Introspection Query.

GraphQL
bearer token based authorization
REST endpoints.
GraphQL specification
support@sentiance.com
Data Explorers