Example Code

Example Code

This article gives sample code for using the Smart API.

Fetching Access Token using Python

This example describes the authentication process using example credentials. See Authenticating with the API for more details.

The examples in this article use the Demo Project which you are free to use for testing the API.

#!/usr/bin/env python3

import requests

if __name__ == '__main__':

client_id = 'ITGMXMTDL6U7VG62ES428VSI39SI7E8VMI3W8Y9R'

tokens_url = 'https://app.smartsubmissions.io/token'
authentication_data = {
    'grant_type': 'client_credentials',
    'client_id': client_id,
}
authentication_headers = {
    'Content-Type': 'application/x-www-form-urlencoded',
}

response = requests.post(
    tokens_url,
    authentication_data,
    headers=authentication_headers,
)

token = reponse.json().get('access_token')