1
Go to sheets.google.com and create a blank spreadsheet. Name it something descriptive like "AirROI Revenue Analysis" or "STR Market Data".
Set up your first worksheet with headers in Row 1:
2
In your Google Sheet, click Extensions > Apps Script. This opens a new tab with the Apps Script code editor. You will see a default function — delete everything in the editor so you have a clean slate.
Before pasting any code, store your API key securely. In the Apps Script editor, click the gear icon (Project Settings) in the left sidebar, scroll to Script Properties, and add a property:
Property
Value
AIRROI_API_KEY
your-api-key-here
3
Copy and paste the following code into the Apps Script editor. This creates two functions: a general-purpose fetchAirROI() helper that handles API authentication and requests, and a getRevenue() wrapper you can call directly from spreadsheet cells.
apps script
/**
* AirROI API Helper — call any endpoint from Google Sheets.
* @param {string} endpoint API path, e.g. "/calculator/estimate"
* @param {Object} params Query parameters (for GET) or body (for POST)
* @param {string} method "GET" (default) or "POST"
* @return {Object} Parsed JSON response
*/
function fetchAirROI(endpoint, params, method) {
var API_KEY = PropertiesService.getScriptProperties()
.getProperty("AIRROI_API_KEY");
var BASE_URL = "https://api.airroi.com";
method = method || "GET";
var options = {
method: method,
headers: {
"X-API-KEY": API_KEY,
"Content-Type": "application/json",
},
muteHttpExceptions: true,
};
var url = BASE_URL + endpoint;
if (method === "GET" && params) {
var queryString = Object.keys(params)
.map(function (key) {
return encodeURIComponent(key) + "=" +
encodeURIComponent(params[key]);
})
.join("&");
url += "?" + queryString;
} else if (method === "POST" && params) {
options.payload = JSON.stringify(params);
}
var response = UrlFetchApp.fetch(url, options);
return JSON.parse(response.getContentText());
}
/**
* Estimate Airbnb revenue for a property.
* Usage: =getRevenue(A2, B2, C2, D2, E2)
* @param {number} lat Latitude
* @param {number} lng Longitude
* @param {number} bedrooms Number of bedrooms
* @param {number} baths Number of bathrooms
* @param {number} guests Maximum guest count
* @return {Array} [[revenue, adr, occupancy]]
* @customfunction
*/
function getRevenue(lat, lng, bedrooms, baths, guests) {
var data = fetchAirROI("/calculator/estimate", {
lat: lat,
lng: lng,
bedrooms: bedrooms,
baths: baths,
guests: guests,
currency: "usd",
});
return [[data.revenue, data.average_daily_rate, data.occupancy]];
}Important
After pasting the code, click the save icon (or Ctrl+S). The first time a custom function runs, Google will ask you to authorize it. Click "Review Permissions" and grant access to "Connect to an external service" — this is required for the API calls.
4
Go back to your Google Sheet. In Row 2, enter property details:
34.052235
-118.243683
2
1
4
Now in cell F2, enter the formula:
formula
=getRevenue(A2, B2, C2, D2, E2)
The function returns three columns at once — F2 will show the projected annual revenue, G2 the average daily rate, and H2 the occupancy rate. Add more rows for additional properties and copy the formula down.
$52,400
$195
74%
5
Create a second worksheet tab for market comparisons. First, add the getMarketSummary() function to your Apps Script file:
apps script
/**
* Get market summary metrics.
* Usage: =getMarketSummary("us", "california", "los angeles")
* @param {string} country Country code (e.g., "us")
* @param {string} region State/region (e.g., "california")
* @param {string} locality City (e.g., "los angeles")
* @return {Array} [[occupancy, adr, revpar, revenue, listings]]
* @customfunction
*/
function getMarketSummary(country, region, locality) {
var data = fetchAirROI("/markets/summary", {
market: {
country: country,
region: region,
locality: locality,
},
currency: "usd",
num_months: 12,
}, "POST");
return [[
data.occupancy,
data.average_daily_rate,
data.rev_par,
data.revenue,
data.active_listings_count,
]];
}Then in your Market Data worksheet, set up headers: Country, Region, Locality, Occupancy, ADR, RevPAR, Revenue, Active Listings. Use the formula:
formula
=getMarketSummary("us", "florida", "miami")Add rows for different markets to build a comparison table. For example, compare Miami, Los Angeles, Austin, Nashville, and Denver side by side to identify the strongest STR markets.
Miami
72%
$285
$205
12,400
Los Angeles
74%
$195
$144
18,200
Austin
68%
$210
$143
8,600
6
Keep your data fresh by scheduling automatic refreshes. In the Apps Script editor:
Click the clock icon (Triggers) in the left sidebar
Click + Add Trigger
Choose function: select a refresh function (you can create a simple one that re-runs your custom functions)
Event source: Time-driven
Select interval: Every hour or Every day
Click Save
Credit usage note
Each auto-refresh triggers API calls that consume credits. A sheet with 10 properties refreshing hourly uses roughly 240 API calls per day. Set the frequency based on how often you need updated data — daily is usually sufficient for investment analysis.
Keep exploring the AirROI API with these related tutorials.
Google Apps Script has a daily quota of 20,000 URL fetch calls for consumer (free) accounts and 100,000 for Google Workspace accounts. Each call to the AirROI API uses one URL fetch. For most use cases, the free quota is more than sufficient.
Yes. Each API call from Google Sheets consumes AirROI credits the same way as any other API call. The /calculator/estimate endpoint typically costs $0.05 per call, and /markets/summary costs $0.10. Monitor your balance in the Developer Dashboard.
Apps Script time-driven triggers can run every minute, every 5 minutes, every hour, or daily. For cost efficiency, we recommend hourly or daily refreshes unless you need near-real-time data. Each refresh triggers API calls that consume credits.
Yes, but be careful with your API key. Store it in Script Properties (Project Settings > Script Properties) rather than hardcoding it in the script. When you share the sheet, collaborators can use the functions, but the key is stored securely in the script project and not visible in the sheet itself.
Google Sheets with Apps Script runs in the cloud, so auto-refresh works even when your computer is off. Excel with Power Query requires the desktop app to be open for refresh. Google Sheets also makes sharing easier since everything is in the browser. Excel is better for very large datasets and complex local analysis.
The fetchAirROI helper has muteHttpExceptions set to true, so it will not throw on HTTP errors. You can add error handling by checking the response code. If a cell shows an error, check that your API key is set correctly in Script Properties and that you have sufficient credits.
Stay ahead of the curve
Join our newsletter for exclusive insights and updates. No spam ever.