Getting started with the Expirify API

The Expirify Client API offers a subset of the full Expirify functionality to allow integration with 3rd party systems.

What can you do with the API?

This API currently offers...

Sample Code & Examples

While the Expirify API can be accessed with any programming language that can make web requests, we have only created samples using Javascript because the samples can be executed right in your browser!

Authorization

All requests to the Expirify are made on behalf of an actual user. First you will need to authorize the user by requesting a bearer token. Once you have a bearer token, you pass that token as header with the request. Any request will be processed as the user who requested the bearer token.

Bearer tokens expire after 18 hours, at which point you will need to request a new one. Once a token has been issued, it cannot be revoked until is has expired.

When requesting a bearer token, you have 2 choices. You can redirect the user to a page hosted by Expirify where they can safely enter their credentials. Or you can request a token directly by posting to /Token. This is usually only required when doing server to server integration or when creating native applications.

Request Token via Redirect

  1. Redirect the user to https://api.expirify.com/account/login?redirect_url=/http://yourdomain.com/pageWithinYourApp.html where "redirect_url" is an absolute url to a page on your site.
  2. Upon successful login, the user will be redirected to the page specified in the redirect_url query string parameter but with ?access_token=abc123etc appended.
  3. Save the access_token either in your application or in the users local browser storage. You will need to use this token in every API call.
    Here is an example of how to get the access_token from the url.
    function getParameterByName(name) {
    name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
    var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
        results = regex.exec(location.search);
    return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
    }
            
    var token = getParameterByName('access_token');
    

Request Token Direct

  1. Make a post to /Token with the following data
    {
    grant_type: 'password',
    username: loginName,
    password:password
    }
  2. Correct login details will result in a successful response which will contain a access_token property
  3. Save this token for later use

Data Formats

We support both XML and JSON request/response formats. Make sure to supply the correct accept header when making your request. Json is the default data format.

Making your first call

Once you have your bearer token, you are ready to make your first call to the API.

  1. First, create an object which will contain the bearer token authorization header. var headers = {};
  2. Then set the Authorization header to be "Bearer " + your token headers.Authorization = 'Bearer ' + token;
  3. You are now ready to make an ajax request to the API. Here is an example using the popular jQuery library
    $.ajax({
    type: 'GET',
    url: 'https://api.expirify.com/api/Domain',
    headers: headers
    }).done(function (data) {
    console.log(data);
    }).fail(console.log);