Yes, there are a few ways to automatically pull "How Long to Beat" data into Google Sheets! Here are the most effective approaches:
Option 1: Using an Unofficial API with Google Apps Script
There's an unofficial HowLongToBeat API that you can use with Google Apps Script. Here's how:
- Set up the script:
- In your Google Sheet, go to Extensions → Apps Script
- Paste this code:
function getGameLength(gameName) {
try {
const url = `https://howlongtobeat.com/api/search`;
const payload = {
searchType: "games",
searchTerms: [gameName],
searchPage: 1,
size: 1
};
const options = {
method: "POST",
headers: {
"Content-Type": "application/json",
"User-Agent": "Mozilla/5.0"
},
payload: JSON.stringify(payload)
};
const response = UrlFetchApp.fetch(url, options);
const data = JSON.parse(response.getContentText());
if (data.data && data.data.length > 0) {
const game = data.data[0];
return `Main: ${game.comp_main}h | Plus: ${game.comp_plus}h | 100%: ${game.comp_100}h`;
}
return "Not found";
} catch (error) {
return "Error fetching data";
}
}
- Use in your sheet:
- In a cell, use:
=getGameLength("Game Name")
Option 2: Using IMPORTXML (Less Reliable)
You can try scraping directly, though this may not always work due to website protections:
=IMPORTXML("https://howlongtobeat.com/search?q="&SUBSTITUTE(A2," ","%20"), "//div[@class='search_list_details_block']//div[contains(@class,'time_100')]")
Option 3: Pre-populated Database Approach
Create a reference sheet with common games and their times, then use VLOOKUP:
- Create a "Game Database" sheet with columns: Game Name, Main Story, Main+Extras, Completionist
- Use:
=VLOOKUP(A2,'Game Database'!A:D,2,FALSE) to pull main story time
Option 4: Manual Template with Quick Entry
Set up your sheet with these columns:
- Game Name
- Main Story (hours)
- Main + Extras (hours)
- Completionist (hours)
- Source/Date Added
Then manually fill in times as you research games, or use a browser extension to quickly copy data.
Recommended Setup
I'd suggest starting with Option 1 (Google Apps Script) as it's the most automated, but have Option 4 as a backup. The script approach gives you real-time data but might occasionally fail due to API changes.
Would you like me to help you set up any of these options, or do you need help structuring your sheet to work with the time data once you get it?