Skip to content

Instantly share code, notes, and snippets.

@mikehwagz
Created March 27, 2020 17:35
Show Gist options
  • Save mikehwagz/9751bdcb15eec4120fd41e93c6db40ce to your computer and use it in GitHub Desktop.
Save mikehwagz/9751bdcb15eec4120fd41e93c6db40ce to your computer and use it in GitHub Desktop.
/* Get 12 most recent instagram thumbnails from a public account
* resolution = 0 - 4
* 0 => 150
* 1 => 240
* 2 => 320
* 3 => 480
* 4 => 640
*/
export default function(username, resolution = 4) {
return fetch(`https://www.instagram.com/${username}/?__a=1`)
.then(res => res.json())
.then(json => json.graphql.user.edge_owner_to_timeline_media.edges)
.then(posts => {
return posts.map(post => ({
src: post.node.thumbnail_resources[resolution].src,
caption: post.node.edge_media_to_caption.edges[0].node.text,
link: `https://instagram.com/p/${post.node.shortcode}`,
})
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment