Skip to content

Instantly share code, notes, and snippets.

@capung-ggwp
Last active December 15, 2021 01:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save capung-ggwp/0e621322b026f45043860dfc3a851c60 to your computer and use it in GitHub Desktop.
Save capung-ggwp/0e621322b026f45043860dfc3a851c60 to your computer and use it in GitHub Desktop.
App Script example for Google Sheet
// example on sheet https://res.cloudinary.com/capung-ggwp/image/upload/v1639101873/ss_example_sheet_vs929r.png
function getProfile(username) {
const url = 'https://instagram-profile1.p.rapidapi.com/getprofile/'+username
const options = {
'method' : 'get',
'headers': {
'x-rapidapi-host': 'REPLACE_IT_X_RAPIDAPI_HOST',
'x-rapidapi-key': 'REPLACE_IT_X_RAPIDAPI_KEY'
}
};
const profile = UrlFetchApp.fetch(url, options)
const profileJSON = JSON.parse(profile.getContentText())
const last3Media = profileJSON.lastMedia.media.slice(0, 3)
profileJSON.lastMedia.media = last3Media
return JSON.stringify(profileJSON)
}
function getFollowers(rawJSON){
const profileJSON = JSON.parse(rawJSON)
const followers = profileJSON.followers
return followers
}
function getBio(rawJSON) {
const profileJSON = JSON.parse(rawJSON)
const bio = profileJSON.bio
return bio
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment