PHPackages                             oilpriceapi/oilpriceapi - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. oilpriceapi/oilpriceapi

ActiveLibrary[API Development](/categories/api)

oilpriceapi/oilpriceapi
=======================

Official PHP SDK for source-timestamped OilPriceAPI energy data, with typed errors and no third-party runtime dependencies.

v2.1.0(1mo ago)04MITPHPPHP &gt;=8.1CI passing

Since Jul 3Pushed 1mo agoCompare

[ Source](https://github.com/OilpriceAPI/oilpriceapi-php)[ Packagist](https://packagist.org/packages/oilpriceapi/oilpriceapi)[ Docs](https://www.oilpriceapi.com)[ RSS](/packages/oilpriceapi-oilpriceapi/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (1)Dependencies (2)Versions (6)Used By (0)

OilPriceAPI — PHP SDK
=====================

[](#oilpriceapi--php-sdk)

> **Real-time oil, gas, LNG, carbon and fuel prices in your PHP app in under 60 seconds** — one class, zero dependencies, works everywhere PHP does (including shared hosting and WordPress).

[![Packagist Version](https://camo.githubusercontent.com/47eb21330d70b3e8fccdc5a0bd52901b030034ba69f7dba2233b0abb78dcad6c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6f696c70726963656170692f6f696c7072696365617069)](https://packagist.org/packages/oilpriceapi/oilpriceapi)[![Downloads](https://camo.githubusercontent.com/307804588640807e8f1c075bfa2e02ae93dd2b735cf7017f8843c60e1b0fb05c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6f696c70726963656170692f6f696c7072696365617069)](https://packagist.org/packages/oilpriceapi/oilpriceapi)[![PHP Version](https://camo.githubusercontent.com/756ec2128f27f22159d1626cc9b6fca646b597ecde73c43bb25b3b5c11b69038/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646570656e64656e63792d762f6f696c70726963656170692f6f696c70726963656170692f706870)](https://packagist.org/packages/oilpriceapi/oilpriceapi)[![Tests](https://github.com/OilpriceAPI/oilpriceapi-php/actions/workflows/test.yml/badge.svg)](https://github.com/OilpriceAPI/oilpriceapi-php/actions/workflows/test.yml)[![License: MIT](https://camo.githubusercontent.com/fdf2982b9f5d7489dcf44570e714e3a15fce6253e0cc6b5aa61a075aac2ff71b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d79656c6c6f772e737667)](https://opensource.org/licenses/MIT)

**[Get a Free API Key](https://oilpriceapi.com/auth/signup?utm_source=php-sdk)** · **[Documentation](https://docs.oilpriceapi.com)** · **[API Explorer](https://api.oilpriceapi.com/swagger)** · **[Pricing](https://oilpriceapi.com/pricing?utm_source=php-sdk-limit)** · **[Live demo, no key needed ↓](#try-it-without-an-api-key-demo-mode)**

The official PHP SDK for [OilPriceAPI](https://oilpriceapi.com), the commodity price API behind fintech dashboards, fleet &amp; logistics tools, maritime compliance platforms and energy analytics products — serving **2M+ API requests every month**.

- **Zero dependencies** — only `ext-curl` and `ext-json` (bundled with virtually every PHP install). No Guzzle, no framework, no conflicts with your host's packages.
- **PHP 8.1+**, strict types, immutable `Price` DTOs.
- **Resilient** — automatic retries with exponential backoff + jitter on 429/5xx, honors `Retry-After`.
- **Typed errors** — `AuthenticationException`, `RateLimitException`, `ApiException`.
- **Demo mode** — try it without an API key.
- **Escape hatch** — `$client->raw()->get(...)` reaches any endpoint, present or future.

What can you get?
-----------------

[](#what-can-you-get)

110+ commodities across the energy complex. The ones our customers poll the most:

CodeWhat it isTypical use`BRENT_CRUDE_USD`Brent crude (global)dashboards, market context, deal models`WTI_USD`WTI crude (US)trading tools, macro models`NATURAL_GAS_USD`Henry Hub natural gasenergy analytics, procurement`DUTCH_TTF_EUR`TTF gas (Europe)European energy, LNG analytics`JKM_LNG_USD`JKM LNG (Asia)LNG trading &amp; shipping`EU_CARBON_EUR`EU ETS carbon allowancesCBAM reporting, maritime compliance, ESG`DIESEL_USD`Diesel (Gulf Coast)fleet fuel-surcharge calculators, logistics`JET_FUEL_USD`Jet fuelaviation ops &amp; charter pricing`VLSFO_USD`Marine bunker fuel (0.5%S)voyage costing, bunker procurement`GOLD_USD`Goldmacro &amp; portfolio contextInstall
-------

[](#install)

```
composer require oilpriceapi/oilpriceapi
```

Quick start
-----------

[](#quick-start)

```
use OilPriceAPI\Client;

$client = new Client('your_api_key'); // or set OILPRICEAPI_KEY env var
$brent  = $client->latest('BRENT_CRUDE_USD');
echo $brent->price; // e.g. XX.XX (USD per barrel)
```

`latest()` without a code returns every commodity on your plan as a list of `Price` objects.

No composer? Plain PHP
----------------------

[](#no-composer-plain-php)

No SDK, no packages — this is the whole integration with nothing but PHP's built-in cURL:

```
