Looker Studio has no OilPriceAPI connector, so use a Google Sheet as the bridge. An Apps Script in the sheet calls GET /v1/prices/latest?by_code=WTI_USD,BRENT_CRUDE_USD on a time-driven trigger and appends one row per price. Looker Studio reads that tab through Google's built-in Google Sheets connector. Neither Google nor OilPriceAPI publishes an OilPriceAPI connector in the Looker Studio gallery.
Updated November 26, 2026. The steps follow the Looker Studio integration guide in the OilPriceAPI docs, Method 1.
Step 1: Log prices to a sheet with Apps Script
Create a Google Sheet with a tab named prices and this header row:
| A | B | C | D | E | F |
|---|---|---|---|---|---|
| observed_at | code | price | currency | source_date | data_status |
Open Extensions > Apps Script. Under Project Settings > Script properties, add OILPRICEAPI_KEY with your API key, so the key never sits in a cell or in the code. Paste this into Code.gs:
// Appends one row per new price to the "prices" tab.
// Columns: observed_at | code | price | currency | source_date | data_status
var CODES = "WTI_USD,BRENT_CRUDE_USD";
function logOilPrices() {
var props = PropertiesService.getScriptProperties();
var key = props.getProperty("OILPRICEAPI_KEY");
if (!key) throw new Error("Add OILPRICEAPI_KEY under Project Settings > Script properties");
var response = UrlFetchApp.fetch(
"https://api.oilpriceapi.com/v1/prices/latest?by_code=" + encodeURIComponent(CODES),
{ headers: { Authorization: "Token " + key }, muteHttpExceptions: true }
);
if (response.getResponseCode() !== 200) {
throw new Error("OilPriceAPI HTTP " + response.getResponseCode() + ": " +
response.getContentText().slice(0, 200));
}
var body = JSON.parse(response.getContentText());
if (body.status !== "success") throw new Error("OilPriceAPI status " + body.status);
// Two or more codes return data.prices; a single code returns one record.
var prices = body.data.prices || [body.data];
// Skip a code whose observation time has not changed since the last run.
var last = JSON.parse(props.getProperty("LAST_OBSERVED") || "{}");
var rows = [];
prices.forEach(function (p) {
var observed = p.observed_at || p.created_at;
if (last[p.code] === observed) return;
last[p.code] = observed;
rows.push([new Date(observed), p.code, Number(p.price), p.currency,
p.source_date, p.data_status]);
});
if (rows.length > 0) {
var sheet = SpreadsheetApp.getActive().getSheetByName("prices");
sheet.getRange(sheet.getLastRow() + 1, 1, rows.length, rows[0].length).setValues(rows);
props.setProperty("LAST_OBSERVED", JSON.stringify(last));
}
// A code with no current price is listed in data.missing with a reason.
var missing = body.data.missing || [];
if (missing.length > 0) {
throw new Error("No current price for: " + missing.map(function (m) {
return m.code + " (" + m.reason + ")";
}).join(", "));
}
}
Run logOilPrices once from the editor and approve the permissions. Two rows should appear, one for WTI_USD and one for BRENT_CRUDE_USD. observed_at is the source timestamp of each price, not the time your script ran. data_status reads current unless the API flags the value as stale.
We checked the request against the live API on November 26, 2026: both codes came back in data.prices with observed_at, source_date and data_status. We ran the function against that response with Google's services stubbed out. The first run wrote two rows. A second run against the same response wrote none. A 401 stopped the run with the HTTP status in the error. A response listing a code in data.missing wrote the other row and then stopped with the missing code and its reason. We did not run it inside a live Google account.
The script asks for both codes in one request. To track other series, change CODES, for example DIESEL_USD; the commodity list has every code. If a requested code has no current price (a stale or discontinued series, for example), the API still answers 200, lists the code in data.missing with a reason, and the script writes the prices it did get, then stops with an error naming the missing codes, so the run shows as failed under Executions. A misspelled code makes the whole request fail.
Step 2: Run it on a schedule
In the Apps Script editor, open Triggers > Add Trigger, choose logOilPrices, a Time-driven event source, and an Hour timer set to every hour. Each run is one API request, so hourly is 24 requests a day. The script skips a code whose observed_at has not changed, so quiet hours and weekends add no duplicate rows.
Step 3: Connect the sheet to Looker Studio
- Open Looker Studio and choose Create > Data source.
- Pick the Google Sheets connector, then your spreadsheet and the
pricestab. Leave Use first row as headers checked. - Click Connect and check the field types:
observed_atas Date & Time,priceas Number, andcode,currency,source_dateanddata_statusas Text. - Set the default aggregation of
priceto Average, so a day with several rows does not add up to an inflated number.
Step 4: Build the report
- Time series chart:
observed_atas the dimension,priceas the metric,codeas the breakdown dimension, so WTI and Brent draw as separate lines. - Scorecard:
pricewith a filter on onecode. Add a drop-down control oncodeso readers can switch series. - Table:
observed_at,code,price,currencyanddata_status, sorted byobserved_atdescending. Showingdata_statuslets readers see a stale value instead of assuming it is current.
To share the report, use Share. To embed it, use File > Embed report.
Why the report can lag
The report is only as current as the slower of two layers. The Apps Script trigger sets how often the sheet gets new rows. Looker Studio's data freshness setting on the data source sets how often the report re-reads the sheet.
| Symptom | First check |
|---|---|
| Sheet has no new rows | Executions in Apps Script; confirm the trigger still exists |
| Sheet is current, report is not | The data source's data freshness setting, or Refresh data in the report |
| Error says HTTP 401 | The OILPRICEAPI_KEY script property and the Authorization: Token header |
| Error says HTTP 429 | The trigger runs too often for your plan; move to a longer interval |
| Totals look too high | price aggregation is Sum; set it to Average |
Other paths in the docs
The Looker Studio integration guide also covers loading prices into BigQuery with a scheduled Cloud Function and reading them through the BigQuery connector, for larger or shared dashboards. It also sketches a do-it-yourself Apps Script Community Connector. That connector calls the API every time someone views the report, so the guide recommends keeping it to internal dashboards. For Power BI, the Power BI guide uses Power Query against the API directly. For prices in cells without a dashboard, see how to get oil prices in Google Sheets.
The hourly trigger above uses 24 requests a day, which fits inside the Free plan's 50.
New accounts get a 7-day trial with 10,000 requests and no credit card. After that, the Free plan is 50 requests/day. The Developer plan is $19/month for 10,000 requests/month.
Start a 7-day trial (10,000 requests, no credit card) · See the Developer plan ($19/month)