Daily Petrol, Diesel, LPG & CNG Fuel Prices in India

부분 유료
분류별 mi8y | 업데이트됨 a month ago | Energy
인기

9.6 / 10

지연 시간

547ms

서비스 수준

100%

Health Check

N/A

모든 자습서로 돌아가기 (1)

Various use cases and steps to integrate Daily Fuel Prices API

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

1. Get the price of a fuel in a city or a state today

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

  1. To find the 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}
  1. Or to get the fuel price in a city, find the 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}

2. Find the list of states or cities containing prices for a certain fuel type(s)

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

3. Fuel price in a state or a city on a past date (within last 30 days)

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}

4. Get the fuel prices in all cities in a state or for all states for today or any past date

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

5. Get the list of cities in India, where the fuel price is highest or lowest today or on a past date

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

6. Get the 30 day fuel price history for any city or state

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}

Notes:

  1. The fuel prices in a state are an average of corresponding fuel prices in all the cities in the same state.