SMAT
Search
⌃K

Pro API

This page describes functionality for our Pro API which mirrors our public free API. Please get in touch if you'd like to discuss access to this.
The Pro API allows users to authenticate themselves using JWT keys and deprecates the need for IP address whitelisting for partnered access.
For more information about JWT keys please check out the JWT website: https://jwt.io/introduction

Authentication

We authenticate users to the Pro API using JWTs. These keys are sent with an API request via an "Authorization: Bearer" header. For example:
import requests
jwt_token = <YOUR TOKEN HERE>
pro_api_host_url = <PRO API_URL HERE>
r = requests.get(
f"{pro_api_host_url}/content",
params={
"site": "win",
"term": "Trump arrest",
"since": "2022-01-01",
"until": "2023-03-18",
},
headers={
"Authorization": f"Bearer {jwt_token}",
},
)
data = r.json()

Refresh Tokens

The JWT token used in requests to the Pro API will expire after 30 days. Therefore it is recommended that for extended use that you re-issue your JWT before the 30 day limit using a refresh token.
The Pro API hosts an endpoint for users to request a new JWT token using a refresh token that can be obtained on the account page of the dashboard application. A refresh token is invalidated after a single use however the request to reissue a new JWT will return a new refresh token that can be used in subsequent calls.
import requests
jwt_token = <YOUR TOKEN HERE>
refresh_token = <YOUR REFRESH TOKEN>
pro_api_host_url = <PRO API_URL HERE>
r = requests.get(
f"{pro_api_host_url}/get_access_token",
params={"refresh_token": refresh_token},
headers={
"Authorization": f"Bearer {oauth_token}",
},
)
data = r.json()
print(data)
```
{
"access_token": <YOUR NEW JWT>
"expires_in": 2592000,
"refresh_token": <YOUR NEW REFRESH TOKEN>,
"token_type": "Bearer"
}
```