Skip to content

Instantly share code, notes, and snippets.

@takvol
Created August 8, 2016 14:44
Show Gist options
  • Save takvol/d6b5ce17580b84b314e10f9f5fa4ab08 to your computer and use it in GitHub Desktop.
Save takvol/d6b5ce17580b84b314e10f9f5fa4ab08 to your computer and use it in GitHub Desktop.
Custom function in GAS that takes eBay item URL and returns item category
function getCategory(itemUrl) {
var itemID = itemUrl.slice(itemUrl.lastIndexOf('/') + 1);
Logger.log(itemID);
var parameters =
"?callname=GetSingleItem" +
"&responseencoding=JSON" +
"&appid=" + "YourAppIDHere" +
"&siteid=0" +
"&version=963" +
"&ItemID=" + itemID;
var result = JSON.parse(UrlFetchApp.fetch("http://open.api.ebay.com/shopping" + parameters).getContentText());
var category = result.Item.PrimaryCategoryID;
return category;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment