@mattxcz/n8n-nodes-instagram-scraper 0.1.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 ADDED
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 tiagohintz (original n8n-nodes-instagram-private-api-wrapped)
4
+ Copyright (c) 2026 Matouš Bečvář (this fork, n8n-nodes-instagram-scraper)
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,68 @@
1
+ # n8n-nodes-instagram-scraper
2
+
3
+ n8n community node that extracts Instagram post/reel metadata (title, caption, thumbnail, likes, comments, author, date, media type) using an authenticated session. Because it authenticates as a real logged-in account, it also works for age-restricted (18+) content that Instagram hides from anonymous/bot requests.
4
+
5
+ This is a fork of [n8n-nodes-instagram-private-api-wrapped](https://github.com/tiagohintz/n8n-nodes-instagram-private-api-wrapped) by tiagohintz (MIT licensed), trimmed down and extended specifically for metadata scraping:
6
+
7
+ - Added **Post -> Get Info by URL**: paste any `instagram.com/p|reel|reels|tv/<shortcode>` URL and get back a flat, ready-to-use object (`title`, `description`, `thumbnail`, `likeCount`, `commentCount`, `viewCount`, `author`, `authorFullName`, `takenAt`, `mediaType`, `isVideo`).
8
+ - Shortcode -> media ID conversion is done locally (same algorithm Instagram itself uses), so unlike GraphQL-based scrapers this doesn't depend on Instagram's `doc_id`, which rotates every few weeks and breaks those scrapers.
9
+ - Removed operations unrelated to metadata scraping (posting, liking, follow/unfollow, direct messages) to keep the node small and the maintenance surface minimal.
10
+ - Session-only authentication (no username/password stored anywhere), same as the upstream project.
11
+
12
+ ## Why session data instead of username/password
13
+
14
+ Instagram aggressively rate-limits and flags direct username/password logins from automation tools. Using a `sessionid`/`csrftoken` cookie pair extracted from an already-logged-in browser session is far more reliable and is what every serious Instagram automation library (instagrapi, instagram-private-api, gallery-dl, yt-dlp) does today.
15
+
16
+ **Security note:** treat your session data like a password. Whoever has it can act as your Instagram account. Use a dedicated account for automation if possible, store the credential only in n8n's encrypted credential store, and never commit it to git or paste it anywhere else.
17
+
18
+ ## Installation
19
+
20
+ ### Option A: Community Nodes UI (after you publish to npm)
21
+
22
+ Settings -> Community Nodes -> Install -> package name: `@mattxcz/n8n-nodes-instagram-scraper`
23
+
24
+ ### Option B: Custom extensions folder (private, no npm needed)
25
+
26
+ ```bash
27
+ npm install
28
+ npm run build
29
+ ```
30
+
31
+ Copy the whole folder (or just `dist/`, `package.json`, `README.md`, `LICENSE`) into your n8n custom extensions directory (commonly `~/.n8n/custom/n8n-nodes-instagram-scraper`), then restart n8n.
32
+
33
+ ## Getting session data
34
+
35
+ 1. Log into instagram.com in your browser with the account you want to use for scraping.
36
+ 2. Open DevTools -> Application/Storage -> Cookies -> `https://www.instagram.com`.
37
+ 3. Copy the values of `sessionid` and `csrftoken`.
38
+ 4. In the n8n credential, paste JSON in this shape:
39
+
40
+ ```json
41
+ {
42
+ "cookies": [
43
+ { "key": "sessionid", "value": "PASTE_HERE", "domain": ".instagram.com", "path": "/" },
44
+ { "key": "csrftoken", "value": "PASTE_HERE", "domain": ".instagram.com", "path": "/" }
45
+ ]
46
+ }
47
+ ```
48
+
49
+ (Exact serialized shape depends on `instagram-private-api`'s `state.serialize()` format — if the node's built-in "Test" button on the credential fails, check the error message, the library is picky about the exact cookie object keys.)
50
+
51
+ ## Usage
52
+
53
+ 1. Add the **Instagram Scraper** node to your workflow.
54
+ 2. Resource: `Post`, Operation: `Get Info by URL`.
55
+ 3. URL: `{{ $json.url }}` or a hard-coded post/reel link.
56
+ 4. Output fields: `title`, `description`, `thumbnail`, `likeCount`, `commentCount`, `viewCount`, `author`, `authorFullName`, `takenAt`, `mediaType`, `isVideo`.
57
+
58
+ ## Maintenance
59
+
60
+ Instagram can change its private API at any time without notice; this is an unofficial, reverse-engineered integration, not the official Graph API. If it stops working, check:
61
+
62
+ 1. Whether `instagram-private-api` has a newer version that fixes it (`npm update instagram-private-api`).
63
+ 2. Whether your session data expired (re-extract it).
64
+ 3. Whether Instagram flagged the account (wait 24-48h, or use a different account).
65
+
66
+ ## License
67
+
68
+ MIT — see [LICENSE](./LICENSE). Original work Copyright tiagohintz, modifications Copyright Matouš Bečvář.
@@ -0,0 +1,6 @@
1
+ import { Instagram } from './nodes/Instagram.node';
2
+ import { InstagramCredentials } from './nodes/InstagramCredentials';
3
+ export { Instagram, InstagramCredentials };
4
+ export { InstagramClient } from './lib/client';
5
+ export * from './lib/types';
6
+ export { Utils } from './lib/utils';
package/dist/index.js ADDED
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.Utils = exports.InstagramClient = exports.InstagramCredentials = exports.Instagram = void 0;
18
+ const Instagram_node_1 = require("./nodes/Instagram.node");
19
+ Object.defineProperty(exports, "Instagram", { enumerable: true, get: function () { return Instagram_node_1.Instagram; } });
20
+ const InstagramCredentials_1 = require("./nodes/InstagramCredentials");
21
+ Object.defineProperty(exports, "InstagramCredentials", { enumerable: true, get: function () { return InstagramCredentials_1.InstagramCredentials; } });
22
+ var client_1 = require("./lib/client");
23
+ Object.defineProperty(exports, "InstagramClient", { enumerable: true, get: function () { return client_1.InstagramClient; } });
24
+ __exportStar(require("./lib/types"), exports);
25
+ var utils_1 = require("./lib/utils");
26
+ Object.defineProperty(exports, "Utils", { enumerable: true, get: function () { return utils_1.Utils; } });
27
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,2DAAmD;AAG1C,0FAHA,0BAAS,OAGA;AAFlB,uEAAoE;AAEhD,qGAFX,2CAAoB,OAEW;AACxC,uCAA+C;AAAtC,yGAAA,eAAe,OAAA;AACxB,8CAA4B;AAC5B,qCAAoC;AAA3B,8FAAA,KAAK,OAAA"}
@@ -0,0 +1,15 @@
1
+ import { IInstagramCredentials, IInstagramUser, IInstagramTimelineFeed, IInstagramMediaInfo, IInstagramPostSummary } from './types';
2
+ export declare class InstagramClient {
3
+ private client;
4
+ private isAuthenticated;
5
+ constructor(credentials?: IInstagramCredentials);
6
+ authenticate(credentials: IInstagramCredentials): Promise<void>;
7
+ authenticateWithRetry(credentials: IInstagramCredentials, maxRetries?: number): Promise<void>;
8
+ private ensureAuthenticated;
9
+ getUserInfo(username: string): Promise<IInstagramUser>;
10
+ getTimelineFeed(maxId?: string): Promise<IInstagramTimelineFeed>;
11
+ getMediaInfo(mediaId: string): Promise<IInstagramMediaInfo>;
12
+ getPostByUrl(url: string): Promise<IInstagramPostSummary>;
13
+ saveSession(): Promise<string>;
14
+ loadSession(sessionData: string): Promise<void>;
15
+ }
@@ -0,0 +1,231 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.InstagramClient = void 0;
4
+ const instagram_private_api_1 = require("instagram-private-api");
5
+ const utils_1 = require("./utils");
6
+ class InstagramClient {
7
+ constructor(credentials) {
8
+ this.isAuthenticated = false;
9
+ this.client = new instagram_private_api_1.IgApiClient();
10
+ if (credentials) {
11
+ this.client.state.generateDevice('instagram_user');
12
+ if (credentials.proxyUrl) {
13
+ this.client.state.proxyUrl = credentials.proxyUrl;
14
+ }
15
+ }
16
+ }
17
+ async authenticate(credentials) {
18
+ try {
19
+ if (credentials.proxyUrl) {
20
+ this.client.state.proxyUrl = credentials.proxyUrl;
21
+ }
22
+ if (!credentials.sessionData) {
23
+ throw new Error('Session data is required. Extract it from a logged-in browser session (sessionid + csrftoken cookies) and paste it as JSON.');
24
+ }
25
+ try {
26
+ const sessionData = typeof credentials.sessionData === 'string'
27
+ ? JSON.parse(credentials.sessionData)
28
+ : credentials.sessionData;
29
+ await this.client.state.deserialize(sessionData);
30
+ const userInfo = await this.client.user.info(this.client.state.cookieUserId);
31
+ void userInfo;
32
+ this.isAuthenticated = true;
33
+ return;
34
+ }
35
+ catch (sessionError) {
36
+ throw new Error(`Invalid or expired session data. Please extract a fresh session and update your credentials. Error: ${sessionError instanceof Error ? sessionError.message : 'Unknown error'}`);
37
+ }
38
+ }
39
+ catch (error) {
40
+ this.isAuthenticated = false;
41
+ if (error instanceof Error) {
42
+ const errorMessage = error.message.toLowerCase();
43
+ if (errorMessage.includes('login_required') || errorMessage.includes('unauthorized')) {
44
+ throw new Error('Session expired or invalid. Extract a fresh session and update your credentials.');
45
+ }
46
+ else if (errorMessage.includes('challenge_required')) {
47
+ throw new Error('Instagram session requires verification. Log in through the app, complete any challenge, then extract a fresh session.');
48
+ }
49
+ else if (errorMessage.includes('checkpoint_required')) {
50
+ throw new Error('Instagram account requires verification. Complete it in the app, wait 24-48h, then extract a fresh session.');
51
+ }
52
+ else if (errorMessage.includes('429') || errorMessage.includes('too many requests')) {
53
+ throw new Error('Rate limited by Instagram. Wait a few hours and try again.');
54
+ }
55
+ throw error;
56
+ }
57
+ throw new Error('Authentication failed: Unknown error occurred.');
58
+ }
59
+ }
60
+ async authenticateWithRetry(credentials, maxRetries = 3) {
61
+ var _a;
62
+ let lastError = null;
63
+ for (let attempt = 1; attempt <= maxRetries; attempt++) {
64
+ try {
65
+ if (attempt > 1) {
66
+ const delay = Math.min(1000 * Math.pow(2, attempt - 1), 10000);
67
+ await utils_1.Utils.delay(delay);
68
+ }
69
+ await this.authenticate(credentials);
70
+ return;
71
+ }
72
+ catch (error) {
73
+ lastError = error instanceof Error ? error : new Error('Unknown error');
74
+ if (lastError.message.includes('challenge_required') ||
75
+ lastError.message.includes('checkpoint_required')) {
76
+ throw lastError;
77
+ }
78
+ }
79
+ }
80
+ throw new Error(`Authentication failed after ${maxRetries} attempts. Last error: ${(_a = lastError === null || lastError === void 0 ? void 0 : lastError.message) !== null && _a !== void 0 ? _a : 'Unknown error'}`);
81
+ }
82
+ ensureAuthenticated() {
83
+ if (!this.isAuthenticated) {
84
+ throw new Error('Client is not authenticated. Please call authenticate() first.');
85
+ }
86
+ }
87
+ async getUserInfo(username) {
88
+ this.ensureAuthenticated();
89
+ try {
90
+ const user = await this.client.user.searchExact(username);
91
+ const userInfo = await this.client.user.info(user.pk);
92
+ return {
93
+ pk: user.pk.toString(),
94
+ username: user.username,
95
+ full_name: user.full_name,
96
+ profile_pic_url: user.profile_pic_url,
97
+ is_verified: user.is_verified || false,
98
+ follower_count: userInfo.follower_count || 0,
99
+ following_count: userInfo.following_count || 0,
100
+ media_count: userInfo.media_count || 0,
101
+ biography: userInfo.biography || '',
102
+ is_private: userInfo.is_private || false,
103
+ };
104
+ }
105
+ catch (error) {
106
+ throw new Error(`Failed to get user info: ${utils_1.Utils.formatError(error)}`);
107
+ }
108
+ }
109
+ async getTimelineFeed(maxId) {
110
+ this.ensureAuthenticated();
111
+ try {
112
+ const feed = this.client.feed.timeline();
113
+ const response = await feed.request();
114
+ return {
115
+ items: response.feed_items.map((item) => {
116
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
117
+ return ({
118
+ id: ((_a = item.media) === null || _a === void 0 ? void 0 : _a.id) || item.id,
119
+ code: ((_b = item.media) === null || _b === void 0 ? void 0 : _b.code) || item.code,
120
+ taken_at: ((_c = item.media) === null || _c === void 0 ? void 0 : _c.taken_at) || item.taken_at,
121
+ media_type: ((_d = item.media) === null || _d === void 0 ? void 0 : _d.media_type) || item.media_type,
122
+ caption: ((_e = item.media) === null || _e === void 0 ? void 0 : _e.caption) ? { text: item.media.caption.text } : null,
123
+ like_count: ((_f = item.media) === null || _f === void 0 ? void 0 : _f.like_count) || 0,
124
+ comment_count: ((_g = item.media) === null || _g === void 0 ? void 0 : _g.comment_count) || 0,
125
+ user: {
126
+ id: ((_k = (_j = (_h = item.media) === null || _h === void 0 ? void 0 : _h.user) === null || _j === void 0 ? void 0 : _j.pk) === null || _k === void 0 ? void 0 : _k.toString()) || ((_m = (_l = item.user) === null || _l === void 0 ? void 0 : _l.pk) === null || _m === void 0 ? void 0 : _m.toString()),
127
+ username: ((_p = (_o = item.media) === null || _o === void 0 ? void 0 : _o.user) === null || _p === void 0 ? void 0 : _p.username) || ((_q = item.user) === null || _q === void 0 ? void 0 : _q.username),
128
+ full_name: ((_s = (_r = item.media) === null || _r === void 0 ? void 0 : _r.user) === null || _s === void 0 ? void 0 : _s.full_name) || ((_t = item.user) === null || _t === void 0 ? void 0 : _t.full_name),
129
+ },
130
+ });
131
+ }),
132
+ more_available: response.more_available || false,
133
+ next_max_id: response.next_max_id,
134
+ };
135
+ }
136
+ catch (error) {
137
+ throw new Error(`Failed to get timeline feed: ${utils_1.Utils.formatError(error)}`);
138
+ }
139
+ }
140
+ async getMediaInfo(mediaId) {
141
+ var _a, _b;
142
+ this.ensureAuthenticated();
143
+ try {
144
+ const media = await this.client.media.info(mediaId);
145
+ const item = media.items[0];
146
+ return {
147
+ id: item.id,
148
+ code: item.code,
149
+ taken_at: item.taken_at,
150
+ media_type: item.media_type,
151
+ like_count: item.like_count,
152
+ comment_count: item.comment_count,
153
+ view_count: item.view_count,
154
+ play_count: item.play_count,
155
+ caption: (_b = (_a = item.caption) === null || _a === void 0 ? void 0 : _a.text) !== null && _b !== void 0 ? _b : null,
156
+ user: {
157
+ pk: item.user.pk.toString(),
158
+ username: item.user.username,
159
+ full_name: item.user.full_name,
160
+ },
161
+ image_versions2: item.image_versions2,
162
+ video_versions: item.video_versions || [],
163
+ carousel_media: item.carousel_media,
164
+ };
165
+ }
166
+ catch (error) {
167
+ throw new Error(`Failed to get media info: ${utils_1.Utils.formatError(error)}`);
168
+ }
169
+ }
170
+ async getPostByUrl(url) {
171
+ var _a, _b, _c, _d, _e, _f;
172
+ this.ensureAuthenticated();
173
+ const shortcode = utils_1.Utils.extractShortcode(url);
174
+ if (!shortcode) {
175
+ throw new Error(`Could not find a post/reel shortcode in URL "${url}". Expected something like https://www.instagram.com/reel/SHORTCODE/`);
176
+ }
177
+ const mediaId = utils_1.Utils.shortcodeToMediaId(shortcode);
178
+ const info = await this.getMediaInfo(mediaId);
179
+ const mediaTypeMap = {
180
+ 1: 'photo',
181
+ 2: 'video',
182
+ 8: 'carousel',
183
+ };
184
+ const mediaType = (_a = mediaTypeMap[info.media_type]) !== null && _a !== void 0 ? _a : 'unknown';
185
+ const isVideo = mediaType === 'video';
186
+ let thumbnail = utils_1.Utils.bestImageUrl(info.image_versions2);
187
+ if (!thumbnail && info.carousel_media && info.carousel_media.length > 0) {
188
+ thumbnail = utils_1.Utils.bestImageUrl(info.carousel_media[0].image_versions2);
189
+ }
190
+ const caption = (_b = info.caption) !== null && _b !== void 0 ? _b : '';
191
+ const firstLine = caption.split('\n')[0].trim();
192
+ return {
193
+ url,
194
+ shortcode,
195
+ mediaId,
196
+ title: firstLine || caption.slice(0, 100) || `Instagram post by @${info.user.username}`,
197
+ description: caption,
198
+ thumbnail,
199
+ isVideo,
200
+ mediaType,
201
+ likeCount: (_c = info.like_count) !== null && _c !== void 0 ? _c : 0,
202
+ commentCount: (_d = info.comment_count) !== null && _d !== void 0 ? _d : 0,
203
+ viewCount: (_f = (_e = info.view_count) !== null && _e !== void 0 ? _e : info.play_count) !== null && _f !== void 0 ? _f : null,
204
+ author: info.user.username,
205
+ authorFullName: info.user.full_name,
206
+ takenAt: utils_1.Utils.formatTimestamp(info.taken_at),
207
+ takenAtTimestamp: info.taken_at,
208
+ };
209
+ }
210
+ async saveSession() {
211
+ try {
212
+ return JSON.stringify(await this.client.state.serialize());
213
+ }
214
+ catch (error) {
215
+ throw new Error(`Failed to save session: ${utils_1.Utils.formatError(error)}`);
216
+ }
217
+ }
218
+ async loadSession(sessionData) {
219
+ try {
220
+ const parsed = typeof sessionData === 'string' ? JSON.parse(sessionData) : sessionData;
221
+ await this.client.state.deserialize(parsed);
222
+ this.isAuthenticated = true;
223
+ }
224
+ catch (error) {
225
+ this.isAuthenticated = false;
226
+ throw new Error(`Failed to load session: ${utils_1.Utils.formatError(error)}`);
227
+ }
228
+ }
229
+ }
230
+ exports.InstagramClient = InstagramClient;
231
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/lib/client.ts"],"names":[],"mappings":";;;AAAA,iEAAoD;AASpD,mCAAgC;AAEhC,MAAa,eAAe;IAI3B,YAAY,WAAmC;QAFvC,oBAAe,GAAY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ACD;AA1QD,0CA0QC"}
@@ -0,0 +1,147 @@
1
+ export interface IInstagramCredentials {
2
+ sessionData: string;
3
+ proxyUrl?: string;
4
+ }
5
+ export interface IInstagramUserInfo {
6
+ id: string;
7
+ username: string;
8
+ full_name: string;
9
+ profile_pic_url: string;
10
+ is_verified: boolean;
11
+ follower_count: number;
12
+ following_count: number;
13
+ media_count: number;
14
+ biography: string;
15
+ }
16
+ export interface IInstagramUser {
17
+ pk: string;
18
+ username: string;
19
+ full_name: string;
20
+ profile_pic_url: string;
21
+ is_verified: boolean;
22
+ follower_count: number;
23
+ following_count: number;
24
+ media_count: number;
25
+ biography: string;
26
+ is_private: boolean;
27
+ }
28
+ export interface IInstagramTimelineFeed {
29
+ items: IInstagramMediaItem[];
30
+ more_available: boolean;
31
+ next_max_id?: string;
32
+ }
33
+ export interface IInstagramUserFeed {
34
+ items: IInstagramMediaItem[];
35
+ more_available: boolean;
36
+ next_max_id?: string;
37
+ }
38
+ export interface IInstagramCarouselItem {
39
+ id: string;
40
+ media_type: number;
41
+ image_versions2?: {
42
+ candidates: Array<{
43
+ url: string;
44
+ width: number;
45
+ height: number;
46
+ }>;
47
+ };
48
+ video_versions?: Array<{
49
+ url: string;
50
+ width: number;
51
+ height: number;
52
+ }>;
53
+ }
54
+ export interface IInstagramMediaInfo {
55
+ id: string;
56
+ code: string;
57
+ taken_at: number;
58
+ media_type: number;
59
+ like_count: number;
60
+ comment_count: number;
61
+ view_count?: number;
62
+ play_count?: number;
63
+ caption?: string | null;
64
+ user: {
65
+ pk: string;
66
+ username: string;
67
+ full_name: string;
68
+ };
69
+ image_versions2?: {
70
+ candidates: Array<{
71
+ url: string;
72
+ width: number;
73
+ height: number;
74
+ }>;
75
+ };
76
+ video_versions?: Array<{
77
+ url: string;
78
+ width: number;
79
+ height: number;
80
+ }>;
81
+ carousel_media?: IInstagramCarouselItem[];
82
+ }
83
+ export interface IInstagramPostSummary {
84
+ url: string;
85
+ shortcode: string;
86
+ mediaId: string;
87
+ title: string;
88
+ description: string;
89
+ thumbnail: string;
90
+ isVideo: boolean;
91
+ mediaType: 'photo' | 'video' | 'carousel' | 'unknown';
92
+ likeCount: number;
93
+ commentCount: number;
94
+ viewCount: number | null;
95
+ author: string;
96
+ authorFullName: string;
97
+ takenAt: string;
98
+ takenAtTimestamp: number;
99
+ }
100
+ export interface IInstagramComment {
101
+ pk: string;
102
+ text: string;
103
+ created_at: number;
104
+ user: {
105
+ pk: string;
106
+ username: string;
107
+ full_name: string;
108
+ profile_pic_url: string;
109
+ };
110
+ }
111
+ export interface IInstagramDirectThread {
112
+ thread_id: string;
113
+ thread_title: string;
114
+ users: Array<{
115
+ pk: string;
116
+ username: string;
117
+ full_name: string;
118
+ profile_pic_url: string;
119
+ }>;
120
+ }
121
+ export interface IInstagramDirectMessage {
122
+ id: string;
123
+ text: string;
124
+ timestamp: number;
125
+ user_id: string;
126
+ }
127
+ export interface IInstagramMediaItem {
128
+ id: string;
129
+ code: string;
130
+ taken_at: number;
131
+ media_type: number;
132
+ caption?: {
133
+ text: string;
134
+ } | null;
135
+ like_count: number;
136
+ comment_count: number;
137
+ user: {
138
+ id: string;
139
+ username: string;
140
+ full_name: string;
141
+ };
142
+ }
143
+ export interface RetryOptions {
144
+ maxRetries: number;
145
+ baseDelay: number;
146
+ maxDelay: number;
147
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/lib/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,18 @@
1
+ import { RetryOptions } from './types';
2
+ export declare class Utils {
3
+ static executeWithRetry<T>(operation: () => Promise<T>, options?: Partial<RetryOptions>): Promise<T>;
4
+ static delay(ms: number): Promise<void>;
5
+ static randomDelay(min?: number, max?: number): Promise<void>;
6
+ static formatError(error: any): string;
7
+ static isRateLimitError(error: any): boolean;
8
+ static extractShortcode(url: string): string | null;
9
+ static shortcodeToMediaId(shortcode: string): string;
10
+ static formatTimestamp(timestamp: number): string;
11
+ static bestImageUrl(imageVersions2?: {
12
+ candidates: Array<{
13
+ url: string;
14
+ width: number;
15
+ height: number;
16
+ }>;
17
+ }): string;
18
+ }
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Utils = void 0;
4
+ class Utils {
5
+ static async executeWithRetry(operation, options = {}) {
6
+ const { maxRetries = 3, baseDelay = 1000, maxDelay = 10000 } = options;
7
+ for (let attempt = 0; attempt < maxRetries; attempt++) {
8
+ try {
9
+ return await operation();
10
+ }
11
+ catch (error) {
12
+ if (attempt === maxRetries - 1) {
13
+ throw error;
14
+ }
15
+ const delay = Math.min(baseDelay * Math.pow(2, attempt), maxDelay);
16
+ await this.delay(delay);
17
+ }
18
+ }
19
+ throw new Error('Maximum retries exceeded');
20
+ }
21
+ static async delay(ms) {
22
+ return new Promise((resolve) => setTimeout(resolve, ms));
23
+ }
24
+ static async randomDelay(min = 1000, max = 3000) {
25
+ const delay = Math.floor(Math.random() * (max - min + 1)) + min;
26
+ await this.delay(delay);
27
+ }
28
+ static formatError(error) {
29
+ if (error instanceof Error) {
30
+ return error.message;
31
+ }
32
+ if (typeof error === 'string') {
33
+ return error;
34
+ }
35
+ return 'Unknown error occurred';
36
+ }
37
+ static isRateLimitError(error) {
38
+ const errorMsg = this.formatError(error).toLowerCase();
39
+ return (errorMsg.includes('rate limit') ||
40
+ errorMsg.includes('too many requests') ||
41
+ errorMsg.includes('429'));
42
+ }
43
+ static extractShortcode(url) {
44
+ if (!url || typeof url !== 'string') {
45
+ return null;
46
+ }
47
+ const match = url.match(/instagram\.com\/(?:[^/]+\/)?(?:p|reel|reels|tv)\/([A-Za-z0-9_-]+)/i);
48
+ return match ? match[1] : null;
49
+ }
50
+ static shortcodeToMediaId(shortcode) {
51
+ const alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_';
52
+ let mediaId = BigInt(0);
53
+ for (const char of shortcode) {
54
+ const index = alphabet.indexOf(char);
55
+ if (index === -1) {
56
+ throw new Error(`Invalid character "${char}" in shortcode "${shortcode}"`);
57
+ }
58
+ mediaId = mediaId * BigInt(64) + BigInt(index);
59
+ }
60
+ return mediaId.toString();
61
+ }
62
+ static formatTimestamp(timestamp) {
63
+ try {
64
+ return new Date(timestamp * 1000).toISOString();
65
+ }
66
+ catch {
67
+ return new Date().toISOString();
68
+ }
69
+ }
70
+ static bestImageUrl(imageVersions2) {
71
+ if (!imageVersions2 || !imageVersions2.candidates || imageVersions2.candidates.length === 0) {
72
+ return '';
73
+ }
74
+ return imageVersions2.candidates.reduce((best, current) => current.width > best.width ? current : best).url;
75
+ }
76
+ }
77
+ exports.Utils = Utils;
78
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/lib/utils.ts"],"names":[],"mappings":";;;AAKA,MAAa,KAAK;IAIjB,MAAM,CAAC,KAAK,CAAC,gBAAgB,CAC5B,SAA2B,EAC3B,UAAiC,EAAE;QAEnC,MAAM,EAAE,UAAU,GAAG,CAAC,EAAE,SAAS,GAAG,IAAI,EAAE,QAAQ,GAAG,KAAK,EAAE,GAAG,OAAO,CAAC;QAEvE,KAAK,IAAI,OAAO,GAAG,CAAC,EAAE,OAAO,GAAG,UAAU,EAAE,OAAO,EAAE,EAAE,CAAC;YACvD,IAAI,CAAC;gBACJ,OAAO,MAAM,SAAS,EAAE,CAAC;YAC1B,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBAChB,IAAI,OAAO,KAAK,UAAU,GAAG,CAAC,EAAE,CAAC;oBAChC,MAAM,KAAK,CAAC;gBACb,CAAC;gBACD,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,CAAC,E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,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE,CACzD,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAC3C,CAAC,GAAG,CAAC;IACP,CAAC;CACD;AAhID,sBAgIC"}
@@ -0,0 +1,5 @@
1
+ import { IExecuteFunctions, INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow';
2
+ export declare class Instagram implements INodeType {
3
+ description: INodeTypeDescription;
4
+ execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]>;
5
+ }