Google Sheets tutorial
How to get oil prices in Google Sheets
OilPriceAPI for Google Sheets is publicly available on Google Workspace Marketplace. Install the add-on, save your API key in its configuration, and use formulas for prices and their source timestamps. You do not need to paste a key into a worksheet or write an Apps Script function.
Published · Updated
Set up the published add-on
- Create an OilPriceAPI account and copy your key from the dashboard. Check current plan access and request limits before choosing a refresh cadence.
- Install OilPriceAPI for Google Sheets from Google Workspace Marketplace, then open the add-on from the Extensions menu in your sheet.
- Choose Configure API Key and paste your key into the add-on. The add-on stores it in properties scoped to this spreadsheet workflow, not in a visible cell formula.
- Enter a formula below. Use
OILPRICE_INFObeside the price so your sheet shows the source timestamp and freshness state.
Formulas you can paste into cells
=OILPRICE_PRICE("WTI_USD")Latest numeric WTI value for calculations
=OILPRICE_INFO("WTI_USD")Source, timestamp, unit, and freshness beside the value
=OILPRICE_CODES()Commodity codes available to your account
Replace WTI_USD with BRENT_CRUDE_USD or another code returned by OILPRICE_CODES(). Dataset access depends on your plan, and source data updates on its own publication schedule. A formula returning a value does not prove that the market price changed today.
Refresh and check the result
For a daily spreadsheet workflow, recalculate the sheet once a day and inspect the timestamp from OILPRICE_INFO. If the source has not published a new observation, keep the previous value labeled with its actual timestamp. Avoid a timer that rewrites the entire sheet: it can replace formulas with fixed values.
If a formula does not return a price
Reopen Configure API Key if the key is missing or revoked. Check your plan and code if access is denied. If you reach a request limit, wait for the reported retry window or use a lower refresh frequency. If the value is old, inspect the source timestamp before using it in a model.
Sharing and other tools
Editors can cause add-on formulas to make requests with the configured key. Use a key intended for that shared workflow, review editor access, and revoke it if the sheet is shared more widely than intended. Read the integration details for current scope and add-on status.
The same data can be used in Excel,Python, and Node.js.
For endpoints and response fields, see the API documentation.
Get an API key