forked from dilame/instagram-private-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsocks5-proxy.example.ts
More file actions
20 lines (20 loc) · 888 Bytes
/
Copy pathsocks5-proxy.example.ts
File metadata and controls
20 lines (20 loc) · 888 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
/* tslint:disable:no-console */
import 'dotenv/config';
import { IgApiClient } from '../src';
// tslint:disable-next-line:no-var-requires
const shttps = require('socks-proxy-agent'); // you should install SOCKS5 client via: npm i socks-proxy-agent
(async () => {
const ig = new IgApiClient();
ig.state.generateDevice(process.env.IG_USERNAME);
ig.request.defaults.agentClass = shttps; // apply agent class to request library defaults
ig.request.defaults.agentOptions = {
// @ts-ignore
hostname: '127.0.0.1', // proxy hostname
port: 8000, // proxy port
protocol: 'socks:' // supported: 'socks:' , 'socks4:' , 'socks4a:' , 'socks5:' , 'socks5h:'
};
// Now we can perform authorization using our SOCKS5 proxy.
const auth = await ig.account.login(process.env.IG_USERNAME, process.env.IG_PASSWORD);
console.log(JSON.stringify(auth));
// Do your things.
})();