Use-Case Tutorials
Energy Software Dashboard
Fetch latest prices, preserve source timestamps, and cache briefly.
curl "https://api.oilpriceapi.com/v1/prices/batch" \
-H "Authorization: Token YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"codes":["WTI_USD","BRENT_CRUDE_USD","NATURAL_GAS_USD"]}'
const response = await fetch("https://api.oilpriceapi.com/v1/prices/latest?by_code=WTI_USD", {
headers: { Authorization: `Token ${process.env.OILPRICE_API_KEY}` },
});
const payload = await response.json();
console.log(payload.data.price, payload.data.created_at);
Checklist:
- Show
created_ator "last refreshed" in the UI. - Cache by code and currency.
- Handle stale data and API failures.
- Review display rights for public dashboards.
Trading / Research / Backtesting
Use historical prices for backtests and futures endpoints for contract workflows.
curl "https://api.oilpriceapi.com/v1/prices/historical?by_code=WTI_USD&start_date=2026-01-01&end_date=2026-03-31" \
-H "Authorization: Token YOUR_API_KEY"
import requests
response = requests.get(
"https://api.oilpriceapi.com/v1/futures/ice-brent/curve",
headers={"Authorization": f"Token {API_KEY}"},
timeout=30,
)
response.raise_for_status()
curve = response.json()["contracts"]
Checklist:
- Distinguish spot/latest prices from futures contracts.
- Store source timestamps and contract months.
- Confirm historical depth on your plan.
- Review futures/exchange-derived data usage before redistributing.
Transport / Aviation / Marine Procurement
Use fuel-specific codes and marine/aviation endpoints where plan-enabled.
curl "https://api.oilpriceapi.com/v1/prices/latest?by_code=DIESEL_USD,JET_FUEL_USD,VLSFO_SGSIN_USD" \
-H "Authorization: Token YOUR_API_KEY"
import requests
response = requests.get(
"https://api.oilpriceapi.com/v1/prices/marine-fuels",
params={"port": "SGSIN", "fuel_type": "VLSFO"},
headers={"Authorization": f"Token {API_KEY}"},
timeout=30,
)
response.raise_for_status()
prices = response.json()["data"]
Checklist:
- Confirm port, region, and unit coverage.
- Keep source timestamps with every quote.
- Use Data Usage Policy before customer-facing fuel quotes or exports.
- Add plan/entitlement handling for premium marine and aviation data.