Skip to content

OilpriceAPI/oilpriceapi-wordpress-plugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OilPriceAPI Widgets — WordPress Plugin

WordPress PHP License

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

Installation

  1. Download this repo as a zip (or clone it) and upload the folder to /wp-content/plugins/oilpriceapi-widget/
  2. Activate the plugin through the WordPress Plugins menu
  3. 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.

How it works

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.

Need more than widgets?

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.

OilPriceAPI ecosystem

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

Development

Plugin structure:

  • oilpriceapi-widget.php — plugin bootstrap, block render callback, defaults
  • includes/class-shortcodes.php — the four shortcodes and script enqueueing
  • admin/class-settings.php — Settings > OilPriceAPI page
  • blocks/oil-price-widget/ — Gutenberg block
  • readme.txt — wordpress.org plugin directory readme

Minimum requirements: WordPress 6.0, PHP 7.4.

License

GPL v2 or later. See LICENSE.

About

WordPress plugin for embedding OilPriceAPI widgets - live oil prices, diesel tracker, fuel surcharge calculator, and carbon cost calculator

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors