Daily Fuel Price API is designed to be accessible and useful for shipping, transport and travel companies to estimate the fuel costs incurred for a trip, by providing accurate prices for Petrol, Diesel, CNG and LPG prices for 720+* cities in India. All of the fuel prices are updated daily based on the market rate in any of the Indian cities. Moreover, the API is flexible and designed for variety of use cases - for business and personal uses.
This tutorial is organised as a cookbook and you may use this as a reference on ‘how-to’ achieve an implementation. If you have any questions, please let us know in the discussion or contact us to know/consult on your unique use case, and we’ll try to provide the best of our support
The endpoint for getting the fuel price for the day in a state - StateFuelPriceToday
needs a stateId
while for a city - CityFuelPriceToday
needs a stateId
& cityId
stateId
, first query the ListStates
endpoint to get the list of states in India# get list of states in India
GET https://daily-petrol-diesel-lpg-cng-fuel-prices-in-india.p.rapidapi.com/v1/list/india/states
Then, use the stateId
(eg. maharashtra
for ‘Maharashtra’) to query the StateFuelPriceToday
endpoint to get the fuel price
# get fuel price today in a state
GET https://daily-petrol-diesel-lpg-cng-fuel-prices-in-india.p.rapidapi.com/v1/fuel-prices/today/india/{stateId}
stateId
from the above response and use it to query the list of cities - ListCities
to find the cityId
(eg. greater-mumbai
for ‘Greater Mumbai’)# get list of cities in a state
GET https://daily-petrol-diesel-lpg-cng-fuel-prices-in-india.p.rapidapi.com/v1/list/india/{stateId}/cities
Then, use the stateId
& cityId
to query the CityFuelPriceToday
endpoint to get the fuel price
# get fuel price today in a city
GET https://daily-petrol-diesel-lpg-cng-fuel-prices-in-india.p.rapidapi.com/v1/fuel-prices/today/india/{stateId}/{cityId}
Currently, though the Petrol & Diesel prices are available for all 720+ cities in India, we were not able to get the prices for LPG & CNG for all the cities. To avoid trial & errors, you can pass the optional fuelTypes
- array query parameters for the ListStates
& ListCities
API to filter the list of states & cities respectively containing only those fuel types.
# filter list of states based on availability of fuel prices for 'cng' & 'lpg'
GET https://daily-petrol-diesel-lpg-cng-fuel-prices-in-india.p.rapidapi.com/v1/list/india/states?fuelTypes=cng,lpg
# filter list of cities in a state based on availability of fuel prices for 'cng & 'lpg'
GET https://daily-petrol-diesel-lpg-cng-fuel-prices-in-india.p.rapidapi.com/v1/list/india/{stateId}/cities?fuelTypes=cng,lpg
The APIs - StateFuelPriceOnDate
& CityFuelPriceOnDate
can be used to get the fuel price for any state or city on a past date in last 30 days, and are very similar to the StateFuelPriceToday
& CityFuelPriceToday
APIs, i.e. they need stateId
& cityId
which can be found via the ListStates
& ListCities
endpoints explained in point 1.
In addition, a path parameter isoDate
is required which is any date in past 30 days confirming to ISO 8601 standard i.e. YYYY-MM-DD
format - for eg. 7th August 2022 may be written as 2022-08-07
# get fuel price on a past date in a city
GET https://daily-petrol-diesel-lpg-cng-fuel-prices-in-india.p.rapidapi.com/v1/fuel-prices/{isoDate}/india/{stateId}/{cityId}
# get fuel price on a past date in a state
GET https://daily-petrol-diesel-lpg-cng-fuel-prices-in-india.p.rapidapi.com/v1/fuel-prices/{isoDate}/india/{stateId}
To get the aggregated fuel prices in all states in India or for all cities in a state, the APIs AllStatesFuelPriceToday
, AllCitiesFuelPriceToday
for today or AllStatesFuelPriceOnDate
, AllCitiesFuelPriceOnDate
for a past date. This API is convenient, if you’d like to query fuel prices for many cities or states
# get fuel prices today in all states
GET https://daily-petrol-diesel-lpg-cng-fuel-prices-in-india.p.rapidapi.com/v1/fuel-prices/today/india/states
# get fuel prices today in all cities in a state
GET https://daily-petrol-diesel-lpg-cng-fuel-prices-in-india.p.rapidapi.com/v1/fuel-prices/today/india/{stateId}/cities
# get fuel prices on a past date in all states
GET https://daily-petrol-diesel-lpg-cng-fuel-prices-in-india.p.rapidapi.com/v1/fuel-prices/{isoDate}/india/states
# get fuel prices on a past date in all cities in a state
GET https://daily-petrol-diesel-lpg-cng-fuel-prices-in-india.p.rapidapi.com/v1/fuel-prices/{isoDate}/india/{stateId}/cities
To get the sorted list of cities where the prices are the highest or lowest, for a given fuel type. This is useful for some planning scenarios, to find the cities with highest or lowest diesel prices for example. The APIs - HighestFuelPriceCitiesToday
, LowestFuelPriceCitiesToday
for today, HighestFuelPriceCitiesOnDate
& LowestFuelPriceCitiesOnDate
for a past date - gets the highest and lowest prices for a fuel type
# get the list of top 5 cities with highest diesel prices today
GET https://daily-petrol-diesel-lpg-cng-fuel-prices-in-india.p.rapidapi.com/v1/fuel-prices/highest/diesel/today/india/cities?limit=5
# get the list of top 10 cities with lowest LPG prices today
GET https://daily-petrol-diesel-lpg-cng-fuel-prices-in-india.p.rapidapi.com/v1/fuel-prices/lowest/lpg/today/india/cities?limit=10
# get the list of top 5 cities with highest diesel prices on a past date
GET https://daily-petrol-diesel-lpg-cng-fuel-prices-in-india.p.rapidapi.com/v1/fuel-prices/highest/diesel/{isoDate}/india/cities?limit=5
# get the list of top 10 cities with lowest LPG prices on a past date
GET https://daily-petrol-diesel-lpg-cng-fuel-prices-in-india.p.rapidapi.com/v1/fuel-prices/lowest/lpg/{isoDate}/india/cities?limit=10
To analyze the fuel price trend in any city or state, it may be beneficial to get the fuel prices for last 30 days and then certain insights may be deduced out of the values. The API - StateFuelPriceHistory
& CityFuelPriceHistory
which gets upto 30 days fuel prices in a state or city respectively
# get the 30 day price history in a state
GET https://daily-petrol-diesel-lpg-cng-fuel-prices-in-india.p.rapidapi.com/v1/fuel-prices/history/india/{stateId}
# get the 30 day price history in a city
GET https://daily-petrol-diesel-lpg-cng-fuel-prices-in-india.p.rapidapi.com/v1/fuel-prices/history/india/{stateId}/{cityId}