What's this?

Flipkart recently launched a Product Feeds API (still in beta). There isn't any official wrappers for PHP (yet?) - so we built one. The code is free and open-source, and is available on GitHub.

This demo shows an example of how you can use the API to retrieve product details directly from Flipkart, and display them.

View the Demo View on GitHub

Behind the scenes

Flipkart API seemed difficult to use, probably because it is still in beta. Here's a quick overview of how it works (at the time this is written):

  1. Obtain an affiliate id and access token from the Flipkart Affiliates website.
  2. Use your affiliate id in a standard url to view the API homepage that contain custom links through which you can view products in different categories. The standard url is of the format https://affiliate-api.flipkart.net/affiliate/api/<affiliate-id>.<json/xml>
  3. The response will contain API urls for different categories that can be used to obtain product details. These urls require HTTP authentication headers (your affiliate-id and access token) in the GET request. A sample request should look something like this:
    GET /affiliate/feeds/...?expiresAt=1408599587245&sig=f6be93ff1b2 HTTP/1.1
    Host: affiliate-api.flipkart.net
    Fk-Affiliate-Id: <affiliate-id>
    Fk-Affiliate-Token: <access-code>
  4. The response will contain details of 50 products in the selected category. Even out-of-stock and discontinued items are displayed, and the API does not provide an option to sort the list or to exclude unnecessary items.
  5. To retrieve the next 50 items, the nextUrl link in the previous response should be used. If you need to use the data in a meaningful way, you'll need to save the entire data into a database, and take care of syncing the changes frequently.

Thoughts

The API is not very useful in its current form unless you plan to scrape the entire thing, store the data and write code to format it. We can expect Flipkart to improve/rebuild the API before long - that would help reduce scraping of their website for product details.

If you'd like to get in touch, shoot me an email: [saneem][at][clusterdev][dot][com]. Please do not email me if your code doesn't work (as long as the demo works, the code is all good). If there are real problems, open an issue on GitHub.