insta-api-wrapper 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +709 -0
- package/lib/config.d.ts +16 -0
- package/lib/config.js +16 -0
- package/lib/index.d.ts +6 -0
- package/lib/index.js +6 -0
- package/lib/lib/client.service.d.ts +119 -0
- package/lib/lib/client.service.js +477 -0
- package/lib/lib/cookies.service.d.ts +4 -0
- package/lib/lib/cookies.service.js +35 -0
- package/lib/lib/handler.d.ts +12 -0
- package/lib/lib/handler.js +83 -0
- package/lib/lib/login.service.d.ts +26 -0
- package/lib/lib/login.service.js +265 -0
- package/lib/lib/parser.service.d.ts +13 -0
- package/lib/lib/parser.service.js +142 -0
- package/lib/types/LoginData.d.ts +63 -0
- package/lib/types/LoginData.js +1 -0
- package/lib/types/PostModels.d.ts +497 -0
- package/lib/types/PostModels.js +1 -0
- package/lib/types/StoriesMetadata.d.ts +56 -0
- package/lib/types/StoriesMetadata.js +1 -0
- package/lib/types/UserGraphQlV2.d.ts +104 -0
- package/lib/types/UserGraphQlV2.js +1 -0
- package/lib/types/UserMetadata.d.ts +208 -0
- package/lib/types/UserMetadata.js +1 -0
- package/lib/types/index.d.ts +49 -0
- package/lib/types/index.js +34 -0
- package/lib/utils/index.d.ts +28 -0
- package/lib/utils/index.js +76 -0
- package/package.json +73 -0
package/README.md
ADDED
|
@@ -0,0 +1,709 @@
|
|
|
1
|
+
# [insta-api-wrapper: Node.js](https://github.com/appit-online/insta-api-wrapper)
|
|
2
|
+
|
|
3
|
+
A lightweight library to **fetch Instagram Stories, Reels, Highlights, user details, profiles, posts...**, including login and cookie handling .
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 🚀 Features
|
|
8
|
+
|
|
9
|
+
- 🔐 Login and fetch session cookie or auth token via `getCookie` or `login` / `login2FA`
|
|
10
|
+
- 🍪 Save & reuse sessions
|
|
11
|
+
- 📖 `InstaService.getStories` – Fetch Instagram stories
|
|
12
|
+
- 📦 `InstaService.fetchTrayStories` – Fetch all stories in the user's tray
|
|
13
|
+
- 🌟 `InstaService.getHighlights` – Fetch Instagram highlights for a user
|
|
14
|
+
- 👤 `InstaService.getUIdByUsername` – Get the user ID by username
|
|
15
|
+
- 📝 `InstaService.getUserDetails` – Fetch detailed user information
|
|
16
|
+
- 📷 `InstaService.fetchUserProfilePosts` – Fetch posts from a user's profile
|
|
17
|
+
- 🖼️ `InstaService.fetchUserPostsByUserId` – Fetch posts by user ID
|
|
18
|
+
- 🔗 `InstaService.fetchContentByUrl` – Fetch content from a post URL
|
|
19
|
+
- ✂️ `InstaService.fetchContentByShortCode` – Fetch content using Instagram shortcode
|
|
20
|
+
- 🆔 `InstaService.fetchContentByMediaId` – Fetch content by media ID
|
|
21
|
+
- ➕ `InstaService.follow` – Follow a user by username or user ID
|
|
22
|
+
- ❤️ `InstaService.like` – Like a post by media ID
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
**Table of contents:**
|
|
26
|
+
|
|
27
|
+
* [Quickstart](#quickstart)
|
|
28
|
+
|
|
29
|
+
* [Installing the library](#installation)
|
|
30
|
+
* [Using the library](#using-the-library)
|
|
31
|
+
* [License](#license)
|
|
32
|
+
|
|
33
|
+
## Quickstart
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
## 📦 Installation
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
npm install insta-api-wrapper --save
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### Using the library
|
|
43
|
+
|
|
44
|
+
### Cookie-based Authentication - Beta
|
|
45
|
+
```javascript
|
|
46
|
+
import * as instaStory from 'insta-api-wrapper';
|
|
47
|
+
|
|
48
|
+
const username = 'your_instagram_username';
|
|
49
|
+
const password = 'your_instagram_password';
|
|
50
|
+
|
|
51
|
+
// 🔐 Get Instagram session cookie (with optional force refetch)
|
|
52
|
+
const refetchCookie = true;
|
|
53
|
+
const userDetails = await instaStory.getCookie(username, password, refetchCookie);
|
|
54
|
+
|
|
55
|
+
// 💾 Save cookie & expiration for reuse
|
|
56
|
+
localStorage.setItem('cookie', userDetails.cookie);
|
|
57
|
+
localStorage.setItem('expires', userDetails.expires);
|
|
58
|
+
|
|
59
|
+
// 📲 Initialize InstaService with your session cookie
|
|
60
|
+
const igService = new instaStory.InstaService(userDetails.cookie);
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Token Authentication
|
|
64
|
+
```javascript
|
|
65
|
+
import * as instaStory from 'insta-api-wrapper';
|
|
66
|
+
|
|
67
|
+
const username = 'your_instagram_username';
|
|
68
|
+
const password = 'your_instagram_password';
|
|
69
|
+
|
|
70
|
+
// 🔐 Get Instagram auth token
|
|
71
|
+
let userDetails: any;
|
|
72
|
+
let loginService = new instaStory.LoginService();
|
|
73
|
+
const reqHeaders = {
|
|
74
|
+
'User-Agent': 'Instagram 177.0.0.30.119 Android (18/4.3; 320dpi; 720x1280; Xiaomi; HM 1SW; armani; qcom; en_US)',
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
try {
|
|
78
|
+
userDetails = await loginService.login(username, password, reqHeaders);
|
|
79
|
+
}catch(e: any) {
|
|
80
|
+
const parsed = JSON.parse(e);
|
|
81
|
+
if (parsed.two_factor_required) {
|
|
82
|
+
// 2FA required
|
|
83
|
+
const info = parsed.two_factor_info;
|
|
84
|
+
userDetails = await loginService.login2FA(password, twoFactorAppCode, twoFactorIdentifier, username, reqHeaders);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// 💾 Save userDetails for reuse
|
|
89
|
+
/*
|
|
90
|
+
import { LocalStorage } from "node-localstorage";
|
|
91
|
+
const localStorage = new LocalStorage("./session");
|
|
92
|
+
*/
|
|
93
|
+
localStorage.setItem('userDetails', userDetails);
|
|
94
|
+
|
|
95
|
+
// 📲 Initialize InstaService
|
|
96
|
+
const igService = new instaStory.InstaService();
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
```javascript
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Get insta story tray
|
|
103
|
+
* @param {string} request headers @optional - required for token authentication
|
|
104
|
+
*/
|
|
105
|
+
// 📲 Initialize InstaService
|
|
106
|
+
const igService = new instaStory.InstaService();
|
|
107
|
+
|
|
108
|
+
const requestHeaders = {
|
|
109
|
+
'Authorization':userDetails.headers["ig-set-authorization"],
|
|
110
|
+
"Ig-U-Ds-User-Id": userDetails.headers["ig-set-ig-u-ds-user-id"],
|
|
111
|
+
"Ig-U-Rur": userDetails.headers["ig-set-ig-u-rur"],
|
|
112
|
+
"X-Ig-Www-Claim": userDetails.headers["x-ig-set-www-claim"],
|
|
113
|
+
'User-Agent': 'Instagram 177.0.0.30.119 Android (18/4.3; 320dpi; 720x1280; Xiaomi; HM 1SW; armani; qcom; en_US)',
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// 📖 Fetch Instagram Tray Stories
|
|
117
|
+
const storyTray = await igService.fetchTrayStories(requestHeaders);
|
|
118
|
+
console.log(storyTray);
|
|
119
|
+
[
|
|
120
|
+
{
|
|
121
|
+
"id": "21335",
|
|
122
|
+
"full_name": "Yoga Instructor",
|
|
123
|
+
"username": "mrstest",
|
|
124
|
+
"story_duration_secs": 5,
|
|
125
|
+
"media_count": 4,
|
|
126
|
+
"has_video": true,
|
|
127
|
+
"profile_pic_url": "https://scontent-muc2-1.cdninstagram.com/v/5770385_n.jpg",
|
|
128
|
+
"is_verified": false,
|
|
129
|
+
"is_private": false
|
|
130
|
+
},
|
|
131
|
+
...
|
|
132
|
+
]
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
```javascript
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Get insta stories
|
|
139
|
+
* @param {string} username value
|
|
140
|
+
* @param {boolean} export insta response @optional - include raw GraphQL data
|
|
141
|
+
* @param {string} request headers @optional - required for token authentication
|
|
142
|
+
*/
|
|
143
|
+
// 📖 Fetch Instagram Stories
|
|
144
|
+
try {
|
|
145
|
+
const requestHeaders = {
|
|
146
|
+
'Authorization':userDetails.headers["ig-set-authorization"],
|
|
147
|
+
"Ig-U-Ds-User-Id": userDetails.headers["ig-set-ig-u-ds-user-id"],
|
|
148
|
+
"Ig-U-Rur": userDetails.headers["ig-set-ig-u-rur"],
|
|
149
|
+
"X-Ig-Www-Claim": userDetails.headers["x-ig-set-www-claim"],
|
|
150
|
+
'User-Agent': 'Instagram 177.0.0.30.119 Android (18/4.3; 320dpi; 720x1280; Xiaomi; HM 1SW; armani; qcom; en_US)',
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
const stories = await igService.getStories('someuser', true, requestHeaders);
|
|
154
|
+
console.log(stories);
|
|
155
|
+
} catch (error: any) {
|
|
156
|
+
if (error.message === 'private profile') {
|
|
157
|
+
console.warn('The user profile is private and stories cannot be accessed.');
|
|
158
|
+
} else {
|
|
159
|
+
console.error('Unknown error:', error);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
{
|
|
164
|
+
"id": "123008993",
|
|
165
|
+
"username": "someusername",
|
|
166
|
+
"name": "User Name",
|
|
167
|
+
"profilePicture": "https://scontent-muc2-1.cdninstagram.com/v/t51.2885-19/403891526_89150552568277163_n.jpg",
|
|
168
|
+
"stories_count": 10,
|
|
169
|
+
"media": [
|
|
170
|
+
{
|
|
171
|
+
"id": "36999034226_191008993",
|
|
172
|
+
"taken_at": 1755282929,
|
|
173
|
+
"expiring_at": 1755369329,
|
|
174
|
+
"original_width": 640,
|
|
175
|
+
"original_height": 1136,
|
|
176
|
+
"caption": null,
|
|
177
|
+
"thumbnail": "https://scontent-muc2-1.cdninstagram.com/v/t51.2885-15/533658976_73414557283417579416565_n.jpg",
|
|
178
|
+
"thumbnailDefault": "https://scontent-muc2-1.cdninstagram.com/v/t51.2885-15/53365897678818856079416565_n.jpg",
|
|
179
|
+
"type": "video",
|
|
180
|
+
"mimetype": "video/mp4",
|
|
181
|
+
"url": "https://scontent-muc2-1.cdninstagram.com/o1/v/t2/f2/m78/AQOcKHtdfCkfdfJ5XMY96xY4_IiwMQ7vvgM9U1Yo-lcutWgH9AfdDbofL1f8Y13r7g647Gk.mp4",
|
|
182
|
+
"has_audio": true,
|
|
183
|
+
"video_duration": 4.77
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
"id": "369972572609_191008993",
|
|
187
|
+
"taken_at": 1755261686,
|
|
188
|
+
"expiring_at": 1755348086,
|
|
189
|
+
"original_width": 1179,
|
|
190
|
+
"original_height": 2096,
|
|
191
|
+
"caption": null,
|
|
192
|
+
"thumbnail": "https://scontent-muc2-1.cdninstagram.com/v/t51.2885-15/5331086517083875_n.jpg",
|
|
193
|
+
"thumbnailDefault": "https://scontent-muc2-1.cdninstagram.com/v/t51.2885-15/533108886_701523226517083875_n.jpg",
|
|
194
|
+
"type": "image",
|
|
195
|
+
"mimetype": "image/jpeg",
|
|
196
|
+
"url": "https://scontent-muc2-1.cdninstagram.com/v/t51.2885-15/533108886_18525701523226517083875_n.jpg",
|
|
197
|
+
"has_audio": false,
|
|
198
|
+
"video_duration": 0
|
|
199
|
+
},
|
|
200
|
+
...
|
|
201
|
+
]
|
|
202
|
+
}
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
```javascript
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Get profile highlights
|
|
209
|
+
* @param {string} username value
|
|
210
|
+
* @param {string} request headers @optional - required for token authentication
|
|
211
|
+
*/
|
|
212
|
+
try {
|
|
213
|
+
const reqHeaders = {}
|
|
214
|
+
const stories = await igService.getHighlights('someuser', reqHeaders);
|
|
215
|
+
console.log(stories);
|
|
216
|
+
} catch (error: any) {
|
|
217
|
+
console.error('Unknown error:', error);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
{
|
|
221
|
+
"last_paginated_highlights_node_edited_at_ts": null,
|
|
222
|
+
"has_fetched_all_remaining_highlights": null,
|
|
223
|
+
"suggested_highlights": {},
|
|
224
|
+
"cursor": null,
|
|
225
|
+
"highlights_tray_type": "DEFAULT",
|
|
226
|
+
"my_week_enabled": null,
|
|
227
|
+
"status": "ok",
|
|
228
|
+
"tray": [
|
|
229
|
+
{
|
|
230
|
+
"id": "highlight:1234567890",
|
|
231
|
+
"reel_type": "highlight_reel",
|
|
232
|
+
"title": "Mein Highlight",
|
|
233
|
+
"created_at": 1700000000,
|
|
234
|
+
"is_pinned_highlight": false,
|
|
235
|
+
"prefetch_count": 0,
|
|
236
|
+
"disabled_reply_types": [
|
|
237
|
+
"story_remix_reply",
|
|
238
|
+
"story_selfie_reply"
|
|
239
|
+
],
|
|
240
|
+
"highlight_reel_type": "DEFAULT",
|
|
241
|
+
"is_converted_to_clips": false,
|
|
242
|
+
"is_nux": false,
|
|
243
|
+
"can_gif_quick_reply": true,
|
|
244
|
+
"can_reshare": false,
|
|
245
|
+
"is_archived": false,
|
|
246
|
+
"strong_id__": "highlight:1234567890",
|
|
247
|
+
"cover_media": {
|
|
248
|
+
"crop_rect": [0.1, 0.1, 0.9, 0.9],
|
|
249
|
+
"media_id": "9876543210_123456789",
|
|
250
|
+
"upload_id": null,
|
|
251
|
+
"cropped_image_version": {
|
|
252
|
+
"height": 150,
|
|
253
|
+
"scans_profile": "",
|
|
254
|
+
"url": "https://example.com/cropped_image.jpg",
|
|
255
|
+
"width": 150
|
|
256
|
+
},
|
|
257
|
+
"full_image_version": null
|
|
258
|
+
},
|
|
259
|
+
"ranked_position": -1000,
|
|
260
|
+
"seen_ranked_position": -1000,
|
|
261
|
+
"media_count": 10,
|
|
262
|
+
"updated_timestamp": 1700001000,
|
|
263
|
+
"latest_reel_media": 1700000500,
|
|
264
|
+
"seen": null,
|
|
265
|
+
"can_reply": true,
|
|
266
|
+
"can_react_with_avatar": false,
|
|
267
|
+
"contains_stitched_media_blocked_by_rm": false,
|
|
268
|
+
"user": {
|
|
269
|
+
"pk": "123456789",
|
|
270
|
+
"full_name": "Max Mustermann",
|
|
271
|
+
"pk_id": "123456789",
|
|
272
|
+
"id": "123456789",
|
|
273
|
+
"strong_id__": "123456789",
|
|
274
|
+
"username": "max123",
|
|
275
|
+
"is_private": false,
|
|
276
|
+
"is_verified": false,
|
|
277
|
+
"profile_pic_id": "1111111111_123456789",
|
|
278
|
+
"profile_pic_url": "https://example.com/profile_pic.jpg",
|
|
279
|
+
"account_badges": [],
|
|
280
|
+
"interop_messaging_user_fbid": 999999999999,
|
|
281
|
+
"is_creator_agent_enabled": false
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
]
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
|
|
288
|
+
````
|
|
289
|
+
|
|
290
|
+
```javascript
|
|
291
|
+
/**
|
|
292
|
+
* Get insta userId
|
|
293
|
+
* @param {string} username value
|
|
294
|
+
* @param {string} request headers @optional
|
|
295
|
+
*/
|
|
296
|
+
// 📖 Fetch Instagram UserId
|
|
297
|
+
try {
|
|
298
|
+
const reqHeaders = {}
|
|
299
|
+
const uid = await igService.getUIdByUsername('someuser', reqHeaders);
|
|
300
|
+
console.log(uid);
|
|
301
|
+
} catch (error: any) {
|
|
302
|
+
console.error('Unknown error:', error);
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
|
|
306
|
+
/**
|
|
307
|
+
* Get insta profile
|
|
308
|
+
* @param {string} username value
|
|
309
|
+
* @param {string} request headers @optional
|
|
310
|
+
*/
|
|
311
|
+
try {
|
|
312
|
+
const reqHeaders = {}
|
|
313
|
+
const profile = await igService.getUserDetails('someuser', reqHeaders);
|
|
314
|
+
console.log(profile);
|
|
315
|
+
} catch (error: any) {
|
|
316
|
+
console.error('Unknown error:', error);
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
{
|
|
320
|
+
"ai_agent_type": null,
|
|
321
|
+
"biography": "Example biography with some emojis and mentions like @exampleuser.",
|
|
322
|
+
"bio_links": [
|
|
323
|
+
{
|
|
324
|
+
"title": "",
|
|
325
|
+
"lynx_url": "https://l.instagram.com/?u=http%3A%2F%2Fexample.com%2Fprofile&e=AT123456789",
|
|
326
|
+
"url": "http://example.com/profile",
|
|
327
|
+
"link_type": "external"
|
|
328
|
+
}
|
|
329
|
+
],
|
|
330
|
+
"fb_profile_biolink": null,
|
|
331
|
+
"biography_with_entities": {
|
|
332
|
+
"raw_text": "Example biography with @users and #hashtags",
|
|
333
|
+
"entities": [
|
|
334
|
+
{
|
|
335
|
+
"user": {
|
|
336
|
+
"username": "exampleuser"
|
|
337
|
+
},
|
|
338
|
+
"hashtag": null
|
|
339
|
+
}
|
|
340
|
+
]
|
|
341
|
+
},
|
|
342
|
+
"blocked_by_viewer": false,
|
|
343
|
+
"restricted_by_viewer": false,
|
|
344
|
+
"country_block": false,
|
|
345
|
+
"eimu_id": "1234567890",
|
|
346
|
+
"external_url": "http://example.com",
|
|
347
|
+
"external_url_linkshimmed": "https://l.instagram.com/?u=http%3A%2F%2Fexample.com&e=AT123456789",
|
|
348
|
+
"edge_followed_by": {
|
|
349
|
+
"count": 12345
|
|
350
|
+
},
|
|
351
|
+
"fbid": "17840000000000000",
|
|
352
|
+
"followed_by_viewer": true,
|
|
353
|
+
"edge_follow": {
|
|
354
|
+
"count": 150
|
|
355
|
+
},
|
|
356
|
+
"follows_viewer": false,
|
|
357
|
+
"full_name": "Example Name",
|
|
358
|
+
"group_metadata": null,
|
|
359
|
+
"has_ar_effects": false,
|
|
360
|
+
"has_clips": true,
|
|
361
|
+
"has_guides": false,
|
|
362
|
+
"has_chaining": true,
|
|
363
|
+
"has_channel": false,
|
|
364
|
+
"has_blocked_viewer": false,
|
|
365
|
+
"highlight_reel_count": 5,
|
|
366
|
+
"has_requested_viewer": false,
|
|
367
|
+
"hide_like_and_view_counts": false,
|
|
368
|
+
"id": "123456789",
|
|
369
|
+
"is_business_account": false,
|
|
370
|
+
"is_professional_account": true,
|
|
371
|
+
"is_supervision_enabled": false,
|
|
372
|
+
"is_guardian_of_viewer": false,
|
|
373
|
+
"is_supervised_by_viewer": false,
|
|
374
|
+
"is_supervised_user": false,
|
|
375
|
+
"is_embeds_disabled": false,
|
|
376
|
+
"is_joined_recently": false,
|
|
377
|
+
"guardian_id": null,
|
|
378
|
+
"business_address_json": null,
|
|
379
|
+
"business_contact_method": "UNKNOWN",
|
|
380
|
+
"business_email": null,
|
|
381
|
+
"business_phone_number": null,
|
|
382
|
+
"business_category_name": null,
|
|
383
|
+
"overall_category_name": null,
|
|
384
|
+
"category_enum": null,
|
|
385
|
+
"category_name": "Public Figure",
|
|
386
|
+
"is_private": false,
|
|
387
|
+
"is_verified": true,
|
|
388
|
+
"is_verified_by_mv4b": false,
|
|
389
|
+
"is_regulated_c18": false,
|
|
390
|
+
"edge_mutual_followed_by": {
|
|
391
|
+
"count": 0,
|
|
392
|
+
"edges": []
|
|
393
|
+
},
|
|
394
|
+
"pinned_channels_list_count": 0,
|
|
395
|
+
"profile_pic_url": "https://example.com/profile.jpg",
|
|
396
|
+
"profile_pic_url_hd": "https://example.com/profile_hd.jpg",
|
|
397
|
+
"requested_by_viewer": false,
|
|
398
|
+
"should_show_category": true,
|
|
399
|
+
"should_show_public_contacts": false,
|
|
400
|
+
"show_account_transparency_details": true,
|
|
401
|
+
"transparency_label": null,
|
|
402
|
+
"transparency_product": null,
|
|
403
|
+
"username": "exampleuser",
|
|
404
|
+
"pronouns": [],
|
|
405
|
+
"edge_owner_to_timeline_media": {
|
|
406
|
+
"count": 100,
|
|
407
|
+
"page_info": {
|
|
408
|
+
"has_next_page": true,
|
|
409
|
+
"end_cursor": ""
|
|
410
|
+
},
|
|
411
|
+
"edges": []
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
```
|
|
415
|
+
|
|
416
|
+
```javascript
|
|
417
|
+
/**
|
|
418
|
+
* Get insta posts from user profile
|
|
419
|
+
* @param {string} username value
|
|
420
|
+
* @param {string} maxId - pagination of user posts - use response attribute next_max_id for more posts
|
|
421
|
+
* @param {string} request headers @optional
|
|
422
|
+
*/
|
|
423
|
+
try {
|
|
424
|
+
const reqHeaders = {}
|
|
425
|
+
const profile = await igService.fetchUserProfilePosts('someuser', '', reqHeaders);
|
|
426
|
+
console.log(profile);
|
|
427
|
+
} catch (error: any) {
|
|
428
|
+
console.error('Unknown error:', error);
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
try {
|
|
432
|
+
const reqHeaders = {}
|
|
433
|
+
const profile = await igService.fetchUserPostsByUserId('190008993', '', reqHeaders);
|
|
434
|
+
console.log(profile);
|
|
435
|
+
} catch (error: any) {
|
|
436
|
+
console.error('Unknown error:', error);
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
{
|
|
440
|
+
"id": "123455",
|
|
441
|
+
"username": "username",
|
|
442
|
+
"name": "User Name",
|
|
443
|
+
"is_private": false,
|
|
444
|
+
"is_verified": true,
|
|
445
|
+
"profile_pic_url": "https://scontent-muc2-1.cdninstagram.com/v/t51.2885-19/403891521097167925951577163_n.jpg",
|
|
446
|
+
"more_available": true,
|
|
447
|
+
"next_max_id": "3696312669046_13753680437",
|
|
448
|
+
"media": [
|
|
449
|
+
{
|
|
450
|
+
"like_and_view_counts_disabled": false,
|
|
451
|
+
"has_privately_liked": false,
|
|
452
|
+
"is_post_live_clips_media": false,
|
|
453
|
+
"is_quiet_post": false,
|
|
454
|
+
"taken_at": 1755342216,
|
|
455
|
+
"has_tagged_users": false,
|
|
456
|
+
"media_type": 2,
|
|
457
|
+
"code": "DUMMYCODE123",
|
|
458
|
+
"caption": {
|
|
459
|
+
"text": "🔥 Beispieltext 🔥\n\nHier steht ein Dummy-Beitrag mit Hashtags und Emojis. 🏆\n\n#Beispiel #Dummy #Test"
|
|
460
|
+
},
|
|
461
|
+
"play_count": 12345,
|
|
462
|
+
"has_views_fetching": true,
|
|
463
|
+
"ig_play_count": 12345,
|
|
464
|
+
"image_versions2": {
|
|
465
|
+
"candidates": [
|
|
466
|
+
{
|
|
467
|
+
"height": 1920,
|
|
468
|
+
"width": 1080,
|
|
469
|
+
"url": "https://example.com/image_1080.jpg"
|
|
470
|
+
},
|
|
471
|
+
{
|
|
472
|
+
"height": 1333,
|
|
473
|
+
"width": 750,
|
|
474
|
+
"url": "https://example.com/image_750.jpg"
|
|
475
|
+
},
|
|
476
|
+
{
|
|
477
|
+
"height": 1137,
|
|
478
|
+
"width": 640,
|
|
479
|
+
"url": "https://example.com/image_640.jpg"
|
|
480
|
+
},
|
|
481
|
+
{
|
|
482
|
+
"height": 853,
|
|
483
|
+
"width": 480,
|
|
484
|
+
"url": "https://example.com/image_480.jpg"
|
|
485
|
+
},
|
|
486
|
+
{
|
|
487
|
+
"height": 568,
|
|
488
|
+
"width": 320,
|
|
489
|
+
"url": "https://example.com/image_320.jpg"
|
|
490
|
+
}
|
|
491
|
+
]
|
|
492
|
+
}
|
|
493
|
+
},...
|
|
494
|
+
```
|
|
495
|
+
|
|
496
|
+
```javascript
|
|
497
|
+
|
|
498
|
+
/**
|
|
499
|
+
* Get post, reel... by url
|
|
500
|
+
* @param {string} url
|
|
501
|
+
* @param {string} request headers @optional - required for token authentication
|
|
502
|
+
*/
|
|
503
|
+
try {
|
|
504
|
+
const requestHeaders = {
|
|
505
|
+
'Authorization':userDetails.headers["ig-set-authorization"],
|
|
506
|
+
"Ig-U-Ds-User-Id": userDetails.headers["ig-set-ig-u-ds-user-id"],
|
|
507
|
+
"Ig-U-Rur": userDetails.headers["ig-set-ig-u-rur"],
|
|
508
|
+
"X-Ig-Www-Claim": userDetails.headers["x-ig-set-www-claim"],
|
|
509
|
+
'User-Agent': 'Instagram 177.0.0.30.119 Android (18/4.3; 320dpi; 720x1280; Xiaomi; HM 1SW; armani; qcom; en_US)',
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
const post = await igService.fetchContentByUrl('https://www.instagram.com/p/DM777IJO7rd/?igsh=MWM2ejl2Mm8zcWRtcg==', requestHeaders);
|
|
513
|
+
console.log(post);
|
|
514
|
+
} catch (error: any) {
|
|
515
|
+
console.error('Unknown error:', error);
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
/**
|
|
519
|
+
* Get post by shortCode
|
|
520
|
+
* @param {string} shortCode
|
|
521
|
+
* @param {string} request headers @optional - required for token authentication
|
|
522
|
+
*/
|
|
523
|
+
try {
|
|
524
|
+
const requestHeaders = {
|
|
525
|
+
'Authorization':userDetails.headers["ig-set-authorization"],
|
|
526
|
+
"Ig-U-Ds-User-Id": userDetails.headers["ig-set-ig-u-ds-user-id"],
|
|
527
|
+
"Ig-U-Rur": userDetails.headers["ig-set-ig-u-rur"],
|
|
528
|
+
"X-Ig-Www-Claim": userDetails.headers["x-ig-set-www-claim"],
|
|
529
|
+
'User-Agent': 'Instagram 177.0.0.30.119 Android (18/4.3; 320dpi; 720x1280; Xiaomi; HM 1SW; armani; qcom; en_US)',
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
const post = await igService.fetchContentByShortCode('AU7s3IJO7rd', requestHeaders);
|
|
533
|
+
console.log(post);
|
|
534
|
+
} catch (error: any) {
|
|
535
|
+
console.error('Unknown error:', error);
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
{
|
|
539
|
+
"username": "dummyuser",
|
|
540
|
+
"name": "Max Mustermann",
|
|
541
|
+
"postType": "p",
|
|
542
|
+
"media_id": "123456789012345678_9876543210",
|
|
543
|
+
"shortcode": "ABC123XYZ",
|
|
544
|
+
"createdAt": 1700000000,
|
|
545
|
+
"likes": 42,
|
|
546
|
+
"caption": "Hier ist ein Dummy-Beitrag mit Bild. 🌟🥳 #dummy #testpost",
|
|
547
|
+
"media_count": 1,
|
|
548
|
+
"comment_count": 3,
|
|
549
|
+
"video_duration": 0,
|
|
550
|
+
"music": {},
|
|
551
|
+
"media": [
|
|
552
|
+
{
|
|
553
|
+
"id": "123456789012345678_9876543210",
|
|
554
|
+
"thumbnail": "https://via.placeholder.com/1080x1350.png?text=Thumbnail",
|
|
555
|
+
"url": "https://via.placeholder.com/1080x1350.png?text=Full+Image",
|
|
556
|
+
"type": "image",
|
|
557
|
+
"dimensions": {
|
|
558
|
+
"height": 1350,
|
|
559
|
+
"width": 1080
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
]
|
|
563
|
+
}
|
|
564
|
+
```
|
|
565
|
+
|
|
566
|
+
|
|
567
|
+
```javascript
|
|
568
|
+
/**
|
|
569
|
+
* Get post, highlight, reel by mediaId
|
|
570
|
+
* @param {string} mediaId
|
|
571
|
+
* @param {string} request headers @optional - required for token authentication
|
|
572
|
+
*/
|
|
573
|
+
try {
|
|
574
|
+
const requestHeaders = {
|
|
575
|
+
'Authorization':userDetails.headers["ig-set-authorization"],
|
|
576
|
+
"Ig-U-Ds-User-Id": userDetails.headers["ig-set-ig-u-ds-user-id"],
|
|
577
|
+
"Ig-U-Rur": userDetails.headers["ig-set-ig-u-rur"],
|
|
578
|
+
"X-Ig-Www-Claim": userDetails.headers["x-ig-set-www-claim"],
|
|
579
|
+
'User-Agent': 'Instagram 177.0.0.30.119 Android (18/4.3; 320dpi; 720x1280; Xiaomi; HM 1SW; armani; qcom; en_US)',
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
const post = await igService.fetchContentByMediaId('3691741226493_45705178442', requestHeaders);
|
|
583
|
+
console.log(post);
|
|
584
|
+
} catch (error: any) {
|
|
585
|
+
console.error('Unknown error:', error);
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
{
|
|
589
|
+
"username": "username",
|
|
590
|
+
"name": "Dummy Name",
|
|
591
|
+
"postType": "story",
|
|
592
|
+
"media_id": "369464054_458376602",
|
|
593
|
+
"shortcode": "DNFoF7y",
|
|
594
|
+
"createdAt": 1754155492,
|
|
595
|
+
"media": [
|
|
596
|
+
{
|
|
597
|
+
"like_and_view_counts_disabled": false,
|
|
598
|
+
"has_privately_liked": false,
|
|
599
|
+
"is_post_live_clips_media": false,
|
|
600
|
+
"is_quiet_post": false,
|
|
601
|
+
"taken_at": 1754655492,
|
|
602
|
+
"media_type": 2,
|
|
603
|
+
"code": "DUMMY_CODE_123",
|
|
604
|
+
"has_views_fetching": true,
|
|
605
|
+
"image_versions2": {
|
|
606
|
+
"candidates": [
|
|
607
|
+
{
|
|
608
|
+
"height": 1136,
|
|
609
|
+
"width": 640,
|
|
610
|
+
"url": "https://example.com/image1_1136x640.jpg"
|
|
611
|
+
},
|
|
612
|
+
{
|
|
613
|
+
"height": 852,
|
|
614
|
+
"width": 480,
|
|
615
|
+
"url": "https://example.com/image2_852x480.jpg"
|
|
616
|
+
},
|
|
617
|
+
{
|
|
618
|
+
"height": 568,
|
|
619
|
+
"width": 320,
|
|
620
|
+
"url": "https://example.com/image3_568x320.jpg"
|
|
621
|
+
},
|
|
622
|
+
{
|
|
623
|
+
"height": 426,
|
|
624
|
+
"width": 240,
|
|
625
|
+
"url": "https://example.com/image4_426x240.jpg"
|
|
626
|
+
},
|
|
627
|
+
{
|
|
628
|
+
"height": 640,
|
|
629
|
+
"width": 640,
|
|
630
|
+
"url": "https://example.com/image5_640x640.jpg"
|
|
631
|
+
}
|
|
632
|
+
]
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
]
|
|
636
|
+
}
|
|
637
|
+
```
|
|
638
|
+
|
|
639
|
+
|
|
640
|
+
``` javascript
|
|
641
|
+
/**
|
|
642
|
+
* Follow Account
|
|
643
|
+
* @param {string} username or userId
|
|
644
|
+
* @param {string} request headers @optional - required for token authentication
|
|
645
|
+
*/
|
|
646
|
+
try {
|
|
647
|
+
const requestHeaders = {
|
|
648
|
+
'Authorization':userDetails.headers["ig-set-authorization"],
|
|
649
|
+
"Ig-U-Ds-User-Id": userDetails.headers["ig-set-ig-u-ds-user-id"],
|
|
650
|
+
"Ig-U-Rur": userDetails.headers["ig-set-ig-u-rur"],
|
|
651
|
+
"X-Ig-Www-Claim": userDetails.headers["x-ig-set-www-claim"],
|
|
652
|
+
"User-Agent": 'Instagram 177.0.0.30.119 Android (18/4.3; 320dpi; 720x1280; Xiaomi; HM 1SW; armani; qcom; en_US)',
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
const followed = await igService.follow('usernameOrId', requestHeaders);
|
|
656
|
+
console.log(followed);
|
|
657
|
+
|
|
658
|
+
} catch (error: any) {
|
|
659
|
+
console.error('Unknown error:', error);
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
{
|
|
663
|
+
"following": true,
|
|
664
|
+
"is_bestie": false,
|
|
665
|
+
"is_feed_favorite": false,
|
|
666
|
+
"is_private": false,
|
|
667
|
+
"is_restricted": false,
|
|
668
|
+
"incoming_request": false,
|
|
669
|
+
"outgoing_request": false,
|
|
670
|
+
"followed_by": false,
|
|
671
|
+
"muting": false,
|
|
672
|
+
"blocking": false,
|
|
673
|
+
"is_eligible_to_subscribe": false,
|
|
674
|
+
"subscribed": false
|
|
675
|
+
}
|
|
676
|
+
```
|
|
677
|
+
|
|
678
|
+
``` javascript
|
|
679
|
+
/**
|
|
680
|
+
* Like Post
|
|
681
|
+
* @param {string} shortCode
|
|
682
|
+
* @param {string} request headers @optional - required for token authentication
|
|
683
|
+
*/
|
|
684
|
+
try {
|
|
685
|
+
const requestHeaders = {
|
|
686
|
+
'Authorization':userDetails.headers["ig-set-authorization"],
|
|
687
|
+
"Ig-U-Ds-User-Id": userDetails.headers["ig-set-ig-u-ds-user-id"],
|
|
688
|
+
"Ig-U-Rur": userDetails.headers["ig-set-ig-u-rur"],
|
|
689
|
+
"X-Ig-Www-Claim": userDetails.headers["x-ig-set-www-claim"],
|
|
690
|
+
'User-Agent': 'Instagram 177.0.0.30.119 Android (18/4.3; 320dpi; 720x1280; Xiaomi; HM 1SW; armani; qcom; en_US)',
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
const liked = await igService.like('shortCode', requestHeaders);
|
|
694
|
+
console.log(liked);
|
|
695
|
+
|
|
696
|
+
} catch (error: any) {
|
|
697
|
+
console.error('Unknown error:', error);
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
{
|
|
701
|
+
"status": "ok"
|
|
702
|
+
}
|
|
703
|
+
```
|
|
704
|
+
|
|
705
|
+
## License
|
|
706
|
+
|
|
707
|
+
Apache Version 2.0
|
|
708
|
+
|
|
709
|
+
See [LICENSE](https://github.com/appit-online/insta-api-wrapper/blob/master/LICENSE)
|