Oil Price API Documentation - Quick Start in 5 Minutes | REST API
GitHub
GitHub
  • SDKs & Languages

    • SDKs & Language Guides
    • TypeScript Response Types
  • Language Guides

    • Java Oil Price API Integration | OilPriceAPI
    • Go Oil Price API Integration | OilPriceAPI
    • Rust Oil Price API Integration | OilPriceAPI
    • PHP Oil Price API Integration | OilPriceAPI
    • Ruby Oil Price API Integration | OilPriceAPI
    • C# .NET Oil Price API Integration | OilPriceAPI
    • R Language Oil Price API Integration | OilPriceAPI

SDKs & Language Guides

Integrate OilPriceAPI into your application using your preferred programming language. All guides include complete client implementations, error handling, and production best practices.

Official SDKs

Install our maintained SDKs for the fastest integration:

LanguagePackageInstall
Pythonoilpriceapipip install oilpriceapi
Node.jsoilpriceapinpm install oilpriceapi

Python SDK

from oilpriceapi import OilPriceAPI

client = OilPriceAPI("YOUR_API_KEY")

# Get latest WTI price
price = client.prices.get("WTI_USD")
print(f"WTI: {price.formatted}")

# Get historical data
history = client.prices.historical("BRENT_CRUDE_USD", days=30)

Full Python Guide

Node.js SDK

import OilPriceAPI from 'oilpriceapi';

const client = new OilPriceAPI('YOUR_API_KEY');

// Get latest prices
const wti = await client.prices.latest('WTI_USD');
console.log(`WTI: ${wti.formatted}`);

// Get multiple prices
const prices = await client.prices.latest(['WTI_USD', 'BRENT_CRUDE_USD']);

Full JavaScript Guide


Language Guides

Complete integration guides with full client implementations for languages without official SDKs:

LanguageGuideFeatures
JavaJava GuideHttpClient, Spring Boot, async
GoGo GuideStandard library, concurrency
RustRust Guidereqwest, tokio, Actix-web
PHPPHP GuidecURL, Guzzle, Laravel
RubyRuby GuideNet::HTTP, Faraday
C#C# GuideHttpClient, .NET Core
RR Guidehttr, statistical analysis

Quick Comparison

Simple Request (All Languages)

Every guide shows you how to make this basic request:

GET https://api.oilpriceapi.com/v1/prices/latest?by_code=WTI_USD
Authorization: Token YOUR_API_KEY

Response:

{
  "status": "success",
  "data": {
    "code": "WTI_USD",
    "price": 73.25,
    "formatted": "$73.25",
    "currency": "USD",
    "unit": "barrel"
  }
}

TypeScript Support

For TypeScript projects, we provide complete type definitions:

import type { Price, HistoricalPrice, FuturesContract } from './oilpriceapi';

const price: Price = await fetchPrice('WTI_USD');

View TypeScript Types


Authentication

All API requests require authentication via the Authorization header:

Authorization: Token YOUR_API_KEY

Get your API key from the Dashboard.

Telemetry Headers (10% Bonus)

Include these headers to get 10% more requests per month:

X-Client-Name: your-app-name
X-Client-Version: 1.0.0

Common Patterns

Error Handling

All guides implement proper error handling for:

StatusErrorAction
401Invalid API keyCheck key format
404Commodity not foundVerify code
429Rate limitedImplement backoff
500Server errorRetry with backoff

Caching

Cache responses to reduce API calls:

  • Latest prices: 5 minutes
  • Historical data: 1 hour
  • Commodity list: 24 hours

Retry Logic

All guides include exponential backoff for rate limits:

Delay = 2^attempt * 1000ms

Need Help?

  • API Reference - Full endpoint documentation
  • Error Codes - All error codes explained
  • Rate Limits - Usage limits by plan
  • Support - Contact our team
Last Updated: 12/30/25, 12:33 PM
Next
TypeScript Response Types