New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

user-instagram

Package Overview
Dependencies
Maintainers
1
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

user-instagram - npm Package Compare versions

Comparing version 2.1.9 to 3.0.0

.eslintrc.json

29

index.js

@@ -1,5 +0,26 @@

const {getUserData, getPostData} = require('./src/scrape');
const GetUserDataHandler = require('./src/Instagram/Application/GetUserDataHandler');
const GetPostDataHandler = require('./src/Instagram/Application/GetPostDataHandler');
const AuthenticationHandler = require('./src/Instagram/Application/AuthenticationHandler');
module.exports = getUserData;
module.exports.getUserData = getUserData;
module.exports.getPostData = getPostData;
const GetUserDataQuery = require('./src/Instagram/Application/Query/GetUserDataQuery');
const GetPostDataQuery = require('./src/Instagram/Application/Query/GetPostDataQuery');
const AuthenticationQuery = require('./src/Instagram/Application/Query/AuthenticationQuery');
module.exports = {
/**
* @param {string} username
* @returns Promise<User>
*/
getUserData: (username) => GetUserDataHandler.handle(new GetUserDataQuery(username)),
/**
* @param {string} shortCode
* @returns {Promise<Post>}
*/
getPostData: (shortCode) => GetPostDataHandler.handle(new GetPostDataQuery(shortCode)),
/**
* @param {string} username
* @param {string} password
* @returns {Promise<void>}
*/
authenticate: (username, password) => AuthenticationHandler.handle(new AuthenticationQuery(username, password))
};

38

package.json
{
"name": "user-instagram",
"version": "2.1.9",
"description": "Get user data and feed content by scraping Instagram's user page. No OAuth needed.",
"version": "3.0.0",
"description": "Get user & post data without authentication",
"main": "index.js",
"scripts": {
"test": "node test/test.js"
"repository": {
"type": "git",
"url": "https://github.com/EdouardCourty/user-instagram.git"
},
"type": "commonjs",
"keywords": [

@@ -13,13 +15,29 @@ "Instagram",

"Instagram user",
"scrapping"
"Scrapping"
],
"repository": {
"type": "git",
"url": "https://github.com/EdouardCourty/user-instagram"
},
"author": "Edouard Courty",
"license": "MIT",
"bugs": {
"url": "https://github.com/EdouardCourty/user-instagram/issues"
},
"homepage": "https://github.com/EdouardCourty/user-instagram#readme",
"dependencies": {
"axios": "^0.21.0"
"axios": "^0.21.1",
"cookie-parser": "^1.4.5"
},
"scripts": {
"eslint": "eslint .",
"test": "node --experimental-vm-modules node_modules/.bin/jest tests"
},
"devDependencies": {
"@babel/eslint-parser": "^7.14.5",
"@babel/plugin-proposal-class-properties": "^7.14.5",
"@babel/plugin-proposal-private-methods": "^7.14.5",
"eslint": "^7.32.0",
"eslint-config-airbnb": "^18.2.1",
"eslint-plugin-import": "^2.25.2",
"eslint-plugin-jsx-a11y": "^6.4.1",
"eslint-plugin-react": "^7.25.1",
"jest": "^27.1.0"
}
}

@@ -1,87 +0,168 @@

# User-Instagram
![npm](https://img.shields.io/npm/dt/user-instagram) ![David](https://img.shields.io/david/EdouardCourty/user-instagram)
<br>
[![NPM](https://nodei.co/npm/user-instagram.png)](https://nodei.co/npm/user-instagram)
# User Instagram
## Introduction
The aim of this module is to provide an easy way to retrieve a user's or a post data on Instagram.
This module is available on NPM.
```
npm install user-instagram
```
[![Downloads](https://img.shields.io/npm/dt/user-instagram)](https://img.shields.io/david/EdouardCourty/user-instagram)
[![Node.js CI](https://github.com/EdouardCourty/user-instagram/actions/workflows/node.js.yml/badge.svg)](https://github.com/EdouardCourty/user-instagram/actions/workflows/node.js.yml)
## Usage
I tried to make this module user-friendly as much as I could. Just provide a username or a profile link.
```js
const userInstagram = require("user-instagram");
Use this module in your projet by installing it with `npm install user-instagram`.
// Gets informations about a user
userInstagram('edouard_courty') // Same as getUserData()
.then(console.log)
.catch(console.error);
Here is a quick example or usage:
```javascript
const instagram = require('user-instagram');
// Gets information about a post
userInstagram.getPostData('CD9EMe5sHP5')
.then(console.log)
.catch(console.error)
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()}.`);
})
```
## Data Structure
## Documentation
The getUserData's JSON output will look like this:
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:
```json
{
"id": "<userId>",
"profileLink": "https://www.instagram.com/edouard_courty",
"biography": "<Biography>",
"subscribersCount": 444,
"subscribtions": 362,
"postsCount": 27,
"fullName": "Edouard Courty",
"username": "edouard_courty",
"isPrivate": false,
"isVerified": false,
"profilePic": "<ProfilePicThumbnailLink>",
"profilePicHD": "<HDProfilePicLink>",
"posts": []
"username": "your username here",
"password": "your password here"
}
```
Then use it like this:
```javascript
const instagram = require('user-instagram');
const {username, password} = require('instagram_config.json')
The getPostData's JSON output will look like that:
```json
{
"id": "<postId>",
"shortcode": "<postShortCode>",
"dimensions": {
"height": 1080,
"width": 1920
},
"caption": "<thePicturesCaption>",
"likesCount": 125,
"commentsCount": 26,
"comments": [
{
"id": "<commentId>",
"text": "<commentText>",
"author": {}
}
],
"location": {
"id": "<locationId>",
"name": "<locationName>",
"slug": "<locationSlug>"
},
"childrenPictures": [],
"owner": {
"username": "<ownerUsername>",
"full_name": "<ownerFullName",
"isPrivate" : true,
"isVerified": false
}
}
await instagram.authenticate(username, password);
```
This module uses ES6 Promises.
© 2020 - Edouard Courty
### 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()`
&copy; Edouard Courty - 2021
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc