Start Using Our Oil Price API in 2 Minutes
import requests
# Get your free API key at oilpriceapi.com
API_KEY = "your_api_key"
url = "https://api.oilpriceapi.com/v1/prices/latest"
headers = {"Authorization": f"Token {API_KEY}"}
response = requests.get(url, headers=headers)
data = response.json()
print(f"WTI: ${data['wti']}/barrel")
print(f"Brent: ${data['brent']}/barrel")
# Response:
# WTI: $63.53/barrel
# Brent: $67.91/barrelconst axios = require('axios');
async function getLatestOilPrices() {
try {
const response = await axios.get('https://api.oilpriceapi.com/v1/prices/latest', {
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
}
});
console.log('WTI Price:', response.data.data.price);
console.log('Last Updated:', response.data.data.updated_at);
return response.data;
} catch (error) {
console.error('Error fetching oil prices:', error.message);
throw error;
}
}
// Get historical data for the past month
async function getHistoricalPrices() {
const thirtyDaysAgo = new Date(Date.now() - 30 * 24 * 60 * 60 * 1000)
.toISOString()
.split('T')[0];
const response = await axios.get('https://api.oilpriceapi.com/v1/prices', {
params: {
by_code: 'WTI_USD',
start_date: thirtyDaysAgo
},
headers: {
'Authorization': 'Bearer YOUR_API_KEY'
}
});
return response.data;
}<?php
function getLatestOilPrices() {
$apiKey = 'YOUR_API_KEY';
$url = 'https://api.oilpriceapi.com/v1/prices/latest';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: Bearer ' . $apiKey,
'Content-Type: application/json'
]);
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($httpCode !== 200) {
throw new Exception("API request failed with status: " . $httpCode);
}
$data = json_decode($response, true);
echo "WTI Price: $" . $data['data']['price'] . "\n";
echo "Last Updated: " . $data['data']['updated_at'] . "\n";
return $data;
}
// Get historical data with date range
function getHistoricalPrices($startDate, $endDate) {
$apiKey = 'YOUR_API_KEY';
$url = 'https://api.oilpriceapi.com/v1/prices?' . http_build_query([
'by_code' => 'WTI_USD',
'start_date' => $startDate,
'end_date' => $endDate
]);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: Bearer ' . $apiKey
]);
$response = curl_exec($ch);
curl_close($ch);
return json_decode($response, true);
}
?>require 'net/http'
require 'json'
require 'uri'
class OilPriceAPI
def initialize(api_key)
@api_key = api_key
@base_url = 'https://api.oilpriceapi.com/v1'
end
def get_latest_prices
uri = URI("#{@base_url}/prices/latest")
request = Net::HTTP::Get.new(uri)
request['Authorization'] = "Bearer #{@api_key}"
request['Content-Type'] = 'application/json'
response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
http.request(request)
end
if response.code == '200'
data = JSON.parse(response.body)
puts "WTI Price: $#{data['data']['price']}"
puts "Last Updated: #{data['data']['updated_at']}"
data
else
raise "API request failed: #{response.code} #{response.message}"
end
end
def get_historical_prices(start_date, end_date = nil)
params = {
by_code: 'WTI_USD',
start_date: start_date
}
params[:end_date] = end_date if end_date
uri = URI("#{@base_url}/prices")
uri.query = URI.encode_www_form(params)
request = Net::HTTP::Get.new(uri)
request['Authorization'] = "Bearer #{@api_key}"
response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
http.request(request)
end
JSON.parse(response.body)
end
end
# Usage
api = OilPriceAPI.new('YOUR_API_KEY')
api.get_latest_pricesWhy Choose Our Oil Price API? (From $15/month)
Real-Time Data
Oil prices updated every 5 minutes during market hours. WebSocket support for instant updates on Pro plans.
Simple Integration
Clean REST API with SDKs for Python, JavaScript, Ruby, and PHP. Comprehensive documentation with examples.
Enterprise Reliable
99.9% uptime SLA. Same data sources as Bloomberg Terminal. Used by 83+ professional trading firms.
Historical Data
Access historical oil prices back to 2020. Daily, weekly, and monthly aggregations available on all paid plans.
50+ Commodities
Beyond WTI and Brent: Natural Gas, Heating Oil, Gasoline, Marine Fuels (MGO, HFO, VLSFO), and more.
Developer Support
Active developer community. Email support on all plans. Dedicated support for Enterprise customers.
Oil Price API vs Bloomberg vs Reuters
Bloomberg Terminal
$24,000/year
- ❌ Expensive annual contracts
- ❌ Complex desktop software
- ❌ Requires extensive training
- ❌ Limited API access
Reuters Eikon
$3,600+/year
- ❌ High minimum pricing
- ❌ Per-user licensing
- ❌ Limited historical data
- ❌ Sales negotiations required
Oil Price API ⭐
From $15/month
- ✅ Pay as you grow
- ✅ Simple REST API
- ✅ 5-minute integration
- ✅ Start free, upgrade anytime
Trusted by Energy Companies Worldwide
Trusted by Energy Industry Leaders
Powering decisions at world-class organizations







Related API Resources
Frequently Asked Questions
How much does the Oil Price API cost?
We offer 100 free API requests per month forever, no credit card required. Paid plans start at $15/month for 10,000 requests, with enterprise plans available for high-volume users.
What oil prices does the API provide?
We provide real-time prices for WTI, Brent Crude, Dubai Crude, Oman Crude, OPEC Basket, and 45+ other commodities including Natural Gas, Heating Oil, Gasoline, and Marine Fuels.
How accurate is your oil price data?
Our data comes directly from official exchanges (NYMEX, ICE) and is the same source used by Bloomberg Terminal. We maintain 99.9% uptime SLA with sub-50ms response times.
Can I get historical oil price data?
Yes! Historical data is available back to 1990 for major benchmarks. Access daily, weekly, or monthly data through our /v1/prices/historical endpoint on all paid plans.
What's the API response time?
Our API delivers sub-100ms response times globally. Most requests complete in under 50ms, making it perfect for real-time trading systems and high-frequency applications.
Do you have rate limits?
Yes, rate limits are based on your plan: Free (100/month), Hobby (1,000/month), Starter (10,000/month), Professional (50,000/month), Business (100,000/month), Enterprise (unlimited).
Can I use this for commercial projects?
Yes! All our plans, including the free tier, support commercial use. Used by 83+ trading firms for production trading systems, risk management, and client-facing applications.
What authentication method do you use?
We use API key authentication. Include your key in the Authorization header as "Token YOUR_API_KEY" with every request. Keys can be regenerated anytime from your dashboard.