Historical WTI Crude Prices
You need reliable, finance-grade historical prices for WTI Crude to power models, risk dashboards, or internal reporting. By the end of this guide, you’ll be able to query the Energy API timeseries endpoint for the WTI Crude symbol, interpret the response, handle errors, and wire results directly into your analytics or storage layers.
What you’ll query and what to expect
This guide focuses on the WTI Crude symbol in the Energy API catalog, which you’ll request via the timeseries endpoint. The goal is to retrieve daily historical prices for finance workflows such as valuation, hedging P&L attribution, and factor backtesting.
- Symbol name: WTI Crude
- Symbol code: WTI_CRUDE
- Unit: USD/barrel
- Endpoint: GET /api/v1/timeseries
- Auth: api_key query parameter (use YOUR_API_KEY)
- Pricing: Starter $19.99/mo, trial 7 days / 50 calls
The request accepts a start date, an end date, and a comma-separated list of symbols. For this article, you’ll query a single symbol: WTI_CRUDE. The normal workflow is to read rates.WTI_CRUDE keyed by date, plus currencies.WTI_CRUDE to confirm the currency for finance normalization and reporting. Because this is used for financial use cases, keep units and currency explicit in your pipeline metadata: USD/barrel for WTI.
Quick start: curl request for WTI Crude timeseries
Use this curl to test your account and network path. Replace YOUR_API_KEY with your token. The date range is arbitrary; pick what you need for backfills or daily deltas.
curl -G "https://energy-api.com/api/v1/timeseries" --data-urlencode "start=2026-01-01" --data-urlencode "end=2026-03-31" --data-urlencode "symbols=WTI_CRUDE" --data-urlencode "api_key=YOUR_API_KEY"
Notes for finance pipelines:
- Keep the symbol list minimal per call to simplify retries and error handling.
- Cache responses for deterministic backtests; pin the exact start/end dates you used to produce a particular report or model artifact.
- The unit for WTI is USD/barrel—log this alongside each observation to avoid implicit conversions later.
Understanding API responses: success vs. error
The Energy API returns JSON with fields such as success, base, rates, dates, and currencies. Below is the official sample response block. Although this example shows a different symbol (OMIE_ES_DA) and a single-day snapshot, the field names and overall structure are representative of successful responses.
{
"success": true,
"date": "2026-10-28",
"base": "EUR",
"rates": {
"OMIE_ES_DA": 197.4594
},
"dates": {
"OMIE_ES_DA": "2026-10-28"
},
"currencies": {
"OMIE_ES_DA": "EUR"
},
"base_filter_note": null,
"missing_symbols": null
}
Field highlights you will actually use in a WTI workflow:
- success: Use this to short-circuit your loader. If false, handle the error and do not write partial results.
- rates: Your price payload. For WTI, read rates.WTI_CRUDE. In a true timeseries response, expect values to be keyed by date; if the response represents a point-in-time snapshot, you may see a direct mapping of symbol to numeric value.
- currencies: Confirm currency for each symbol. For WTI, currencies.WTI_CRUDE should be "USD" when available.
- dates: The effective date per symbol or series point. Always persist the date you ingest to ensure deterministic joins with other financial datasets.
- base: The base field can appear for some datasets; do not assume it changes the currency of WTI. Use currencies.WTI_CRUDE for definitive currency metadata.
Real-time availability note for WTI Crude
At the time of the live check, the WTI_CRUDE symbol returned an error. If you receive an error like the one below, your integration should:
- Log the failure atomically (symbol, date range, request ID, response body).
- Skip writing incomplete financial records to storage.
- Alert or retry after checking the catalog for current availability.
If WTI_CRUDE is unavailable, query the catalog endpoint referenced in the error to confirm current availability. Keep your symbol resolution step explicit and versioned in your pipeline to avoid silent symbol drift.
JavaScript example: fetching and parsing WTI Crude for finance workflows
Below is a minimal Node.js script using fetch that calls the same timeseries endpoint with WTI_CRUDE and demonstrates robust handling for both success and error responses. It shows how to safely read rates.WTI_CRUDE and currencies.WTI_CRUDE without inventing any ticks or filling missing observations.
import fetch from "node-fetch";
const API_URL = "https://energy-api.com/api/v1/timeseries";
const params = new URLSearchParams({
start: "2026-01-01",
end: "2026-03-31",
symbols: "WTI_CRUDE",
api_key: "YOUR_API_KEY"
});
(async () => {
const url = `${API_URL}?${params.toString()}`;
const resp = await fetch(url, { method: "GET" });
const data = await resp.json();
// 1) Hard stop on error
if (!data || data.success === false) {
console.error("Timeseries error:", data && data.error ? data.error : "Unknown error");
process.exit(1);
}
// 2) Validate presence of currencies and rates for WTI_CRUDE
const symbol = "WTI_CRUDE";
const cur = data.currencies && data.currencies[symbol];
if (!cur) {
console.error(`Missing currencies.${symbol}. Cannot confirm currency metadata.`);
process.exit(1);
}
if (cur !== "USD") {
console.warn(`Currency for ${symbol} is ${cur}. Finance normalization may be required.`);
}
// 3) Read the values. Some responses can present a dict of date -> value under rates[symbol],
// while others present a direct numeric value. Handle both without inventing data.
const series = data.rates && data.rates[symbol];
if (series === undefined || series === null) {
console.error(`No rates found for ${symbol}.`);
process.exit(1);
}
// 4) Emit structured rows for loading: (symbol, date, value, unit, currency)
// Unit is defined by the catalog: USD/barrel for WTI Crude.
const UNIT = "USD/barrel";
// Case A: timeseries map keyed by date
if (typeof series === "object" && !Array.isArray(series)) {
for (const [date, value] of Object.entries(series)) {
if (typeof value === "number") {
console.log(JSON.stringify({
symbol,
date,
value,
unit: UNIT,
currency: cur
}));
}
}
} else if (typeof series === "number") {
// Case B: single snapshot value; if 'dates' has a matching symbol date, include it
const date = data.dates && data.dates[symbol] ? data.dates[symbol] : null;
console.log(JSON.stringify({
symbol,
date, // may be null if not present
value: series,
unit: UNIT,
currency: cur
}));
} else {
console.error("Unrecognized rates payload shape for WTI_CRUDE.");
process.exit(1);
}
})();
Key takeaways for finance reliability:
- Fail fast on success=false to avoid partial writes that taint P&L or backtests.
- Confirm currencies.WTI_CRUDE is USD. Never assume the base field dictates currency for every series.
- Support both a date-keyed timeseries payload and a single-point payload without fabricating missing values.
Python example: request, verify fields, and stage for storage
This Python snippet makes the same call and illustrates field checks you should perform before ingestion. It emits rows you can store in a warehouse table keyed by (symbol, date).
import os
import sys
import json
import urllib.parse
import urllib.request
API_URL = "https://energy-api.com/api/v1/timeseries"
query = {
"start": "2026-01-01",
"end": "2026-03-31",
"symbols": "WTI_CRUDE",
"api_key": "YOUR_API_KEY"
}
url = f"{API_URL}?{urllib.parse.urlencode(query)}"
try:
with urllib.request.urlopen(url) as r:
payload = r.read().decode("utf-8")
data = json.loads(payload)
except Exception as e:
print(f"Network or parse error: {e}", file=sys.stderr)
sys.exit(1)
if not data or data.get("success") is False:
print(f"API error: {data.get('error', 'Unknown error')}", file=sys.stderr)
sys.exit(1)
symbol = "WTI_CRUDE"
currencies = data.get("currencies", {})
currency = currencies.get(symbol)
if not currency:
print(f"Missing currencies.{symbol}", file=sys.stderr)
sys.exit(1)
if currency != "USD":
print(f"Note: currencies.{symbol}={currency}. Normalize to USD if required.", file=sys.stderr)
rates = data.get("rates", {})
series = rates.get(symbol)
if series is None:
print(f"Missing rates.{symbol}", file=sys.stderr)
sys.exit(1)
UNIT = "USD/barrel"
out_rows = []
if isinstance(series, dict):
for dt, val in series.items():
if isinstance(val, (int, float)):
out_rows.append({
"symbol": symbol,
"date": dt,
"value": val,
"unit": UNIT,
"currency": currency
})
elif isinstance(series, (int, float)):
dt = (data.get("dates", {}) or {}).get(symbol)
out_rows.append({
"symbol": symbol,
"date": dt,
"value": series,
"unit": UNIT,
"currency": currency
})
else:
print(f"Unrecognized rates.{symbol} shape", file=sys.stderr)
sys.exit(1)
for row in out_rows:
print(json.dumps(row))
Production tip: write out_rows directly to a staging table and only promote to a finance-facing fact table once your symbol- and date-level row counts match expectations. This keeps backtests and VaR pipelines deterministic.
Practical notes that save time in finance pipelines
- Units and currency: WTI Crude is USD/barrel. Store both alongside each observation to avoid silent conversion errors.
- Non-trading days: Many energy prices are published on business days; some calendars include holidays. Do not interpolate by default. In P&L, carry-forward logic should be explicit and documented.
- Timestamps and timezone: The API returns date fields. If you add ingestion timestamps, store timezone (prefer UTC) and do not conflate publication date with your load time.
- Caching: For backtests and month-end processes, cache JSON payloads and checksum them. This guards against accidental symbol substitutions.
- Symbol catalog drift: Always validate that WTI_CRUDE exists in the current catalog before bulk pulls. If unavailable, fail gracefully and notify stakeholders.
- Multiple symbols: If you later query other symbols, do not add a base parameter that conflicts with the dataset. Avoid passing base=USD together with symbols that require different handling (e.g., TTF_GAS or EUA_CO2) in the same call.
- Versioning: Pin your symbol lists and date ranges in config so your finance results are reproducible.
Troubleshooting WTI_CRUDE availability
If you see the unavailability error for WTI_CRUDE, treat this as a hard failure and consult the catalog referenced by the error message. Do not substitute another symbol in production finance pipelines without explicit approval, as it will invalidate backtests and risk reports. Keep a retry policy that does not exceed your trial or plan limits, and measure your retry-backoff to avoid spiky usage.
During outages or catalog changes:
- Record symbol, date window, request URL (minus the key), and response body in your job logs.
- Skip downstream ETL steps that depend on that symbol to prevent mixed-vintage datasets.
- Schedule a controlled re-run once the symbol reappears in the catalog.
End-to-end checklist for finance integration
- Authentication: Use api_key=YOUR_API_KEY in the query string.
- Request shape: GET /api/v1/timeseries with start, end, symbols=WTI_CRUDE.
- Parsing: Read rates.WTI_CRUDE (prefer date-keyed values), confirm currencies.WTI_CRUDE.
- Unit integrity: Persist USD/barrel with each row.
- Error handling: Stop on success=false; log and alert on missing symbols or unexpected shapes.
- Data provenance: Save raw responses for the audit trail behind P&L and risk figures.
Documentation and next steps
For field-by-field definitions and additional parameters, review the official docs. Keep your integration minimal: only the parameters required to fetch WTI_CRUDE within your target window, plus your api_key. If you expand your scope later, validate each new symbol and its currency/unit before combining series in finance models.
FAQ
What unit should I store for WTI Crude?
Store USD/barrel as the unit for WTI Crude together with the currency field. Never assume unit from symbol alone in your downstream joins.
How do I handle missing days in my finance model?
Treat missing dates as genuine gaps. If you must carry-forward for reporting, do it in a separate transform with clear lineage so backtests remain auditable.
Does the base field change the currency for WTI?
No. Use currencies.WTI_CRUDE to confirm currency. The base field can appear in responses but should not override per-symbol currency metadata.
Why am I receiving an error for WTI_CRUDE?
The live check returned: {"success":false,"error":"Symbol WTI_CRUDE is not currently available. See /api/v1/symbols for the current catalog."}. Verify the catalog and retry only after confirming availability.
What are the trial limits?
The trial is 7 days with 50 calls. The Starter plan is $19.99/month. Monitor your retries and backfills to stay within limits.
Ready to integrate WTI Crude prices into your finance stack? Create an account and run the curl above with your key to validate connectivity, then wire the JavaScript or Python sample into your ETL. Register
Ready to get started?
Get your API key and start querying energy commodity prices in minutes.
Get API Key