OilPriceAPI Docs
GitHub
GitHub
  • Interactive Explorer

    • Interactive API Explorer
  • Price Data

    • API Reference
    • Get Latest Prices
    • Historical Prices
  • Commodities

    • List Commodities
    • Get Commodity Details
  • AI Agents (MCP)

    • Get Market Brief
    • Subscriptions / Watches
    • Agent Subscriptions with MCP
  • Marine Fuels

    • List Marine Fuel Ports
    • Get Port Details with Prices
  • Premium Endpoints

    • All Prices API - One Call, All Commodities
    • Cushing Oil Storage Intelligence API
    • Drilling Intelligence API
    • Marine Fuels API
    • ICE Brent Futures API
  • Futures

    • Futures API
    • ICE Brent Futures
    • ICE WTI Futures
    • ICE Gas Oil Futures
    • NYMEX Natural Gas Futures
    • ICE EUA Carbon Futures
  • Dark Data (Premium)

    • Energy Intelligence API
    • Rig Counts
    • Well Permits
    • Oil Inventories
    • OPEC Production
    • Drilling Productivity
    • Forecasts (STEO)
  • Well Production (Beta)

    • Well Production Data
    • Well Production API Reference
  • Analytics

    • Analytics API
  • Account & Billing

    • Account API

Get Latest Prices

Status: ✅ Available | ⚡ Real-time | 📊 460+ commodity codes

Returns the most recent price for a commodity. Call with a single by_code, or pass a comma-separated list to get several at once. Called with no by_code, it returns a single default commodity (BRENT_CRUDE_USD) — not every commodity.

GET/v1/prices/latest

Authentication

See Authentication Guide for API key setup.

Parameters

ParameterTypeRequiredDescription
by_codestringNoCommodity code, or several comma-separated (e.g. WTI_USD,BRENT_CRUDE_USD). Omit to get the default code.

Response

Success (200) — Single commodity

data is a flat price object (not nested by commodity code):

{
  "status": "success",
  "data": {
    "price": 68.58,
    "formatted": "$68.58",
    "currency": "USD",
    "code": "WTI_USD",
    "created_at": "2026-07-03T13:43:01.099Z",
    "updated_at": "2026-07-03T13:43:01.099Z",
    "type": "spot_price",
    "unit": "barrel",
    "source": "market_reporting",
    "data_status": "current",
    "freshness": {
      "status": "current",
      "age_seconds": 275,
      "expected_max_age_seconds": 1800
    },
    "changes": {
      "24h": { "amount": 0.72, "percent": 1.06, "previous_price": 67.86 },
      "7d": { "amount": -1.01, "percent": -1.45, "previous_price": 69.59 },
      "30d": { "amount": -26.41, "percent": -27.8, "previous_price": 94.99 },
      "90d": { "amount": -42.96, "percent": -38.52, "previous_price": 111.54 }
    },
    "metadata": {
      "source": "market_reporting",
      "source_description": "Investing.com"
    }
  }
}

Success (200) — Multiple commodities

When you pass several codes, prices come back as an array under data.prices (not keyed by code), alongside a data.metadata block:

{
  "status": "success",
  "data": {
    "prices": [
      {
        "price": 68.58,
        "code": "WTI_USD",
        "formatted": "$68.58",
        "currency": "USD",
        "type": "spot_price",
        "unit": "barrel",
        "data_status": "current"
      },
      {
        "price": 71.98,
        "code": "BRENT_CRUDE_USD",
        "formatted": "$71.98",
        "currency": "USD",
        "type": "spot_price",
        "unit": "barrel",
        "data_status": "current"
      }
    ],
    "metadata": {
      "request_id": "6390b34903a8d3f0",
      "timestamp": "2026-07-03T13:47:37Z",
      "version": "v1"
    }
  }
}

Response Fields

Note: For a single code the price object sits directly in data. For multiple codes the objects are in the data.prices array.

FieldTypeDescription
pricenumberCurrent price value (rounded to 2 decimals)
formattedstringPrice formatted with currency symbol (e.g., "$68.58")
currencystringPrice currency code (USD, EUR, GBP)
codestringCommodity code (e.g., "WTI_USD")
created_atstringISO 8601 timestamp with milliseconds (UTC)
observed_atstringISO 8601 source observation timestamp when available; for source-dated daily data this is the reference date
source_datestringDate-only source reference date when available, e.g. OPEC Basket daily values
updated_atstringISO 8601 timestamp of the last update (UTC)
typestringPrice type, e.g. "spot_price"
unitstringUnit of measure (e.g. "barrel")
sourcestringData source identifier
data_statusstringFreshness label, e.g. "current"
freshnessobjectstatus, age_seconds, expected_max_age_seconds — how recent the point is
changesobjectPrice moves keyed by window (24h, 7d, 30d, 90d), each with amount, percent, previous_price
metadata.sourcestringData source identifier
metadata.source_descriptionstringHuman-readable description of the data source

