How to access Flipkart Affiliate API using JavaScript

CodeGuy
March 02, 2016

Flipkart affiliate API enables the developers to work with the various API frameworks, such as Offer, Product Feed, and Order Report etc. You are sometimes compelled to implement using js. For the below code snippet, issues like CORS must be addressed. The same-origin policy permits scripts running in a browser to only make requests to pages on the same domain. Hence js Implementations in browser extensions or webviews may prove successful.
This API allows you to get the title(s) in complete offers list (JSON implementation). Make necessary substitutions <...> wherever necessary.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
$(document).ready(function() {
    $.ajax({
        type: 'GET',
        url: "https://affiliate-api.flipkart.net/affiliate/offers/v1/all/json",
        dataType: "json",
        xhrFields: {
            withCredentials: false
        },
        headers: {
            'Fk-Affiliate-Id': '',
            'Fk-Affiliate-Token': '',
            'Content-Type': 'application/json'
        },
        success: function(data) {
            for (i = 0; i < data.allOffersList.length; i++)
                alert(data.allOffersList[i].title);
        },
    }); //end ajax
});

0 comments

Do not spam.

Like us on Facebook

Blog Archive