npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

user-instagram

v3.0.2

Published

Get user & post data without authentication

Downloads

7,093

Readme

User Instagram

Downloads Node.js CI

Usage

Use this module in your projet by installing it with npm install user-instagram.

Here is a quick example or usage:

const instagram = require('user-instagram');

await instagram.authenticate('my_instagram_username', 'my_instagram_password');

// Fetching a user
instagram.getUserData('edouard_courty').then(userData => {
  // Do whatever you need to to with this data
  console.log(`My username is ${userData.getUsername()}.`);
})

// Fetching a post
instagram.getPostData('CUc7tBPFXvP').then(postData => {
  // Do whatever you need to to with this data
  console.log(`The caption of this post is ${postData.getCaption()}.`);
})

Documentation

In the previous versions of user-instagram, only a small amount of requests could be sent every day without getting rate-mimited.
Couple of issues were submitted about this problem and it's the main reason why I decided to refactor this module, and add an authentication method to it.

Authentication

The authenticate method takes two mandatory parameters: username and password.
A good way to keep these strings safe is storing them in an uncommited file in your repo like some instagram_config.json file structured like the following:

{
  "username": "your username here",
  "password": "your password here"
}

Then use it like this:

const instagram = require('user-instagram');
const {username, password} = require('instagram_config.json')

await instagram.authenticate(username, password);

Getting a user's data

When logged in, you can request the data of any public user you want, plus the private users that your account follows.
The getUserData method takes only one parameter: the username of the user to be fetched.

This method will return a promise holding a User class, containing getters for all the interesting properties of this class.

Available user properties

All the boolean values are accessed with the following methods: (the function names should be self explanatory of their return value)

  • isVerified()
  • isPrivate()
  • isBusinessAccount()
  • isProfessionalAccount()
  • hasClips()
  • hasArEffect()
  • hasChannel()
  • hasGuides()
  • isHidingLikesAndViewsCount()
  • hasJoinedRecently()

All the non-boolean values are accessed with the following methods:

  • getUsername()
  • getBiography()
  • getPublicationsCount()
  • getFollowersCount()
  • getExternalUrl()
  • getFollowingCount()
  • getFullName()
  • getHighlightsReelsCount()
  • getId()
  • getBusinessAddressJson()
  • getBusinessContactMethod()
  • getBusinessEmail()
  • getBusinessPhoneNumber()
  • getBusinessCategoryName()
  • getOverallCategoryName()
  • getCategoryEnum()
  • getProfilePicture()
  • getHdProfilePicture()
  • getPronouns()
  • getMedias()

Getting a post's data

When logged in, you can request the data of any public post you want, plus the posts of the private accounts that your account follows.
The getPostData method takes only one parameter: the shortcode of the post to be fetched.

This method will return a promise holding a Post class, containing getters for all the interesting properties of this class.

Available post properties

All the boolean values are accessed with the following methods: (the function names should be self explanatory of their return value)

  • isVideo()
  • areCommentsDisabled()
  • areLikesAndViewsCountDisabled()
  • isPaidPartnership()
  • isAd()
  • hasAudio()

All the non-boolean values are accessed with the following methods:

  • getId()
  • getType()
  • getShortcode()
  • getDimensions()
  • getDisplayUrl()
  • getVariants()
  • getAccessibilityCaption()
  • getTaggedUsers()
  • getCaption()
  • getCommentsCount()
  • getComments()
  • getDate()
  • getLikesCount()
  • getLocation()
  • getOwner()
  • getChildren()
  • getVideoViewsCount()
  • getVideoPlaysCount()

Generic properties shared across the module

Each Media from the getMedias() in the User class method is a Media class that has these getters:

  • getType()
  • getId()
  • getShortcode()
  • getCaption()
  • getDimensions()
  • getDisplayUrl()
  • getTaggedUsers()
  • isVideo()
  • getAccessibilityCaption()
  • areCommentsDisabled()
  • getCommentsCount()
  • getLikesCount()
  • getTimestamp()
  • getLocation()
  • getChildren()
  • hasAudio()
  • getViewsCount()
  • getVideoUrl()

Every TaggerUser from getTaggedUsers() in a Post or a User.getMedias() hold the following getters:

  • getTagXPosition()
  • getTagYPosition()
  • getFullName()
  • getId()
  • isVerified()
  • getProfilePictureUrl()
  • getUsername()

Every dimension value from getDimensions() from a Media or a Post is a Dimension class with a bult-in aspect-ratio calculator:

  • getHeight()
  • getWidth()
  • getAspectRatio()

© Edouard Courty - 2021