OilPriceAPI Docs
Quick Start
API Reference
  • SDKs and languages
  • Tutorials
  • Articles
  • Documentation directory
  • Quick reference
  • API explorer
  • FAQ
  • Changelog
  • Status
  • Dashboard
GitHub
Quick Start
API Reference
  • SDKs and languages
  • Tutorials
  • Articles
  • Documentation directory
  • Quick reference
  • API explorer
  • FAQ
  • Changelog
  • Status
  • Dashboard
GitHub

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_at or "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

# Use /marine-fuels/latest for filtering — the unfiltered /marine-fuels
# endpoint ignores port/fuel parameters and returns all ports.
response = requests.get(
    "https://api.oilpriceapi.com/v1/prices/marine-fuels/latest",
    params={"port_code": "SGSIN"},
    headers={"Authorization": f"Token {API_KEY}"},
    timeout=30,
)
response.raise_for_status()
ports = response.json()["data"]["prices"]  # list of port objects, each with a "fuels" array
vlsfo = next(
    fuel
    for port in ports
    for fuel in port["fuels"]
    if fuel["fuel_type"] == "VLSFO"
)
print(vlsfo["code"], vlsfo["price"])  # VLSFO_SGSIN_USD 857.5

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.

Related

  • Plan Fit
  • SDK Examples
  • Data Freshness
Last Updated: 9/11/26, 11:08 PM