How to Build a Fuel Price Monitoring App with Live Oil Prices (2026 Guide)

By

Ejaz Ahmed

22 Oct 2026 • 5 min read

Oil Price API: Build a Fuel Monitoring App

Imagine you run a fleet of delivery trucks. Overnight, crude jumps 15% and diesel follows a few days later. If you only find out when the fuel card bill arrives, the margin on every delivery that week is already gone.

Logistics companies, fuel resellers and independent traders all have the same problem: by the time a price move shows up in the news, it has already hit their costs. In this guide you'll build a small fuel price monitoring app in Python that watches crude oil in real time, keeps a year of history and tells you when prices move. It runs on our oil price API, which serves WTI and Brent crude — spot and front-month futures — with bid and ask.

What you'll build

  • A script that fetches the live WTI and Brent price, with bid and ask.
  • A one-call snapshot of oil alongside natural gas, gasoline and heating oil.
  • A daily price history you can chart or export.
  • A simple alert that fires when the price moves more than a threshold.

Step 1: Get an API key

Create an account at CommodityPriceAPI. Every account starts with a 7-day free trial on the Lite plan — 2,000 requests, no credit card — and you can extend the trial up to a month. Your key is in the dashboard, along with your request usage.

Two plan details matter for a fuel app:

  • Lite returns prices in USD, may be up to 10 minutes old and allows 10 requests per minute.
  • Plus, Premium and Enterprise read the oil prices every second and can convert them into 150+ currencies with the quote parameter.

Step 2: Pick your oil symbols

There are four crude oil symbols, all quoted in US dollars per barrel:

SymbolWhat it tracks
WTIOIL-SPOTWTI crude, continuous cash (spot) price
WTIOIL-FUTWTI crude, NYMEX front-month futures, continuous
BRENTOIL-SPOTBrent crude, continuous cash (spot) price
BRENTOIL-FUTBrent crude, ICE front-month futures, continuous

For a monitoring app, start with the spot symbols. They have no expiry date, so the line never jumps when a futures contract changes. Use the -FUT symbols when your numbers have to match futures quotes or hedging reports. US fleets usually watch WTI; Europe, Africa and most of Asia price off Brent.

Step 3: Fetch the live price

Each oil symbol has its own per-second endpoint, /v3/rates/latest/{symbol}, which returns the price with bid and ask. Send your key in the x-api-key header and keep it in an environment variable, not in the code.

import os
import requests

API = "https://api.commoditypriceapi.com/v3"
HEADERS = {"x-api-key": os.environ["COMMODITY_API_KEY"]}


def latest(symbol: str) -> dict:
    """Latest price for one oil symbol, with bid and ask."""
    res = requests.get(f"{API}/rates/latest/{symbol}", headers=HEADERS, timeout=10)
    res.raise_for_status()
    body = res.json()
    return body["rates"][symbol] | body["metadata"][symbol]


if __name__ == "__main__":
    for symbol in ("WTIOIL-SPOT", "BRENTOIL-SPOT"):
        p = latest(symbol)
        print(f"{symbol:14} {p['rate']:>8.2f} {p['quote']}/{p['unit']}  "
              f"bid {p['bid']:.2f}  ask {p['ask']:.2f}")

Output (your numbers will differ):

WTIOIL-SPOT       93.39 USD/Bbl  bid 93.37  ask 93.41
BRENTOIL-SPOT    105.41 USD/Bbl  bid 105.39  ask 105.43

Add params={"quote": "EUR"} to the request on Plus or above, and the same call returns the price per barrel in euros.

Step 4: Oil and refined products in one call

Fuel costs don't follow crude alone. The multi-symbol endpoint, /v3/rates/latest?symbols=, returns several commodities at once — useful for a dashboard that shows crude next to natural gas, RBOB gasoline and heating oil:

res = requests.get(
    f"{API}/rates/latest",
    headers=HEADERS,
    params={"symbols": "WTIOIL-SPOT,BRENTOIL-SPOT,NG-FUT,RB-SPOT,HO-SPOT"},
    timeout=10,
)
for symbol, rate in res.json()["rates"].items():
    print(symbol, rate)

This endpoint returns one number per symbol; the per-second endpoint in step 3 adds bid and ask.

Step 5: Add price history

Trends matter more than a single number. The time-series endpoint returns daily open, high, low and close between two dates, up to 365 days per request, and the history goes back to 1990:

res = requests.get(
    f"{API}/rates/time-series",
    headers=HEADERS,
    params={"symbols": "WTIOIL-SPOT", "startDate": "2025-10-01", "endDate": "2026-09-30"},
    timeout=30,
)
closes = {day: r["WTIOIL-SPOT"]["close"] for day, r in res.json()["rates"].items()}

Plot closes with any charting library, or write it to CSV for the finance team. For a quick look without code, the live WTI price chart shows the last year.

Step 6: Alert when the price moves

The last piece turns data into a decision. Keep the price from your previous check and alert when the change passes a threshold:

THRESHOLD = 0.03  # 3%

def check(previous: float, symbol: str = "WTIOIL-SPOT") -> float:
    now = latest(symbol)["rate"]
    change = (now - previous) / previous
    if abs(change) >= THRESHOLD:
        print(f"ALERT: {symbol} moved {change:+.1%} to {now:.2f}")  # send email/Slack here
    return now

Run check on a schedule — every minute is plenty for fuel planning — and store the result between runs. If you want the API to do the maths, the fluctuation endpoint returns the absolute and percentage change between two dates.

Security and reliability tips

  • Keep the key on your server. Mobile and browser apps should call your own backend, which calls the API, so the key never ships to users.
  • Read the key from an environment variable or a secrets manager, never from source control.
  • Cache responses for as long as your plan's update interval. Calling more often returns the same price and uses quota.
  • Check the HTTP status before parsing, and handle 429 (rate limit) by backing off.

FAQs

Is there a free oil price API?

There's no permanent free plan, but every account starts with a 7-day free trial on the Lite plan — 2,000 requests, no credit card — and the trial can be extended up to a month.

How often are oil prices updated?

The four oil symbols are read every second. On Plus, Premium and Enterprise each request returns the newest price; on Lite it can be up to 10 minutes old.

Which symbol should I use for crude oil?

Use WTIOIL-SPOT or BRENTOIL-SPOT for a smooth live price, and WTIOIL-FUT or BRENTOIL-FUT when you need the front-month futures price. See the spot vs futures guide.

Can I get oil prices in other currencies?

Yes. On Plus or above, add quote=EUR (or any of 150+ supported currencies) and the price per barrel comes back converted.

How far back does the history go?

Daily WTI and Brent history goes back to 1990, through the historical, time-series and fluctuation endpoints.

Is this the official benchmark price?

No. The API returns derived market prices with bid and ask. They are not exchange settlement prices or official assessments such as Dated Brent.

Wrap-up

With four requests — latest price, a multi-symbol snapshot, a year of history and a threshold check — you have a working fuel price monitor. From here, add a chart, push alerts to Slack, or quote prices in your customers' currency. The API documentation covers every endpoint, and you can start on the free trial today.

CommodityPriceAPI
Simple, Fast and Reliable

Get real-time commodity prices data for oil, gold, silver, corn, wheat, natural gas and more.