Socket
Socket
Sign inDemoInstall

instagram-apis

Package Overview
Dependencies
78
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.4 to 1.0.5

src/myError.js

51

index.js

@@ -6,38 +6,25 @@ const instagramLogin = require("./src/instagramLogin.js");

class client extends profileAPIs {
async init(param) {
this.username = param.username;
this.password = param.password;
async init({username, password, cookie, saveCookie}) {
this.username = username;
this.password = password;
this.cookie =
param.cookie == "" || param.cookie === undefined
cookie == "" || cookie === undefined
? await new instagramLogin(this.username, this.password).start()
: param.cookie;
: cookie;
let filePath = "./sessions.json";
let fileWorker =
fs.existsSync(filePath) && param.cookie === undefined
? () => {
try {
let data = JSON.parse(
fs.readFileSync(filePath, "utf-8")
);
if (!data[`${this.username}`]) {
!data[`${this.username}`].includes(this.cookie)
? data[`${this.username}`].push(this.cookie)
: fs.writeFileSync(
filePath,
JSON.stringify(data)
);
}
} catch (error) {
console.log(error)
}
}
: () => {
try {
let data = { [this.username]: [] };
data[`${this.username}`].push(this.cookie);
fs.writeFileSync(filePath, JSON.stringify(data));
} catch (error) {}
};
saveCookie?(
() => {
if (fs.existsSync(filePath)) {
let data = JSON.parse(fs.readFileSync(filePath, "utf8"));
!data[`${username}`].includes(cookie) ? data[`${username}`].push(cookie) : null;
fs.writeFileSync(filePath, JSON.stringify(data))
}
else {
let data = { [username]: [cookie] };
fs.writeFileSync(filePath, JSON.stringify(data))
}
}
)() : null;
super.initialize(this.cookie);
fileWorker();
console.log("Logged In..");

@@ -44,0 +31,0 @@ }

{
"name": "instagram-apis",
"version": "1.0.4",
"version": "1.0.5",
"description": "Insatgram library filled with useful Instagram API's",

@@ -5,0 +5,0 @@ "main": "index.js",

# Install the package
```

@@ -11,10 +12,9 @@ npm install instagram-apis

const client = new lib();
(
async () => {
await client.init({
username: "USERNAME",
password: "PASSWORD"
})
}
)();
(async () => {
await client.init({
username: "USERNAME",
password: "PASSWORD",
// saveCookie: true
});
})(); // saveCookie parameter used to save your cookie in session.json file;
```

@@ -27,9 +27,7 @@

const client = new lib();
(
async () => {
await client.init({
cookie: "COOKIE"
})
}
)();
(async () => {
await client.init({
cookie: "COOKIE",
});
})();
```

@@ -88,4 +86,4 @@

| Function | Parameters | Do What ? | Example |
| ------------------------- | ----------------------- | ------------------------------------------- | ------------------------------------------------------------------------------ |
| Function | Parameters | Do What ? | Example |
| ------------------------- | ----------------------- | ------------------------------------------- | ---------------------------------------------------------------------------- |
| getMediaIdFromURL() | URL **[required]** | Returns the media ID of post or reels | await client.getMediaIdFromURL("https://www.instagram.com/p/CfJn1AHAFdA/") |

@@ -100,7 +98,8 @@ | getMediaInfoFromMediaId() | media_id **[required]** | Returns the media information | await client.getMediaInfoFromMediaId("MEDIA_ID") |

## News Inbox API's :
- #### All functions returning a values ( no-void functions )
| Function | Parameters | Do What ? | Example |
| ---------------------- | --------------------- | ---------------------------- | ---------------------------------------------- |
| Function | Parameters | Do What ? | Example |
| ---------------------- | --------------------- | ---------------------------- | -------------------------------------------- |
| getLastFollowRequests | | Returns last follow requests | await client.getLastFollowRequests() |
| acceeptFollowRequest() | UserID **[required]** | Accepts follow request | await client.acceeptFollowRequest("USER_ID") |

@@ -7,2 +7,3 @@ const data = require("./_constants.js");

const mediaAPIs = require("./mediaAPIs.js");
const myError = require("./myError.js");

@@ -23,3 +24,3 @@ module.exports = class chattingAPIs extends mediaAPIs {

if (!(typeof userIds == "object"))
throw new Error("userIds parameter should be array");
throw new myError("userIds parameter should be array");
let postdata = `recipient_users=[${JSON.stringify(

@@ -36,3 +37,3 @@ userIds

} catch ({ response: { data } }) {
throw new Error(data);
throw new myError(data);
}

@@ -51,3 +52,3 @@ }

} catch ({ response: { data } }) {
throw new Error(data);
throw new myError(data);
}

@@ -63,3 +64,3 @@ }

} catch ({ response: { data } }) {
throw new Error(data);
throw new myError(data);
}

@@ -75,3 +76,3 @@ }

} catch ({ response: { data } }) {
throw new Error(data);
throw new myError(data);
}

