WTI Crude (WTI_CRUDE) Price API
You need the latest finance-grade price for WTI Crude and a reliable way to read it programmatically. By the end of this guide, you will query the Energy API for the WTI_CRUDE symbol, parse the result safely, and ship a small integration that handles units, dates, and base currency logic without surprises.
What you will implement and what you need
This guide focuses on a single task: fetching the current WTI Crude (symbol code WTI_CRUDE) price via a GET request and consuming the response in your finance application or data pipeline. You will make one request to the latest endpoint, use the api_key query parameter for authentication, and read three fields that matter in production: rates.WTI_CRUDE, dates.WTI_CRUDE, and currencies.WTI_CRUDE.
Prerequisites are minimal: an HTTP client (curl, fetch, or requests), an environment variable or config file to store your API key, and a place to cache the latest price if you want to reduce calls during the 7-day trial (50 calls) or the Starter plan ($19.99/month).
API and symbol specifics you must know
- Symbol name: WTI Crude
- Symbol code: WTI_CRUDE
- Unit: USD/barrel
- Auth: api_key query parameter. Placeholder YOUR_API_KEY only.
- Do not pass base=USD when you also need TTF_GAS or EUA_CO2.
- No MCP host. Starter $19.99/mo, trial 7 days / 50 calls.
- curl: curl -G "https://energy-api.com/api/v1/latest" --data-urlencode "symbols=WTI_CRUDE" --data-urlencode "api_key=YOUR_API_KEY"
- Read rates.WTI_CRUDE, dates.WTI_CRUDE, currencies.WTI_CRUDE. base may be MIXED.
Endpoint for latest prices (HTTP GET): https://energy-api.com/api/v1/latest
Required query parameters:
- symbols: Set to WTI_CRUDE for this guide.
- api_key: Your credential, passed as a query parameter.
Quick start: curl request and official JSON
Run this request to retrieve the latest WTI_CRUDE price. Keep YOUR_API_KEY as a literal placeholder until you paste your own key.
curl -G "https://energy-api.com/api/v1/latest" --data-urlencode "symbols=WTI_CRUDE" --data-urlencode "api_key=YOUR_API_KEY"
Official JSON response example:
{
"success": true,
"date": "2026-10-06",
"base": "USD",
"rates": {
"WTI_CRUDE": 96.24
},
"dates": {
"WTI_CRUDE": "2026-10-06"
},
"currencies": {
"WTI_CRUDE": "USD"
},
"base_filter_note": null
}
What to read from the response and why
For price display and storage, these are the critical fields to consume:
- rates.WTI_CRUDE: The numeric latest price (96.24) you will chart, alert on, or store. Unit is USD/barrel for WTI_CRUDE.
- dates.WTI_CRUDE: The effective date string for this symbol ("2026-10-06"). Use it to avoid processing stale data.
- currencies.WTI_CRUDE: The quote currency for the price ("USD"). Display this alongside the unit to avoid ambiguity.
Additional fields:
- success: Boolean request status. Confirm true before using data.
- date: Top-level date associated with the snapshot. When you fetch multiple symbols, this can represent the batch date.
- base: The response base currency context. For single-symbol WTI_CRUDE calls it will typically be USD. If you mix symbols like TTF_GAS or EUA_CO2, base may be MIXED.
- base_filter_note: Notes from base filtering logic if present (null in the official example).
JavaScript example: fetch, validate, and map to your model
The snippet below calls the latest endpoint for WTI_CRUDE, validates the presence of required fields, and returns a typed object you can persist or display.
async function getLatestWtiCrude() {
const url = "https://energy-api.com/api/v1/latest?symbols=WTI_CRUDE&api_key=YOUR_API_KEY";
const res = await fetch(url, { method: "GET" });
if (!res.ok) {
throw new Error("HTTP error " + res.status);
}
const data = await res.json();
// Minimal validation
if (!data || data.success !== true) {
throw new Error("API indicated failure or returned no payload");
}
if (!data.rates || typeof data.rates.WTI_CRUDE !== "number") {
throw new Error("Missing or invalid rates.WTI_CRUDE");
}
if (!data.dates || typeof data.dates.WTI_CRUDE !== "string") {
throw new Error("Missing dates.WTI_CRUDE");
}
if (!data.currencies || data.currencies.WTI_CRUDE !== "USD") {
throw new Error("Unexpected currency for WTI_CRUDE");
}
// Normalize into a finance-friendly record
return {
symbol: "WTI_CRUDE",
price: data.rates.WTI_CRUDE, // number
currency: data.currencies.WTI_CRUDE, // "USD"
unit: "USD/barrel", // from catalog facts
asOfDate: data.dates.WTI_CRUDE, // ISO date string
snapshotBase: data.base || null // "USD" or possibly "MIXED" in multi-symbol calls
};
}
// Example usage
getLatestWtiCrude()
.then(record => {
console.log("WTI_CRUDE latest:", record.price, record.currency, "as of", record.asOfDate);
})
.catch(err => {
console.error("Failed to load WTI_CRUDE:", err);
});
Notes:
- Authentication is via api_key as a query parameter. Store your key securely and inject it into the URL at runtime from a secret manager or environment variable.
- The unit for WTI_CRUDE is USD/barrel; keep it in your UI or export schema.
- If you expand to multiple symbols later, validate per-symbol fields under rates, dates, and currencies keys.
Handling base currency and symbol mixes
For WTI_CRUDE as a single symbol, the base returned in the top-level base field will be USD as shown in the official response. If you later expand your call to include symbols like TTF_GAS or EUA_CO2, do not pass base=USD. In such mixed requests, base may be MIXED, and you should read per-symbol currencies.* fields instead of relying on a single base value.
Implementation recommendations:
- Always read currencies.WTI_CRUDE to determine the price currency for WTI_CRUDE.
- If you must convert or aggregate across symbols, do so downstream using a clear FX policy and explicit conversions. Avoid forcing a base on the request when mixing with TTF_GAS or EUA_CO2.
- Log the top-level base and base_filter_note fields to help debug mixed responses.
Operational guidance: caching, retries, and update cadence
Update cadence: The endpoint returns the latest available snapshot and provides dates.WTI_CRUDE for the symbol’s as-of date. Use that date to avoid re-processing older data in ETL jobs or alerting pipelines. The response does not include a time-of-day: treat dates.* as ISO-8601 calendar dates.
Caching: For dashboards that render multiple tiles or refresh frequently, cache the JSON or the normalized record in-memory or via a small TTL cache. A 30–60 second TTL often reduces call volume without materially affecting a “latest” display in most finance contexts. During the 7-day trial (50 calls), caching prevents hitting the cap while testing.
Retries: Implement idempotent retries on network failures with exponential backoff. Check success === true before using the payload. Log the HTTP status code and any response body for failed attempts.
Non-trading days: Commodities may have limited updates on weekends or holidays. Your integration should accept the latest price date as-is and surface it to users so they know the data vintage.
End-to-end flow you can reuse
1) Request
Use the single-symbol call for WTI_CRUDE with your api_key in the query string.
curl -G "https://energy-api.com/api/v1/latest" --data-urlencode "symbols=WTI_CRUDE" --data-urlencode "api_key=YOUR_API_KEY"
2) Expected response (parse these exact fields)
{
"success": true,
"date": "2026-10-06",
"base": "USD",
"rates": {
"WTI_CRUDE": 96.24
},
"dates": {
"WTI_CRUDE": "2026-10-06"
},
"currencies": {
"WTI_CRUDE": "USD"
},
"base_filter_note": null
}
3) Validation checklist
- Assert success is true.
- Assert typeof rates.WTI_CRUDE is number.
- Assert dates.WTI_CRUDE is a non-empty string.
- Assert currencies.WTI_CRUDE === "USD".
4) Store or display
Persist symbol, price, currency, unit, and asOfDate. Include snapshotBase for auditability if you later expand to multi-symbol responses.
Multiple complete JSON examples you can copy during testing
Use these identical examples to validate your deserializers in different environments or languages. They are the same official payload so your tests remain deterministic.
Example A (integration test fixture):
{
"success": true,
"date": "2026-10-06",
"base": "USD",
"rates": {
"WTI_CRUDE": 96.24
},
"dates": {
"WTI_CRUDE": "2026-10-06"
},
"currencies": {
"WTI_CRUDE": "USD"
},
"base_filter_note": null
}
Example B (contract test fixture):
{
"success": true,
"date": "2026-10-06",
"base": "USD",
"rates": {
"WTI_CRUDE": 96.24
},
"dates": {
"WTI_CRUDE": "2026-10-06"
},
"currencies": {
"WTI_CRUDE": "USD"
},
"base_filter_note": null
}
Example C (monitoring fixture):
{
"success": true,
"date": "2026-10-06",
"base": "USD",
"rates": {
"WTI_CRUDE": 96.24
},
"dates": {
"WTI_CRUDE": "2026-10-06"
},
"currencies": {
"WTI_CRUDE": "USD"
},
"base_filter_note": null
}
Error handling and guardrails
Consider these defensive patterns:
- Field presence checks: Always verify rates.WTI_CRUDE, dates.WTI_CRUDE, and currencies.WTI_CRUDE before using them.
- Type checks: Price fields should be numbers; avoid implicit coercion that could hide malformed strings.
- Idempotent retries: On transient 5xx or network errors, retry with exponential backoff. Do not retry on 4xx due to bad credentials.
- Timeouts: Set client timeouts and capture partial failures in logs for later analysis.
If you encounter MIXED base in multi-symbol responses, prefer per-symbol currencies.* fields to ensure you do not mislabel units or currencies in finance reports.
Cost and quota reminders (so you size your integration)
- Starter plan: $19.99/month.
- Trial: 7 days / 50 calls.
- Authentication: api_key query parameter. Use YOUR_API_KEY as the placeholder in your code templates.
Keep calls modest by caching the last successful payload for your dashboards, then refreshing on a controlled interval.
FAQ
Q: What endpoint do I call for the latest WTI Crude price?
A: Use GET https://energy-api.com/api/v1/latest with symbols=WTI_CRUDE and your api_key in the query string.
Q: Which fields should my finance app store?
A: Store rates.WTI_CRUDE (numeric price), dates.WTI_CRUDE (as-of date), currencies.WTI_CRUDE ("USD"), and include the unit USD/barrel in your metadata.
Q: Do I need to pass base=USD?
A: Not for a single WTI_CRUDE call. If you include TTF_GAS or EUA_CO2, do not pass base=USD. In such mixes the response base may be MIXED; rely on per-symbol currencies.*.
Q: How should I handle weekends or holidays?
A: Use dates.WTI_CRUDE to understand the data vintage. If the date doesn’t change, your cache can continue serving the last known price and display the as-of date to users.
Q: Is there pagination on this endpoint?
A: This latest endpoint returns a snapshot for the requested symbols. No pagination parameters are described for this call.
Ready to integrate WTI_CRUDE into your finance workflow? Create your key and start with a 7-day trial by visiting Register, then explore more options in the Documentation.
Ready to get started?
Get your API key and start querying energy commodity prices in minutes.
Get API KeyRelated posts
Learn how to integrate a Finance API for WTI Crude prices in PHP. Master authentication, parsing, and caching...
Read more →
A WTI crude price API returns WTI_CRUDE as JSON. Energy-API GET /api/v1/latest?symbols=WTI_CRUDE. Official mix...
Read more →
Discover how to optimize Finance API performance with effective latency SLAs and benchmarking techniques for r...
Read more →
Unlock trading success with our Finance API insights. Learn to optimize P&L using real-time spread and basis a...
Read more →
Streamline developer onboarding with Energy API by creating a sandbox environment for rapid prototyping. Disco...
Read more →