Generating an API client for your language

We provide a specification of our API in the OpenAPI v3 format. You can find the current version of the spec here. We recommend openapi-generator to generate an API client for the programming language you use. As an example, here is how we generate a Python client module:

mkdir build-python
openapi-generator-cli generate -i /path/to/spec.yaml -g python -o build-python

You might have to write some custom code to retrieve an access token using your OAuth client credentials, along the lines of:

# Create an authenticated client instance.
configuration = Configuration()
configuration.host = URL

# Perform OAuth authentication
response, response_code, _ = openapi_client.ApiClient(configuration).call_api(
    resource_path='/oauth/token',
    method='POST',
    body={
        "grant_type": "client_credentials",
        "client_id": CLIENT_ID,
        "client_secret": CLIENT_SECRET,
    },
    response_type='dict(str, str)'
)
assert response_code == 200

# Re-create client with access token
client = openapi_client.ApiClient(
    configuration,
    header_name='Authorization',
    header_value=f'Bearer {response["access_token"]}'
)
return client

Last updated