1.0.1 • Published 5 months ago

like-instagram v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

like-instagram

Instagram reverse engineered API

npm i like-instagram

Note: Login requires a security checkpoint, eventually I will fix this.

For now, login manually and import the cookies.

Usage

const Instagram = require('like-instagram')

const ig = new Instagram({
  cookies: [{ name, value }, ...]
})

const TARGET_USERNAME = '<username>'

for await (const feed of ig.getPostsAll(TARGET_USERNAME)) {
  for (const post of feed.posts) {
    console.log('- Post', post.code, post.pk, post.taken_at, post.caption?.text.split('\n')[0])
    console.log('Comment count', post.comment_count)
    console.log('Like count', post.like_count)
    console.log('Image', post.image_versions2?.url)
    console.log('Carousel count', post.carousel_media_count)

    const likers = await ig.getPostLikers(post.pk)

    console.log('- Post likers (' + likers.user_count + ')')

    for (const liker of likers.users) {
      console.log('Post liker', liker.username)
    }

    for await (const comments of ig.getPostCommentsAll(post.pk)) {
      console.log('- Comments', comments.length, 'Post', post.code)

      for (const comment of comments) {
        console.log('- Comment', comment.pk, comment.user.username, comment.text)

        if (comment.comment_like_count > 0) {
          for await (const likers of ig.getCommentLikersAll(comment.pk)) {
            console.log('- Comment likers (' + likers.count + ')')

            for (const liker of likers.users) {
              console.log('Comment liker', liker.username)
            }
          }
        }

        if (comment.child_comment_count > 0) {
          const replies = await ig.getChildComments(post.pk, comment.pk)

          console.log('- Child comments (' + replies.count + ')')

          for (const reply of replies.child_comments) {
            console.log('Child comment', reply.pk, reply.created_at, reply.user.username, reply.text)

            if (reply.comment_like_count > 0) {
              for await (const likers of ig.getCommentLikersAll(reply.pk)) {
                console.log('- Child comment likers (' + likers.count + ')')

                for (const liker of likers.users) {
                  console.log('Child comment liker', liker.username)
                }
              }
            }
          }
        }
      }
    }
  }
}

(I will add the full documentation as always, just in a few days for this case.)

License

MIT