OilPriceAPI Docs
GitHub
GitHub

Currency Conversion

OilPriceAPI responses are USD-first by default, but selected endpoints support response conversion with the currency query parameter.

Supported Output Currencies

CurrencyDescriptionAvailability
USDDefault output currencyAll plans
EUREuro-converted responsePaid / premium access
GBPBritish pound-converted responsePaid / premium access

If you omit currency, responses default to USD where applicable.

Supported Endpoints

Use currency conversion on endpoints that return price data rather than catalog metadata.

Common examples:

  • GET /v1/prices/all
  • GET /v1/prices/latest
  • Historical price endpoints under /v1/prices/*
  • Premium market overview endpoints that expose converted price fields

Catalog pages and account/billing endpoints generally ignore this parameter.

Basic Example

curl "https://api.oilpriceapi.com/v1/prices/all?currency=EUR" \
  -H "Authorization: Token YOUR_API_KEY"

Latest Price Example

curl "https://api.oilpriceapi.com/v1/prices/latest?by_code=WTI_USD&currency=GBP" \
  -H "Authorization: Token YOUR_API_KEY"

Query Parameter

ParameterTypeDescriptionExample
currencystringOutput currency for supported price responsesEUR

Example Response

{
  "status": "success",
  "data": {
    "code": "WTI_USD",
    "price": 67.42,
    "formatted": "EUR 67.42",
    "currency": "EUR",
    "base_currency": "USD",
    "created_at": "2026-04-24T14:30:00.000Z"
  },
  "meta": {
    "request_id": "req_abc123"
  }
}

How Conversion Works

  • Commodity codes remain the same
  • Numeric price reflects the converted amount
  • currency reflects the output currency
  • Some endpoints may also expose a base_currency or equivalent metadata field
  • Historical results convert each returned price point into the requested currency

Error Handling

Treat invalid or unavailable currencies as request errors rather than retryable failures.

Example invalid parameter response:

{
  "status": "error",
  "error": {
    "code": "INVALID_CURRENCY",
    "message": "Supported currencies are USD, EUR, and GBP."
  }
}

If your plan does not allow conversion, expect a plan or entitlement error similar to other premium features.

SDK Examples

Python

import requests

response = requests.get(
    "https://api.oilpriceapi.com/v1/prices/latest",
    params={"by_code": "WTI_USD", "currency": "EUR"},
    headers={"Authorization": "Token YOUR_API_KEY"},
    timeout=30,
)

response.raise_for_status()
data = response.json()
print(data["data"]["formatted"])

JavaScript

const response = await fetch(
  "https://api.oilpriceapi.com/v1/prices/all?currency=GBP",
  { headers: { Authorization: "Token YOUR_API_KEY" } },
);

if (!response.ok) {
  throw new Error(`Request failed with ${response.status}`);
}

const payload = await response.json();
console.log(payload.data);

Best Practices

  • Store the user’s preferred display currency separately from commodity code selection
  • Do not assume every endpoint supports currency conversion
  • Cache converted responses separately from USD responses
  • Keep finance/accounting workflows aware that displayed prices may be converted outputs

Related Docs

  • Premium Features and Plan Requirements
  • Rate Limiting
  • Handling Responses
  • All Prices API
Last Updated: 7/16/26, 1:53 PM