Socket
Socket
Sign inDemoInstall

instagram-user

Package Overview
Dependencies
26
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.0 to 2.0.0

42

index.js

@@ -5,19 +5,31 @@ 'use strict';

module.exports = user => {
if (typeof user !== 'string') {
throw new TypeError(`Expected a string, got ${typeof user}`);
module.exports = async username => {
if (typeof username !== 'string') {
throw new TypeError(`Expected \`user\` to be of type \`string\` but received type \`${typeof username}\``);
}
return got(`http://instagram.com/${user}/?__a=1`, {json: true}).then(res => ({
description: res.body.user.biography || '',
email: getEmails(res.body.user.biography || '')[0] || '',
followers: res.body.user.followed_by.count,
following: res.body.user.follows.count,
fullName: res.body.user.full_name || '',
id: res.body.user.id,
posts: res.body.user.media.count,
url: `http://instagram.com/${user}`,
username: res.body.user.username,
website: res.body.user.external_url || ''
}));
try {
const url = `https://instagram.com/${username}`;
const {body: {graphql: {user}}} = await got(`${url}/?__a=1`, {json: true});
const email = getEmails(user.biography).values().next().value || '';
return {
...user,
description: user.biography,
email,
followers: user.edge_followed_by.count,
following: user.edge_follow.count,
fullName: user.full_name,
posts: user.edge_owner_to_timeline_media.count,
url,
username,
website: user.external_url
};
} catch (error) {
if (error.statusCode === 404) {
error.message = `User "${username}" not found`;
}
throw error;
}
};
{
"name": "instagram-user",
"version": "1.0.0",
"description": "Get Instagram user info",
"license": "MIT",
"repository": "kevva/instagram-user",
"author": {
"name": "Kevin Martensson",
"email": "kevinmartensson@gmail.com",
"url": "github.com/kevva"
},
"engines": {
"node": ">=4"
},
"scripts": {
"test": "xo && ava"
},
"files": [
"index.js"
],
"keywords": [
"api",
"instagram",
"user",
"username"
],
"dependencies": {
"get-emails": "^1.0.1",
"got": "^6.3.0"
},
"devDependencies": {
"ava": "*",
"xo": "*"
},
"xo": {
"esnext": true
}
"name": "instagram-user",
"version": "2.0.0",
"description": "Get Instagram user info",
"license": "MIT",
"repository": "kevva/instagram-user",
"author": {
"name": "Kevin Mårtensson",
"email": "kevinmartensson@gmail.com",
"url": "github.com/kevva"
},
"engines": {
"node": ">=10"
},
"scripts": {
"test": "xo && ava"
},
"files": [
"index.js"
],
"keywords": [
"api",
"instagram",
"user",
"username"
],
"dependencies": {
"get-emails": "^3.0.0",
"got": "^9.6.0"
},
"devDependencies": {
"ava": "^2.4.0",
"xo": "^0.24.0"
}
}

@@ -9,3 +9,3 @@ # instagram-user [![Build Status](https://travis-ci.org/kevva/instagram-user.svg?branch=master)](https://travis-ci.org/kevva/instagram-user)

```
$ npm install --save instagram-user
$ npm install instagram-user
```

@@ -19,6 +19,6 @@

instagramUser('unicorns').then(user => {
console.log(user);
(async () => {
console.log(await instagramUser('unicorns'));
//=> {description: 'A wonderful description', email: 'unicorns@foo.com', ...}
})
})();
```

@@ -31,2 +31,4 @@

Returns a `Promise<Object>` with the user information.
#### username

@@ -37,6 +39,1 @@

Instagram username.
## License
MIT © [Kevin Martensson](https://github.com/kevva)

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc