Home → Blog

If you price freight lanes or budget fuel surcharges in the Midwest, you need a concrete, reproducible way to retrieve the EIA-derived “Midwest Diesel” benchmark and wire it into your finance stack. By the end of this guide you will be able to query FreightPulse for the Midwest Diesel metric, parse the response that wraps EIA data, and integrate it into your pricing, forecasting, or reconciliation code with clear handling of units, timestamps, and caching.

What you will build

You will make a simple, dependable integration against FreightPulse’s fuel endpoint that returns the EIA-sourced Midwest Diesel price. We will cover:

Illustration: Midwest Diesel Price API

Access, authentication, and envelope

Keep these integration facts at hand; they will save you time during testing and deployment:

If you need an API key, create one via Register. Reference parameters and schema anytime in the Documentation.

The Midwest Diesel metric and units you should expect

The “Midwest Diesel” metric reflects the EIA diesel retail price level for the Midwest region and is served in United States dollars per gallon. In responses where the pricing block is present, the base currency is USD and the unit is gallon. Treat all monetary outputs as floats in USD; do not mix them with other currencies or liters.

FreightPulse wraps these values in a stable, top-level envelope with success and data keys. Always check the success flag before dereferencing nested fields. For finance-grade extracts you should also record the top-level timestamp (ISO-8601, typically UTC with an explicit offset) so you can reproduce downstream calculations and audit how fresh a price was when it entered a ledger or planning model.

Official sample for fuel prices (copy-paste ready)

The following live sample shows the authentication header, path, and a representative JSON payload. Use this to scaffold your parser and verify fields and units in tests:

cURL:

curl -H "X-API-Key: YOUR_API_KEY" "https://freightpulsehq.com/api/v1/historical?metric=fuel_price_diesel_midwest&period=30d"

JSON:

{
"success": true,
"data": {
"timestamp": "2026-10-02T12:00:34+00:00",
"source": "EIA (U.S. Energy Information Administration)",
"currency": "USD",
"unit": "gallon",
"data": {
"diesel": {
"national_average": 6.382,
"change_week": -0.147,
"change_percent": -2.25,
"updated_at": "2026-09-28",
"regions": {
"east_coast": 6.137,
"midwest": 6.526,
"gulf_coast": 5.955,
"rocky_mountain": 6.407,
"west_coast": 7.357,
"california": 8.181
}
},
"gasoline": {
"national_average": 4.465,
"change_week": -0.013,
"change_percent": -0.29,
"updated_at": "2026-09-28",
"grades": {
"regular": 4.465,
"midgrade": 5.073,
"premium": 5.482
}
},
"bunker_fuel": {
"available": false,
"note": "No known free source (Rotterdam/Singapore/Houston) — requires a paid provider (e.g. Ship & Bunker, Argus)."
}
},
"historical": {
"diesel_30d_avg": 6.291,
"diesel_90d_avg": 5.561,
"diesel_yoy_change": 72,
"gasoline_30d_avg": 4.355,
"gasoline_90d_avg": 4.111,
"gasoline_yoy_change": 42.9
}
},
"meta": {
"request_id": "52112c12-9cba-475b-b45c-7c4176d43f0b"
}
}

Fields you will typically consume for finance calculations:

Requesting the “Midwest Diesel” series for finance workflows

For budgeting or accrual rollforward you often want a dated series you can sum, average, or join to GL periods. FreightPulse exposes the Midwest Diesel metric via a historical endpoint keyed by metric=fuel_price_diesel_midwest. Note: No official historical series is published for fuel_price_diesel_midwest. You can still call the endpoint and read series[].value when present; build your parser to degrade gracefully if series is missing and fall back to the latest point-in-time level from data.data.diesel.regions.midwest.

Copy-pasteable request:

Parsing guidance:

Python example: fetch and read series[].value for Midwest Diesel

The snippet below calls the same endpoint as the cURL above and safely reads either a dated series or a single Midwest point with its effective date. It also captures timestamp, currency, and unit for finance-grade records.