@@ -87,3 +88,3 @@ }

} catch ({ response: { data } }) {
throw new Error(data);
throw new myError(data);
}

@@ -100,3 +101,3 @@ }

} catch ({ response: { data } }) {
throw new Error(data);
throw new myError(data);
}

@@ -113,3 +114,3 @@ }

} catch ({ response: { data } }) {
throw new Error(data);
throw new myError(data);
}

@@ -127,3 +128,3 @@ }

} catch ({ response: { data } }) {
throw new Error(data);
throw new myError(data);
}

@@ -140,3 +141,3 @@ }

} catch ({ response: { data } }) {
throw new Error(data);
throw new myError(data);
}

@@ -153,3 +154,3 @@ }

} catch ({ response: { data } }) {
throw new Error(data);
throw new myError(data);
}

@@ -222,3 +223,3 @@ }

} catch ({ response: { data } }) {
throw new Error(data);
throw new myError(data);
}

@@ -242,3 +243,3 @@ }

} catch (data) {
throw new Error(data);
throw new myError(data);
}

@@ -301,3 +302,3 @@ }

} catch ({ response: { data } }) {
throw new Error(data);
throw new myError(data);
}

@@ -315,3 +316,3 @@ }

} catch ({ response: { data } }) {
throw new Error(data);
throw new myError(data);
}

@@ -345,3 +346,3 @@ }

} catch ({ response: { data } }) {
throw new Error(data);
throw new myError(data);
}

@@ -372,5 +373,5 @@ }

} catch ({ response: { data } }) {
throw new Error(data);
throw new myError(data);
}
}
}

@@ -5,2 +5,3 @@ const axios = require("axios");

const data = require("./_constants.js");
const myError = require("./myError.js");

@@ -39,3 +40,3 @@ module.exports = class {

}
throw new Error("Error In Login");
throw new myError("Error In Login");
}

@@ -42,0 +43,0 @@

@@ -6,2 +6,3 @@ const axios = require("axios");

const { getVideoDurationInSeconds } = require('get-video-duration');
const myError = require("./myError.js");

@@ -22,3 +23,3 @@

} catch ({response: {data}}) {
throw new Error(data);
throw new myError(data);
}

@@ -31,3 +32,3 @@ }

} catch ({response: {data}}) {
throw new Error(data);
throw new myError(data);
}

@@ -41,3 +42,3 @@ }

} catch (err) {
throw new Error(err);
throw new myError(err);
}

@@ -50,3 +51,3 @@ }

} catch ({response : { data }}) {
throw new Error(data);
throw new myError(data);
}

@@ -59,3 +60,3 @@ }

} catch ({response : { data }}) {
throw new Error(data);
throw new myError(data);
}

@@ -68,3 +69,3 @@ }

} catch ({response : { data }}) {
throw new Error(data);
throw new myError(data);
}

@@ -77,3 +78,3 @@ }

} catch ({response: { data }}) {
throw new Error(data);
throw new myError(data);
}

@@ -80,0 +81,0 @@ }

const axios = require("axios")
const myError = require("./myError.js")

@@ -16,3 +17,3 @@ module.exports = class {

} catch ({ response: { data } }) {
throw new Error(data);
throw new myError(data);
}

@@ -29,5 +30,5 @@ }

} catch ({ response: { data } }) {
throw new Error(data);
throw new myError(data);
}
}
}
const data = require("./_constants.js");
const axios = require("axios");
const chattingAPIs = require("./chattingAPIs.js");
const myError = require("./myError.js");
module.exports = class profileAPIs extends chattingAPIs {

@@ -35,3 +37,3 @@ wantedValues = [

} catch ({ response: { data } }) {
throw new Error(data);
throw new myError(data);
}

@@ -49,3 +51,3 @@ }

} catch ({ response: { data } }) {
throw new Error(data);
throw new myError(data);
}

@@ -72,3 +74,3 @@ }

} catch ({ response: { data } }) {
throw new Error(data);
throw new myError(data);
}

@@ -97,3 +99,3 @@ }

} catch ({ response: { data } }) {
throw new Error(data);
throw new myError(data);
}

@@ -116,3 +118,3 @@ }

} catch ({ response: { data } }) {
throw new Error(data);
throw new myError(data);
}

@@ -128,3 +130,3 @@ }

} catch ({ response: { data } }) {
throw new Error(data);
throw new myError(data);
}

@@ -141,3 +143,3 @@ }

} catch ({ response: { data } }) {
throw new Error(data);
throw new myError(data);
}

@@ -154,3 +156,3 @@ }

} catch ({ response: { data } }) {
throw new Error(data);
throw new myError(data);
}

@@ -167,5 +169,5 @@ }

} catch ({ response: { data } }) {
throw new Error(data);
throw new myError(data);
}
}
};
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