The API function in the Javascript SDK makes it easy to call Oauth based APIs. By using it, auth tokens will be handled automatically. To make a API call, an Y8 Account user must first be logged in.

Alternately, if you need to access an Y8 Account API for a guest, there is the apiGuest function.

See the API reference for a list of calls available.

Arguments

ID.api('API url', 'METHOD', arguments, callback);

Or

ID.apiGuest('API url', 'METHOD', arguments, callback);
  • Url is everything after https://account.y8.com/api/v1/json/
  • Method is usually POST or GET
  • The argument is usually null but can be a JS object. Ex. {key: value}
  • Callback function with response argument

Example

<script type="text/javascript">
ID.api('links/pending', 'GET', null, function(response){
    console.log(response);
});
</script>