Discovery API

Introduction

Note: To access the Discovery API, your Workspace must be on the Mode Enterprise plan. Talk to your CSM to get access to the Discovery API.

The Discovery API is a read-only batch API that allow developers to get lists of Mode resources, along with metadata about each of those resources. The API will be referred to as ‘batch’ throughout the documentation. The resources currently supported are Reports, Collections, Queries and Charts.

Note: Spaces have been rebranded as Collections in Mode, but the API will continue to refer to spaces. The spaces object and resources are the same as Collections in the Mode UI.

Getting started with the Discovery API

To create a valid Signature Token for accessing the Discovery API, a Workspace admin’s API key & secret are required for authenticating the token creation endpoint. All other endpoints will require a valid Signature Token for access.

Note: If the user who set up API credentials leaves the workspace, the credentials will be invalidated and you will need to create another token.

1. Get API key and secret

2. Create a Signature Token for Discovery API requests

3. Use the Signature Token to authenticate with the Discovery API

Include the Bearer Token in the Authentication Header of your requests.

Use the Signature Token to Authenticate with the Discovery API:

signature_token = {
  "token": "5b89bf4b0a49",
  "name": "batch-api-token-1",
  "creator_id": 3,
  "organization_id": 4,
  "access_key": "8b6fdc0a36bf340604a3cedc",
  "access_secret": "829146cb6c752f51bbbb8c85",
  "created_at": "2020-07-02T21:01:17.181Z",
  "updated_at": "2020-07-02T21:01:17.181Z",
  "expires_at": "2020-10-02T21:00:00.000Z",
  "authentication_for": "batch-api",
  "authorization_type": "read-only"
}

token         = signature_token["token"]
access_key    = signature_token["access_key"]
access_secret = signature_token["access_secret"]
DECODED_TOKEN="$TOKEN":"$ACCESS_KEY":"$ACCESS_SECRET"
ENCODED_TOKEN=$( echo -n $DECODED_TOKEN | base64 )
BEARER_TOKEN="Bearer "$ENCODED_TOKEN""
decoded_token = "#{token}:#{access_key}:#{access_secret}"
encoded_token = Base64.strict_encode64(decoded_token)
bearer_token  = "Bearer #{encoded_token}"
from base64 import b64encode

decoded_token = token + ':' + access_key + ':' + access_secret
encoded_token = b64encode(decoded_token.encode('utf-8'))
bearer_token  = 'Bearer ' + encoded_token.decode('utf-8')
decoded_token = token + ':' + access_key + ':' + access_secret;
encoded_token = btoa(decoded_token);
bearer_token  = 'Bearer ' + encoded_token;