Skip to the content.

Flipkart Scraper API

API to scrape search results and product details from Flipkart

Disclaimer: I am not affiliated or linked to flipkart in any way. This repository is an exploratory project and not meant for commercial use.

Flipkart API Banner

Version GitHub license GitHub issues Telegram

Table of Contents


Features

Note

Deprecation of hosted API

This API is being shipped only as a Docker image now and not as a hosted URL, due to over-exploitation of the API and lack of funds & free-tier limitations. The hosted API URL has been taken down. Check out Deployement

The API has been rewritten in Rust. With this process, a multitude of unexpected errors have been addressed with improved accuracy and better scraping mechanism. Refer issue #13 and Refer issue #12.


API Reference

Search Item

  GET /search/${product_name}
Parameter Type Description
product_name string Required. Name of product to search

The response will be given in following JSON format :

{
  "total_result": int,
  "query": String,
  "fetch_from": String,
  "result": [
    "name": String,
    "link": String,
    "current_price": int | null,
    "original_price": int | null,
    "discounted": boolean,
    "thumbnail": String,
    "query_url": String,
  ]
}

Link argument of a product will be URL of Flipkart product after removing the https://www.flipkart.com/ or any other similar component from it.

Product Details

  GET /product/${product_link_argument}
Parameter Type Description
product_link_argument string Required. Product link without https://www.flipkart.com/

The response will be given in following JSON format :

{
  "name": String | null,
  "current_price": int | null,
  "original_price": int | null,
  "discounted": boolean,
  "discount_percent": int | null,
  "rating": float | null,
  "in_stock": boolean,
  "f-assured": boolean,
  "share_url": String,
  "seller": {
    "seller_name": String,
    "seller_rating": float | null
  } | null,
  "thumbnails": [ String ],
  "highlights": [ String ],
  "offers": [
    {
      "offer_type": String | null,
      "description": String
    }
  ]
  "specs": [
    {
      "title": String
      "details": [
        {
          "property": String,
          "value": String
        }
      ]
    }
  ]
}

Increasing Resolution of Image

You can increase the resolution of image by changing certain parameters in the thumbnail link.

For example, in the link :

https://rukminim2.flixcart.com/image/312/312/kzfvzww0/computer/r/g/i/hp-laptop-15s-eq2144au-amd-ryzen-5-5500u-8gb-ddr4-512-gb-pcie-original-imagbg5jctdf4xwf.jpeg?q=70

The 312/312 describes the resolution. Just change it to 1024/1024 for product image.

https://rukminim2.flixcart.com/image/1024/1024/kzfvzww0/computer/r/g/i/hp-laptop-15s-eq2144au-amd-ryzen-5-5500u-8gb-ddr4-512-gb-pcie-original-imagbg5jctdf4xwf.jpeg?q=70

Deployment

Deploy using Docker

Using Cargo

If you have Cargo installed on your system, you can compile and run the code on your system.


Error Handling

In case of any error you will receive an error message in the following format :

{
  "error": "ERROR MESSAGE",
}

Note : In case the API can’t find Product URL or Name of Product, it will be set to null. Hence always null check the result. Refer datatypes of the JSON response

If you are facing unexpected results then Raise An Issue


Migration from JS to Rust

The API was previously written in Javascript, which had a lot of error and exceptions and the error handling was used to control the “Control Flow” of the program. The same resulted in a complex work and data flow and a difficult to maintain source code.

Hence decision was made to rewrite the API in Rust in a better approach to avoid running into issue and at the same time perform better with more accuracy and less “hacks”. The types are also now guaranteed to match as specified in the documentation. One can always refer to the javascript builds in the previous commits.

Also decision to remove the hosted API was taken. API is now only available for self-hosting. Refer issues #12 and #13.