Fuel Surcharge

Calculate your fuel surcharge from the EIA weekly diesel index

Changed on

Applies your own surcharge schedule to the stored EIA (DOE) weekly retail on-highway diesel series and returns the result for the latest week plus a weekly table, newest first. Two methods: percent (surcharge % = completed increments over base x percent per increment) and per_mile ((diesel - base) / mpg, USD per mile). Diesel at or below the base price is a 0 surcharge. Each week carries its EIA week date and retrieval time. A region with no stored week returns 404.

get/v1/fuel-surcharge/calculate

Request

  • Base URL
    https://api.oilpriceapi.com
  • Auth
    API key in header Authorization

Query parameters

base_pricenumber required
Example:1.25

Diesel price (USD/gallon) already built into your base rate.

method'percent' | 'per_mile'
Example:percent

percent returns surcharge_percent per week; per_mile returns surcharge_per_mile in USD per mile. Case-insensitive; defaults to percent.

incrementnumber
Example:0.05

Required for percent. Diesel price step (USD/gallon) per surcharge step, at least 0.001. Plain decimals only.

percent_per_incrementnumber
Example:1

Required for percent. Surcharge percentage points added per step.

rounding'floor' | 'ceil' | 'exact'
Example:floor

floor counts completed steps only; ceil counts a partial step; exact applies no banding.

mpgnumber
Example:6.5

Required for per_mile. Fleet fuel economy in miles per gallon, at least 1.

region'national' | 'east-coast' | 'midwest' | 'gulf-coast' | 'rocky-mountain' | 'west-coast' | 'california'
Example:national

EIA weekly retail diesel region. national is the U.S. average (DIESEL_RETAIL_USD); the others are the EIA PADD regions plus California. Case-insensitive; defaults to national.

weeksinteger
Example:4

Number of most recent EIA weeks in the weeks table, newest first, 1 to 52. Defaults to 4.

Response

Surcharge for the latest EIA week and the weekly table

statusstring

Example response

{
  "status": "success",
  "data": {
    "commodity_code": "DIESEL_RETAIL_USD"
  }
}

Changes