Access to the Anglia API is authorised using the OAuth 2.0 client credentials flow.
POST
the OAuth Grant Type and specify your Client Id and Client Secret as a Basic Authorization Header to the token endpoint.
grant_type
: set this to "client_credentials"client_id
: Your application's Client Id.client_secret
: Your application's Client Secret.POST /token HTTP/1.1 Authorization: Basic MTIzN...yMzQ= // Derived from your client_id and client_secret grant_type=client_credentials
access_token
, token_type
, and expires_in
values. Use this token when sending requests to the API.
HTTP/1.1 200 OK
{
"access_token": "Umddnp6...HAmFgnt",
"token_type": "bearer",
"expires_in": 3599
}
invalid_client
is returned.
GET /api/v1/part?mpn={mpn} HTTP/1.1 Authorization: Bearer Umddnp6...HAmFgnt HTTP/1.1 200 OK Content-Type: application/json; charset=utf-8 [{"Id":712446001,"Brand":"TAICOM","Manufacturer":"TAICOM","MPN":"TPH04SSZ","ShortDescription":"SPACER 4W 2.54MM S/ROW...}]
To maintain performance of the API there is a rate limit of 10 HTTP requests/second per (Token and IP address) requests per day up to a maximum of 19200.
The Anglia API is CORS enabled and it is possible to make cross origin AJAX requests. A simple jQuery example is below.
$.ajax({
type: 'GET',
url: rootUrl + 'api/v1/part?mpn=' + encodeURI(mpn), // Find part(s) by MPN
headers: { 'Authorization': 'Bearer {access_token}' } // Send access token
}).done(function (data) {
// Output results - JSON.stringify(data);
}).fail(function (jqXHR, textStatus, errorThrown) {
if (jqXHR.status == 422)
// Handle possible validation result
else
// Handle error result
});