API Requirements
Any call for the API requires the following headers in the REQUEST header except for the get_token API call
Content-Type- The content type of the request must beapplication/jsonx-api-key- The token value for a user received from the Timbr-platform
For the get_token endpoint, the following headers are required instead of the x-api-key header
Authorization- The authorization bearer of a base64 username/password combination encrypted with the salt as defined in theAPI_AUTH_SALTenvironment variable of the timbr-api service
How to get a token for a user from the Timbr platform
For the following example, we use the following assumption: The endpoint https://timbr-sample.company.com as if the Timbr-Platform is running and configured
- Login to the timbr-platform endpoint (i.e. - https://timbr-sample.company.com)
- Access the endpoint - https://timbr-sample.company.com/timbr/get_timbr_user_token/
- Save the value of the
tokento be used as thex-api-keyof the requests.
How to get a token from the Timbr API Service
To get the API token using the Timbr API Service you will need to generate an Authorization Bearer token.
Timbr API Service uses Fernet symmetric encryption as defined in Python cryptography library to generate the Authorization Bearer Token
The Bearer Token is used in the request for get_token in order to get a Timbr-api token.
Steps to get a Timbr-api token using an Authorization Bearer token:
- Create an authorization bearer token by following and running the python script provided with the installation of the Timbr API Service
- Post a request using the authorization bearer token with the following headers to
/timbr/api/get_token
| Header Key | Header Value | Sample | Description |
|---|---|---|---|
Content-Type | application/json | Content-Type: application/json | Posts a query and returns results in JSON form |
Authorization | Bearer <token> | Authorization: Bearer gAAAAA.... | Used for authentication and retrieval of a timbr token to be used in following requests |
Request:
curl -X 'POST' \
'https://timbr-sample.company.com/timbr/api/get_token' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer gAAA...Gy8='
Response:
- Response code: 200
- Response body:
{
"data": [
"tk_ab...6af3"
],
"status": "success"
}
Required Headers in Requests
The following headers are required in any API call request (except for the get_token request)
| Header Key | Header Value | Sample | Description |
|---|---|---|---|
Content-Type | application/json | Content-Type: application/json | Posts a query and returns results in JSON form |
x-api-key | *************** | x-api-key: *************** | The header value is the token value for a user from the Timbr-Platform |