📊 Google Sheets
Get Diesel Prices in Google Sheets
Use Apps Script to get real-time diesel prices. Works on desktop, mobile, and tablet.
Setup with Apps Script
Step 1: Open Apps Script Editor
- In Google Sheets, click Extensions → Apps Script
- Delete any existing code
- Paste the code below
function DIESEL_PRICE(stateCode) {
const API_KEY = 'YOUR_API_KEY';
const url = `https://api.oilpriceapi.com/v1/diesel-prices?state=${stateCode}`;
const options = {
'method': 'GET',
'headers': {
'Authorization': 'Bearer ' + API_KEY
}
};
try {
const response = UrlFetchApp.fetch(url, options);
const data = JSON.parse(response.getContentText());
return data.data.regional_average.price;
} catch (error) {
return 'Error: ' + error.message;
}
}Step 2: Use your custom function
Now you can use DIESEL_PRICE like any built-in Google Sheets function:
=DIESEL_PRICE("CA")
Get Diesel Prices by State
Alabama
Formula: =DIESEL_PRICE("AL")
View prices →
Alaska
Formula: =DIESEL_PRICE("AK")
View prices →
Arizona
Formula: =DIESEL_PRICE("AZ")
View prices →
Arkansas
Formula: =DIESEL_PRICE("AR")
View prices →
California
Formula: =DIESEL_PRICE("CA")
View prices →
Colorado
Formula: =DIESEL_PRICE("CO")
View prices →
Connecticut
Formula: =DIESEL_PRICE("CT")
View prices →
Delaware
Formula: =DIESEL_PRICE("DE")
View prices →
Florida
Formula: =DIESEL_PRICE("FL")
View prices →
Georgia
Formula: =DIESEL_PRICE("GA")
View prices →
Hawaii
Formula: =DIESEL_PRICE("HI")
View prices →
Idaho
Formula: =DIESEL_PRICE("ID")
View prices →
Ready to Get Started?
Get your free API key and start using diesel prices in Google Sheets today
Get Free API Key