Calculate your fuel surcharge from the EIA weekly diesel index
Changed onApplies 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.
Request
- Base URLhttps://api.oilpriceapi.com
- AuthAPI key in header Authorization
Query parameters
Diesel price (USD/gallon) already built into your base rate.
percent returns surcharge_percent per week; per_mile returns surcharge_per_mile in USD per mile. Case-insensitive; defaults to percent.
Required for percent. Diesel price step (USD/gallon) per surcharge step, at least 0.001. Plain decimals only.
Required for percent. Surcharge percentage points added per step.
floor counts completed steps only; ceil counts a partial step; exact applies no banding.
Required for per_mile. Fleet fuel economy in miles per gallon, at least 1.
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.
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
Example response
{
"status": "success",
"data": {
"commodity_code": "DIESEL_RETAIL_USD"
}
}Changes
- info
endpoint added
- info