Reporting API
This guide will help you get started with the Reporting API in just a few minutes.
Getting started
We’ll use curl
for our API call examples. You could also consider a dedicated tool for developing API requests (like Postman).
Authenticate
You’ll need a session token to authenticate your requests, or Metabase will refuse to talk with you. To get a session token, submit a request to the /api/session endpoint with your username and password:
Attention: Your Metabase email and password are different than the credentials used to sign in to Massive’s Partner Portal.
This request will return a JSON object with a key called ID
and the token as the key’s value, e.g.
You’ll need to include that session token in the headers of your subsequent requests like this:
Some things to note about sessions:
- By default, sessions are good for 14 days.
- You should cache credentials to reuse them until they expire because logins are rate-limited for security.
- Invalid and expired session tokens return a 401 (Unauthorized) status code.
- Handle 401 status codes gracefully. We recommend writing your code to fetch a new session token and automatically retry a request when the API returns a
401 status code
.
Read any card
The reporting API builds on your dashboard view. You can query any data in your dashboard via the API with the command below:
Note: If there is data you’d like to query that is not in your dashboard please reach out to your contact at Massive via Slack or Email.
You simply need to replace the session ID with your from the authentication step and the card ID from your dashboard:
You can find the card ID in the URL of the card. In the example below that would be 484
:
Note: You must open a specific card and you should not use the ID of the whole dashboard.