Skip to main content Link Menu Expand (external link) Copy Copied

GraphQL API

The GraphQL API relies on OAuth2 for authentication.

We’re using the Machine-to-Machine workflow, you will be provided with a client ID and and client secret.

If you do not have your ID and secret yet, please contact us so we can create an access for you.

Authentication

To use the API, you need to get a token. Using your client ID and client secret, the following HTTP query will return your token:

    curl --request POST \
        --url https://tokens.analytiks.ai \
        --header 'content-type: application/json' \
        --data '{"client_id":"__YOUR_CLIENT_ID__","client_secret":"__YOUR_CLIENT_SECRET__","audience":"https://gql.analytiks.ai","grant_type":"client_credentials"}'

On success the API call will return a structure like this one:

{"access_token":"YOUR_TOKEN","expires_in":86400,"token_type":"Bearer"}

Usage

Once you have your token, you can send POST requests to https://gql.analytiks.ai/v1/graphql.

We are expecting the following headers:

  • Content-Type set to application/json
  • Authorization set to Bearer YOUR_TOKEN

You can play with the API in the API Explorer provided on this site.

The API Visualization section may also be helpful.

Query examples

You can list all available locations with the following query:

query ListLocations {
  locationList {
    id
    name
    brand {
      id
      name
    }
  }
}

Using one of your location’s ID, you can get a detailed presence report for a date range (or a single day, in this example).

For metrics providing hourly breakdowns, an array of with 24 elements will be returned, one for each hour of the day. Data is indexed in chonological order, starting from 12AM-1AM, local time:

query PresenceReport {
  location(id: __YOUR_ID_HERE__) {
    id
    name
    presenceAnalytics(from: "2021-07-07", to: "2021-07-07") {
      visitsDuration {
        average
        under15Mins
        from15To30Mins
        from30To45Mins
        from45To60Mins
        over60Mins
      }
      visits {
        source
        value
      }
      walkBys {
        source
        value
      }
      newVisitors {
        source
        value
      }
      returningVisitors {
        source
        value
      }
      walkthroughRate {
        source
        value
      }
      averageDailyVisits {
        source
        value
      }
      visitsByHour {
        source
        dataPoints {
          key
          values
        }
      }
      zoneAnalytics {
        metricsByDay {
          day
          metrics {
            lowActivity
            highActivity
            relativeActivity
            source
          }
        }
      }
    }
  }
}

If your location is equiped with access points and provides WiFi login for your users, you can query user profiles for a given day (or a date range) like so:

query PresenceQuery($id: Int!, $from: timestamptz!, $to: timestamptz!) {
  location(id: $id) {
    visitorProfiles (
        where: {
          lastVisit: { _gte: $from, _lt: $to }
        },
        order_by: { lastVisit: desc }
    ) {
      wifiProfile {
        firstName
        lastName
        gender
        language
        email
        phoneNumber
        allowsMarketing
      }
      visits
      lastLoginMethod
      lastVisit
    }
  }
}

Note that querying with this style requires parameters to be supplied separately:

{
  "id": __YOUR_LOCATION_ID__,
  "from": "2022-01-22",
  "to": "2022-01-23"
}

If you have any question, feel free to contact us!