Authentication

Piriod uses Authorization HTTP header for authenticating the API calls. Add "Token your_token" to Authorization header in your API calls. The API key could be got from API Keys section in your user preferences page in the web client console.

Sample authentication

For python you could specify the API key through headers params using requests library.

import requests

url = f'https://api.piriod.com/subscriptions/{id}/'
headers = {
  'Authorization': f'Token {api_key}'
}
r = requests.get(url=url, headers=headers)

print(r.json())

Organizations

Clients can make requests as organizations using the special header x-simple-workspace which should contain a Piriod organization ID, usually starting with the prefix acc_. The organization ID could be got from Organizations section in your user preferences page in the web client console.

Set organization ID to API calls

The value is set per-request as shown in the adjacent code sample. Methods on the returned object reuse the same account ID.

import requests

url = f'https://api.piriod.com/subscription/{id}/'
headers = {
  'Authorization': f'Token {api_key}'
  'x-simple-workspace': organization_id
}
r = requests.get(url=url, headers=headers)

print(r.json())