Embed live oil, diesel, and natural gas prices on any WordPress site. Four widgets, available as shortcodes or a Gutenberg block. No API key or account required.
| Widget | Shortcode | What it shows |
|---|---|---|
| Oil Price Ticker | [oilpriceapi_ticker] |
Live Brent, WTI, and Natural Gas prices with 24h change |
| Diesel Price Tracker | [oilpriceapi_diesel] |
U.S. national + regional retail diesel prices (EIA, weekly) |
| Fuel Surcharge Calculator | [oilpriceapi_fuel_surcharge] |
Industry-standard surcharge from current diesel price |
| Carbon Cost Calculator | [oilpriceapi_carbon] |
CO2 emissions and carbon cost from EPA emission factors |
- Download this repo as a zip (or clone it) and upload the folder to
/wp-content/plugins/oilpriceapi-widget/ - Activate the plugin through the WordPress Plugins menu
- Drop a shortcode into any post/page, or add the "OilPriceAPI" Gutenberg block
Defaults (theme, commodities, base fuel price, carbon price) are configurable under Settings > OilPriceAPI and can be overridden per shortcode.
The plugin renders a container div and enqueues a small (<30KB) async script from oilpriceapi.com/widgets/. The scripts fetch prices from OilPriceAPI's public, keyless widget endpoints (api.oilpriceapi.com/v1/prices/widget) and refresh every 5 minutes. No data is collected from your site or visitors.
The full OilPriceAPI offers live and historical prices for crude, refined products, natural gas, and carbon — free tier includes 200 requests/month. Try it in the interactive API explorer or read the docs.
| Platform | Package |
|---|---|
| Python | pip install oilpriceapi |
| Node.js / TypeScript | npm install oilpriceapi |
| PHP | composer require oilpriceapi/oilpriceapi |
| Go | github.com/OilpriceAPI/oilpriceapi-go |
| MCP (Claude / AI assistants) | github.com/OilpriceAPI/mcp-server |
Plugin structure:
oilpriceapi-widget.php— plugin bootstrap, block render callback, defaultsincludes/class-shortcodes.php— the four shortcodes and script enqueueingadmin/class-settings.php— Settings > OilPriceAPI pageblocks/oil-price-widget/— Gutenberg blockreadme.txt— wordpress.org plugin directory readme
Minimum requirements: WordPress 6.0, PHP 7.4.
GPL v2 or later. See LICENSE.