Security News
Bun 1.2 Released with 90% Node.js Compatibility and Built-in S3 Object Support
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
user-instagram
Advanced tools
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()}.`);
})
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.
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);
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.
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()
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.
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()
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
FAQs
Get user & post data without authentication
The npm package user-instagram receives a total of 1,065 weekly downloads. As such, user-instagram popularity was classified as popular.
We found that user-instagram demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
Security News
Biden's executive order pushes for AI-driven cybersecurity, software supply chain transparency, and stronger protections for federal and open source systems.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.