Getting Started

Authentication

Access to the Anglia API is authorised using the OAuth 2.0 client credentials flow.

Steps

  1. You will first need to register your application with Anglia by contacting the API team to obtain your Client Id and Client Secret. It is important you keep these details secret as per our Terms & Conditions.
  2. Your application can now request an access token. To do so, you will need to 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
    
  3. If successful, you'll receive an HTTP 200 response with a payload containing 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
    }
    
    Check your Client Id and Client Secret are correct if invalid_client is returned.
  4. Now you can make authenticated requests to the Anglia API endpoints. Use the retrieved access token as a Bearer token in the Authorization header of your HTTP request. The browser will not automatically include the access token in subsequent requests your application must do so explicitly. You will need to request a new access token if it has expired and you must use HTTPS to provide transport layer security.
    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...}]
    

Rate Limit

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 9600.

Asynchronous Requests

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
});
* For readability, all code examples are deliberately truncated.