import os
import requests
from datetime import datetime, timezone

API_URL = "https://freightpulsehq.com/api/v1/historical"
API_KEY = os.getenv("FREIGHTPULSE_API_KEY", "YOUR_API_KEY")

params = {
"metric": "fuel_price_diesel_midwest",
"period": "30d"
}
headers = {
"X-API-Key": API_KEY
}

resp = requests.get(API_URL, params=params, headers=headers, timeout=20)
resp.raise_for_status()
payload = resp.json()

if not payload.get("success"):
raise RuntimeError("FreightPulse returned success=false")

data = payload.get("data", {})

# Always record audit fields if present
fp_timestamp = data.get("timestamp") # e.g., "2026-10-02T12:00:34+00:00"
currency = data.get("currency") # "USD"
unit = data.get("unit") # "gallon"

# Prefer a dated series if provided
series = data.get("series", []) # Expect elements like {"date": "YYYY-MM-DD", "value": 6.526}
records = []

if isinstance(series, list) and series:
for pt in series:
# Read the field explicitly requested in the catalog facts
value = pt.get("value")
date = pt.get("date")
if value is None or date is None:
continue
records.append({
"date": date,
"midwest_diesel": float(value),
"currency": currency,
"unit": unit
})
else:
# Fallback to the current Midwest point if series is not published
diesel = (data.get("data", {}) or {}).get("diesel", {})
midwest_value = (diesel.get("regions", {}) or {}).get("midwest")
effective_date = diesel.get("updated_at") # YYYY-MM-DD when EIA last updated
if midwest_value is None:
raise KeyError("Midwest Diesel not found in response")
records.append({
"date": effective_date,
"midwest_diesel": float(midwest_value),
"currency": currency,
"unit": unit
})

# Example: compute a simple 30-day average if you got a series
if len(records) > 1:
avg = sum(r["midwest_diesel"] for r in records) / len(records)
print(f"Midwest Diesel 30d average: {avg:.3f} {currency}/{unit}")
else:
only = records[0]
print(f"Midwest Diesel latest: {only['midwest_diesel']:.3f} {currency}/{unit} (as of {only['date']})")

# Persist or pass 'records' into your finance model as needed

Finance-grade handling: timestamps, caching, and cutovers

Finance teams care about when a price was valid, not just when it was fetched. Use these practices when you operationalize the Midwest Diesel metric:

Avoiding common mistakes

Guest access and deployment steps

You can test without an API key at modest volume. Guest access is capped at 100 requests/day per IP. This is usually enough to build a prototype, wire environment variables, and verify parsing and caching. For CI or production, create a key via Register and store it in your secret manager. In Kubernetes or similar orchestrators, mount it as FREIGHTPULSE_API_KEY and pass it to your service.

Validation checklist before you ship

FAQ

What unit and currency does Midwest Diesel use?

USD per gallon. Read data.currency and data.unit to confirm and store alongside the value.

How do I get a 30-day series for the Midwest Diesel metric?

Call GET https://freightpulsehq.com/api/v1/historical?metric=fuel_price_diesel_midwest&period=30d with the X-API-Key header. If data.series is present, iterate series[].value and series[].date. If a series is not published, use data.data.diesel.regions.midwest with data.data.diesel.updated_at for the effective date.

Can I use this to quote today’s national diesel average?

Do not invent or substitute a national value. This guide focuses on the Midwest Diesel metric. If you need other regions or aggregates, consult the Documentation and only use values returned by the API.

Is port congestion included or live?

Port congestion metrics on FreightPulse use IMF PortWatch and are lagged by approximately 6–7 days. They are not live AIS wait times and are unrelated to the Midwest Diesel metric.

Can I access the API without a key?

Yes. Guest access allows 100 requests per day per IP without a key. For sustained use, register and send X-API-Key: YOUR_API_KEY.

Get your integration into production

Create your API key and wire the X-API-Key header so you can call the Midwest Diesel metric reliably at build and run time. Start here: Register, then keep the schema and field references handy in the Documentation.