Created
March 27, 2020 17:35
-
-
Save mikehwagz/9751bdcb15eec4120fd41e93c6db40ce to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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