All guides

Mumbai's petrol price premium over Delhi since 2017

Tutorial · 4 min read · Published 2026-10-24

Compute Mumbai's petrol premium over Delhi in JavaScript: 11.22 rupees in June 2017, a low of 5.05 in 2020 and a high of 15.10 in 2022.

One request, all four cities

Leave out city and the API returns all four metros on every row. This request asks for petrol from the first day of the series to the end of 2025:

curl
curl "https://india-petroleum-api.vercel.app/v1/prices?fuel=petrol&from=2017-06-16&to=2025-12-31"

It returns 3,121 rows and about 300 KB of JSON. Responses are cached, but for a dashboard that needs only recent data, narrow the range.

Compute the gap

JavaScript
const url = 'https://india-petroleum-api.vercel.app/v1/prices?fuel=petrol&from=2017-06-16&to=2025-12-31';
const { data } = await (await fetch(url)).json();
const gaps = data.map((row) => ({
  date: row.date,
  gap: +(row.petrol.mumbai - row.petrol.delhi).toFixed(2),
}));
const low = gaps.reduce((a, b) => (b.gap < a.gap ? b : a));
const high = gaps.reduce((a, b) => (b.gap > a.gap ? b : a));
console.log(gaps[0], low, high);
// { date: '2017-06-16', gap: 11.22 } { date: '2020-05-05', gap: 5.05 } { date: '2022-04-06', gap: 15.1 }

The + in front of toFixed turns the string back into a number, which also drops a trailing zero, so 15.10 prints as 15.1. When two days tie, reduce as written keeps the earlier one.

What the numbers say

On 16 June 2017 a litre of petrol cost 11.22 rupees more in Mumbai than in Delhi (76.70 against 65.48). The gap fell to 5.05 on 5 May 2020 and stayed there until 31 May 2020. It rose to 15.10 on 6 April 2022 and stayed there until 21 May 2022. On 23 October 2026 it was 9.09 (111.21 against 102.12).

The table does not say why the gap moves. Both figures are PPAC's published price for the day, and the API does not model how they are built up.

Use it in your app

Try other cities and fuels in the playground, and keep the attribution from meta.attribution next to anything you display. The first guide explains what each date and figure means.