Security
Each api call expects the authorization token in the request header. To generate it, you should follow the next steps.
Generate token
Important: the generated token will be valid for 14 days.
1. Create a request with the following properties:
- Base url: https://api.acuitytrading.com/token
- Http method: POST
- ContentType: application/x-www-form-urlencoded; charset=UTF-8
- X-Requested-With: XMLHttpRequest
The body content depends on where the call is from:
- Body: {grant_type=password&username=’client_username’&password=’client_password’}
C# Sample
var client = new RestClient("https://api.acuitytrading.com/token");
var request = new RestRequest(Method.POST);
request.AddHeader("Cache-Control", "no-cache");
request.AddParameter("undefined", "grant_type=password&username=client_username&password=client_password, ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
2. Call and capture the token: You will receive the following result format:
"access_token": "...",
"token_type": "...",
"expires_in": "...",
"userName": "...",
Append authorization token to api call
Once you have the token, you should append it on the api call as a header in the following format:
- Header key: Authorization
- Value key: “Bearer {access_token}"
C# Sample:
var client = new RestClient("https://api.acuitytrading.com/api/assettypes");
var request = new RestRequest(Method.GET);
request.AddHeader("Cache-Control", "no-cache");
request.AddHeader("Authorization", "Bearer {your_token}");
IRestResponse response = client.Execute(request);