apyhub
Back
▣ VERIFICATION KIT

US Gasoline & Diesel Prices API

What it does

The US gasoline and diesel prices API returns fuel price data for US areas in one request. Send mode to choose latest prices, history, trip cost, or a covered areas list. You can also send areas, fuels, limit, sort, startDate, endDate, interval, distanceKm, distanceMiles, mpg, or litersPer100km when the mode needs them.

Use latest for the newest weekly price in each area and fuel. It can also sort by area, cheapest first, most expensive first, or biggest weekly rise. Use history for weekly data or monthly and yearly averages between your dates. Use trip to estimate fuel cost from distance and fuel economy.

The response gives a row count, billed units, and an item list. Each row can include the area name and type, fuel name, week, price in USD per gallon, 52-week high and low, weekly and yearly change, past prices, release dates, and a source link.

Teams use the US gasoline and diesel prices API to show live fuel prices in dashboards and compare states or cities. They also use it to estimate route cost before dispatch and to build fuel price charts for planning.

To convert fuel costs into other money units, use the Currency Converter API. To match prices with country data, use the Country Information API.

POST
Gas Prices API - US Gasoline & Diesel by State, Weekly History
https://api.eu.apyhub.com/martin10291/us-gasoline-diesel-prices

QUICKSTART

GUIDE

Quickstart

Get the latest U.S. gas prices for the default fuel and area settings with a single POST request.

curl -X POST "https://api.eu.apyhub.com/martin10291/us-gasoline-diesel-prices" \
  -H "apy-token: $APY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"mode":"latest"}'

What you'll get back

Returns a JSON object with billed and count integers, plus an items array of result objects.

Each item can include fields such as area, fuel, unit, week, price, and other price-change metadata depending on the mode.

{
  "billed": 1,
  "count": 1,
  "items": [
    {
      "area": "US",
      "fuel": "regular",
      "unit": "USD/gallon",
      "week": "2026-11-16",
      "price": 3.49
    }
  ]
}
TRY ITLIVE · 100 ATOMS
Loading your default key…
The full key is used to call the gateway and stays in this tab — never sent to orbit or saved.
body
trip mode: vehicle fuel economy in US mpg. Default 25 when litersPer100km is also empty.
latest = newest weekly price per area and fuel with weekly/yearly change and 52-week high/low; history = price series between startDate and endDate (weekly, or monthly/yearly averages); trip = fuel cost of a trip from distance and fuel economy at the current local price; areas = list of covered.
latest mode: area order (default), cheapest first, most expensive first, or biggest weekly rise first.

About this endpoint

What it does

Returns US gasoline and diesel price data by area in a JSON object. Depending on mode, the response can contain the latest weekly prices, historical price series, trip cost calculations, or the list of covered areas.

Request Body

ParameterTypeMandatoryDescription
mpgNumberNoTrip mode: vehicle fuel economy in US mpg. Default 25 when litersPer100km is also empty.
modeENUMNoAllowed values: latest, history, trip, areas.
latest = newest weekly price per area and fuel with weekly/yearly change and 52-week high/low.
history = price series between startDate and endDate (weekly, or monthly/yearly averages).
trip = fuel cost of a trip from distance and fuel economy at the current local price.
areas = list of covered.
sortENUMNoAllowed values: area, priceAsc, priceDesc, changeWeek.
latest mode only: area order (default), cheapest first, most expensive first, or biggest weekly rise first.
areasString ArrayNoUS, PADD1..PADD5 (East Coast, Midwest, Gulf Coast, Rocky Mountain, West Coast), PADD1A/1B/1C, PADD5XCA, states CA CO FL MA MN NY OH TX WA, cities BOS CHI CLE DEN HOU LAX MIA NYC SFO SEA, or names like California / New York City. all = every area. Max 100 items.
fuelsString ArrayNoregular, midgrade, premium, allGrades, diesel (all = every fuel). Empty = regular + diesel for latest, regular for history and trip. Diesel is published for US, PADD regions, CA and PADD5XCA. Max 100 items.
limitIntegerNoMaximum rows returned. Default 1000. Allowed range: 1-20000.
endDateStringNohistory mode: last week, YYYY-MM-DD. Default latest.
intervalENUMNoAllowed values: weekly, monthly, yearly.
history mode: weekly survey values, or monthly / yearly averages of the weekly values.
startDateStringNohistory mode: first week, YYYY-MM-DD (or YYYY / YYYY-MM). Default one year ago. Gasoline from 1990/1994, diesel from 1994.
distanceKmNumberNotrip mode: trip distance in kilometers (used when distanceMiles is empty).
distanceMilesNumberNotrip mode: trip distance in miles (or use distanceKm).
litersPer100kmNumberNotrip mode: fuel economy in L/100 km (used when mpg is empty).

Response

Returns a JSON object with billed as an integer, count as an integer, and items as an array of result objects. Each item can include area and fuel identifiers plus pricing, change, history, and trip-related fields depending on the selected mode.

ParameterTypeMandatoryDescription
billedIntegerYesUnits charged for this call: result rows only; not-found / unavailable / invalid rows are free.
countIntegerYesNumber of rows in items.
itemsObject ArrayYesResult rows. Each object may include the following fields.
items[].areaStringNoUS, PADD1..PADD5, PADD1A/1B/1C, PADD5XCA, state (CA, TX...) or city (NYC, LAX...).
items[].fuelStringNoregular, midgrade, premium, allGrades or diesel.
items[].unitStringNoUnit used in the row.
items[].weekStringNoEIA survey Monday, YYYY-MM-DD.
items[].priceNumberNoUSD per gallon, retail incl. taxes.
items[].stateStringNoNullable string.
items[].low52wNumberNo52-week low price.
items[].sourceStringNoData source.
items[].high52wNumberNo52-week high price.
items[].areaNameStringNoArea name.
items[].areaTypeStringNonational, region, state or city.
items[].fuelNameStringNoFuel name.
items[].sourceUrlStringNoSource URL.
items[].changeWeekNumberNoWeek-over-week change.
items[].changeYearNumberNoYear-over-year change.
items[].vsNationalNumberNoNullable comparison against the national price.
items[].historyFromStringNoHistory start reference.
items[].releaseDateStringNoRelease date.
items[].tripCostUsdNumberNoTrip mode only.
items[].yearAgoPriceNumberNoPrice from one year ago.
items[].changeWeekPctNumberNoWeek-over-week percentage change.
items[].changeYearPctNumberNoYear-over-year percentage change.
items[].nextReleaseDateStringNoNext scheduled release date.
items[].previousWeekPriceNumberNoPrice from the previous week.
▣ COMMON ERRORS

Errors any endpoint can return

400bad_request

Required parameter missing or malformed body.

401unauthorized

API key missing, revoked, or not authorized for this service.

429rate_limited

Your plan's per-second rate exceeded. Retry with exponential backoff.

503upstream_busy

Backend temporarily unavailable. Try again in a few seconds.