Quick code samples

Take a quick look at these code samples to give you a head start on creating your applications.

To view code samples for individual APIs, or  , and run a test for our APIs.

 

Here are some code samples to give you a head start creating your applications.   

Javascript Sample Code

//For GET request
var xhr = new XMLHttpRequest();

var url = 'https://<api_endpoint>/';

var queryParams = '?' +  encodeURIComponent('apikey') + '=' + encodeURIComponent('<your_api_key>');

xhr.open('GET', url + queryParams);

xhr.onreadystatechange = function () {

    if (this.readyState == 4) {

        alert('Status: '+this.status+'\nHeaders: '+JSON.stringify(this.getAllResponseHeaders())+'\nBody: '+this.responseText);

    }

};



xhr.send('')

//For POST request 
var xhr = new XMLHttpRequest();

var url = '<api_endpoint>';

var queryParams = '?' +  encodeURIComponent('apikey') + '=' + encodeURIComponent('<your_api_key>');

xhr.open('POST', url + queryParams);

xhr.setRequestHeader('<requestheader1>', '<requestheader1.value>');
//.... multiple headers

xhr.setRequestHeader('Content-Type', 'application/json;charset=utf-8');

xhr.onreadystatechange = function () {

    if (this.readyState == 4) {

        alert('Status: '+this.status+'\nHeaders: '+JSON.stringify(this.getAllResponseHeaders())+'\nBody: '+this.responseText);

    }

};

xhr.send('<request_data_in_json_format>');