Getting Started

The following procedures help you to get started with Mobility Intelligence APIs.

Log in to the API Store

  1. Go to the API Store website.
  2. Sign in to the website using the provided credential.
API Store

Subscribe to an API

  1. Click the API that you want to subscribe (for example, DiscreteVisit API).
  2. Select DefaultApplication from the Applications drop-down list.
  3. Select Free from the Tiers drop-down list.
  4. Click Subscribe.
Subscribe an API

Get Access Token

  1. In the navigation menu, select Applications.
  2. In the Application page, click DefaultApplication.
  3. Click Production Keys tab to generate production.
    Do not click Sandbox Keys tab. Sandbox APIs are meant for testing.
  4. Click Generate keys and then Show Keys. The Consumer Key and Consumer Secret become visible. You can click the Copy icon to copy the keys.
Generate and show key

Query API

There are two ways to query API. You can query by using:

  • in-built Swagger tool
  • code

To query API using Swagger tool

Note: When you run queries using the Swagger tool, they are added to the query count.

  1. In the navigation menu, select APIS.
  2. Select the API that you want to query, for example, DiscreteVisitAPI.
    Before you query an API, you need to first subscribe to it,
  3. Click API Console tab, and then click POST, as shown in the following screenshot. The Parameters and Response Messages sections appear, showing the Payload value text area.
  4. Either enter or paste your query in the Payload Value text area.
    Note: You can find sample queries in the respective API pages. Alternatively, see the following section for some sample queries.
  5. ‍Click Try it out! to query the API. 
Query API using the Swagger tool

To query API using code

  1. Get access token (OAuth Client Credentials grant type) by calling the token API.
  2. Append the consumer key and secret into a single string "CONSUMER_KEY:CONSUMER_SECRET" and then base64-encoded.
  3. Use the access token in the code to query the API.
    Refer to the examples for generating the access token and using the access tokens in code, examples are in CURL, Python®, and R® programming languages.

Examples to generate the token


See the preceding Get Token Access section to access the Production Keys tab.
Scroll down to the Generating Access Tokens section and then copy the second Curl command. 
You can generate an access token using the client credential grant type with the command. The base64 string is generated for you, it is visible in the code if you click Show Keys.

curl -k -d "grant_type=client_credentials" \  -H "Authorization: Basic [base64 encoded CONSUMER_KEY:CONSUMER_SECRET]" \  https://apistore.datasparkanalytics.com/token


To use this example, you need to have the Requests package.

import base64
import requests
consumerKey = "CONSUMER_KEY"
consumerSecret = "CONSUMER_SECRET"
keySecret = (consumerKey + ":" + consumerSecret).encode('utf-8')
consumerKeySecretB64 = base64.b64encode(keySecret).decode('utf-8')
tokenResponse = requests.post("https://apistore.datasparkanalytics.com/token",
  data = { 'grant_type': 'client_credentials' },  
  headers = { 'Authorization': 'Basic ' + consumerKeySecretB64 })
token = tokenResponse.json()['access_token']



consumer.key <- "CONSUMER_KEY"
consumer.secret <- "CONSUMER_SECRET"
key.secret.b64 <- base64_encode(paste(consumer.key, consumer.secret, sep = ":"))
token.response <- POST("https://apistore.datasparkanalytics.com/token",
    body = "grant_type=client_credentials",
    add_headers(Authorization = paste("Basic", key.secret.b64)))
token <- content(token.response)$access_token

Examples to use the access tokens in code to query the API


export REQUEST='{
 "date": "2017-05-30",
 "location": {
   "locationType": "locationHierarchyLevel",
   "levelType": "discrete_visit_subzone",
   "id": "OTSZ02"
 "queryGranularity": {
   "type": "period",
   "period": "PT1H"
 "aggregations": [
     "metric": "unique_agents",
     "type": "hyperUnique",
     "describedAs": "footfall"

curl -H "Authorization: Bearer [Insert access token]" \     -H "Content-Type: application/json" \     --data-raw "$REQUEST" \      "https://apistore.datasparkanalytics.com:8243/discretevisit/v2/query"


To use this example, you need to have the Requests package.

import json

queryBody = {
 "date": "2017-05-30",  "location": {
   "locationType": "locationHierarchyLevel",
   "levelType": "discrete_visit_subzone",
   "id": "OTSZ02"
 "queryGranularity": {
   "type": "period",
   "period": "PT1H"
     "metric": "unique_agents",
     "type": "hyperUnique",
     "describedAs": "footfall"

queryResponse = requests.post("https://apistore.datasparkanalytics.com:8243/discretevisit/v2/query",
 data = json.dumps(queryBody),
 headers = {
   'Authorization': 'Bearer ' + token,
   'Content-Type': 'application/json'

footfallResult = queryResponse.json()


query.body <- list(
  date = "2017-05-30",
  location = list(locationType = "locationHierarchyLevel",
  levelType = "discrete_visit_subzone", id = "OTSZ02"), 
  queryGranularity = list(type = "period", period = "PT1H"),
  aggregations = list(list(metric = "unique_agents", type = "hyperUnique", describedAs = "footfall")) )
query.response <- POST("https://apistore.datasparkanalytics.com:8243/discretevisit/v2/query",
                      add_headers(Authorization = paste("Bearer", token)),
                      encode = "json",
                      body = query.body)
footfall.result <- content(query.response)