Errors

CodeStatusDescription
UNAUTHORIZED401Missing or invalid API key (returned as error.code)
invalid_code400Unknown commodity code (returned under data with status: "fail")

Examples

# Get the default commodity (BRENT_CRUDE_USD)
curl "https://api.oilpriceapi.com/v1/prices/latest" \
  -H "Authorization: Token YOUR_API_KEY"

# Get a specific commodity
curl "https://api.oilpriceapi.com/v1/prices/latest?by_code=WTI_USD" \
  -H "Authorization: Token YOUR_API_KEY"

# Get multiple commodities (returned as a data.prices array)
curl "https://api.oilpriceapi.com/v1/prices/latest?by_code=WTI_USD,BRENT_CRUDE_USD" \
  -H "Authorization: Token YOUR_API_KEY"

# Get the latest official OPEC Reference Basket price
curl "https://api.oilpriceapi.com/v1/prices/latest?by_code=OPEC_BASKET_USD" \
  -H "Authorization: Token YOUR_API_KEY"

OPEC Basket responses include source-date fields:

{
  "status": "success",
  "data": {
    "price": 69.33,
    "formatted": "$69.33",
    "currency": "USD",
    "code": "OPEC_BASKET_USD",
    "created_at": "2026-07-02T12:00:00.000Z",
    "observed_at": "2026-07-02T12:00:00.000Z",
    "source_date": "2026-07-02",
    "type": "spot_price",
    "unit": "barrel",
    "source": "opec.org"
  }
}
// JavaScript
async function getLatestPrice() {
  const response = await fetch(
    "https://api.oilpriceapi.com/v1/prices/latest?by_code=WTI_USD",
    {
      headers: {
        Authorization: "Token YOUR_API_KEY",
      },
    },
  );

  const data = await response.json();

  // For a single code, the price object is directly in data.data
  console.log(`Current price: ${data.data.formatted}`); // "$68.58"
  console.log(`Numeric value: ${data.data.price}`); // 68.58
  console.log(`24h change: ${data.data.changes["24h"].percent}%`);
  console.log(`Source: ${data.data.metadata.source_description}`);

  return data.data.price;
}
# Python
import requests

def get_latest_price(commodity_code='WTI_USD'):
    url = 'https://api.oilpriceapi.com/v1/prices/latest'
    headers = {'Authorization': 'Token YOUR_API_KEY'}
    params = {'by_code': commodity_code}

    response = requests.get(url, headers=headers, params=params)
    data = response.json()

    price = data['data']['price']
    formatted = data['data']['formatted']

    print(f"Current {commodity_code}: {formatted}")
    return price

# Get multiple commodities. With several codes, prices are in data['prices']
def get_multiple_prices(codes=['WTI_USD', 'BRENT_CRUDE_USD', 'NATURAL_GAS_USD']):
    url = 'https://api.oilpriceapi.com/v1/prices/latest'
    headers = {'Authorization': 'Token YOUR_API_KEY'}
    params = {'by_code': ','.join(codes)}

    response = requests.get(url, headers=headers, params=params)
    prices = response.json()['data']['prices']  # a list, not keyed by code
    return {p['code']: p for p in prices}
# Ruby
require 'net/http'
require 'json'
require 'uri'

def get_latest_price(commodity_code = 'WTI_USD')
  uri = URI("https://api.oilpriceapi.com/v1/prices/latest?by_code=#{commodity_code}")

  http = Net::HTTP.new(uri.host, uri.port)
  http.use_ssl = true

  request = Net::HTTP::Get.new(uri)
  request['Authorization'] = 'Token YOUR_API_KEY'

  response = http.request(request)
  data = JSON.parse(response.body)

  price = data['data']['price']
  puts "Current #{commodity_code}: $#{price}"

  price
end

Rate Limits

All plans share the same request rate limit of 60 requests per rolling 60-second window per API key. Plans differ by monthly request quota, not by request rate. Bursts within the window are fine. See Rate Limiting for details.

PlanRequests/MonthRequest Rate Limit
Free20060 per rolling 60s
Developer10,00060 per rolling 60s
Starter50,00060 per rolling 60s
Professional100,00060 per rolling 60s
Scale1,000,00060 per rolling 60s

Rate limit headers are included in responses. X-RateLimit-Limit / -Remaining / -Used track your monthly quota:

X-RateLimit-Limit: 10000
X-RateLimit-Remaining: 9876
X-RateLimit-Reset: 1785542399

Best Practices

  • Cache responses: Prices update roughly every 5 minutes; use the freshness block to decide when to refetch
  • Request specific commodities: Use by_code when possible, comma-separated for several at once
  • Handle rate limits: Check X-RateLimit-* headers and implement backoff

Related Endpoints

  • Historical Prices - Past price data
  • Commodities List - Available commodity codes
  • WebSocket Streaming - Real-time updates
Last Updated: 7/13/26, 10:16 AM
Prev
API Reference
Next
Historical Prices