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.
@@ -0,0 +1,208 @@
1
+ export interface IGUserMetadata {
2
+ /** Instagram user id */
3
+ id: number;
4
+ /** Instagram username */
5
+ username: string;
6
+ /** full name of instagram account */
7
+ fullname: string;
8
+ /** followers count */
9
+ followers: number;
10
+ /** following count */
11
+ following: number;
12
+ /** total post */
13
+ post_count: number;
14
+ /** is_private? */
15
+ is_private: boolean;
16
+ is_verified: boolean;
17
+ /** full instagram bio */
18
+ biography: string;
19
+ /** external url given by user */
20
+ external_url: string;
21
+ /** total of an IGTV videos if has igtv post */
22
+ total_igtv_videos: number;
23
+ has_videos: boolean;
24
+ /** url of instagram profile picture at HD / Original Quality */
25
+ hd_profile_pic_url_info: HDProfilePic;
26
+ has_highlight_reels: boolean;
27
+ has_guides: boolean;
28
+ is_business: boolean;
29
+ /** contact phone number if user set their phone number to public */
30
+ contact_phone_number: string;
31
+ /** contact email */
32
+ public_email: string;
33
+ /** account type e.g Business | Personal .etc */
34
+ account_type: number;
35
+ items: FeedItem[];
36
+ }
37
+ export interface UserGraphQL {
38
+ user: UserDetails;
39
+ items: FeedItem[];
40
+ more_available: boolean;
41
+ next_max_id: string;
42
+ status: string;
43
+ }
44
+ export interface FeedItem {
45
+ like_and_view_counts_disabled: boolean;
46
+ has_privately_liked: boolean;
47
+ is_post_live_clips_media: boolean;
48
+ is_quiet_post: boolean;
49
+ taken_at: number;
50
+ has_tagged_users: boolean;
51
+ media_type: number;
52
+ code: string;
53
+ caption?: {
54
+ text: string;
55
+ };
56
+ play_count?: number;
57
+ has_views_fetching?: boolean;
58
+ ig_play_count?: number;
59
+ image_versions2?: {
60
+ candidates: {
61
+ height: number;
62
+ width: number;
63
+ url: string;
64
+ }[];
65
+ };
66
+ original_width: number;
67
+ original_height: number;
68
+ is_artist_pick: boolean;
69
+ location?: {
70
+ pk: string;
71
+ facebook_places_id: string;
72
+ external_source: string;
73
+ name: string;
74
+ address: string;
75
+ city: string;
76
+ has_viewer_saved: boolean;
77
+ short_name: string;
78
+ lng: number;
79
+ lat: number;
80
+ };
81
+ lng?: number;
82
+ lat?: number;
83
+ like_count: number;
84
+ number_of_qualities?: number;
85
+ video_versions?: {
86
+ id: string;
87
+ url: string;
88
+ type: number;
89
+ height: number;
90
+ width: number;
91
+ bandwidth: number | null;
92
+ }[];
93
+ video_duration?: number;
94
+ has_audio?: boolean;
95
+ thumbnail?: string;
96
+ thumbnailDefault?: string;
97
+ url?: string;
98
+ type?: 'image' | 'video';
99
+ dimensions?: {
100
+ height: number;
101
+ width: number;
102
+ };
103
+ }
104
+ export interface UserDetails {
105
+ pk: number;
106
+ username: string;
107
+ full_name: string;
108
+ is_private: boolean;
109
+ profile_pic_url: string;
110
+ profile_pic_id: string;
111
+ is_verified: boolean;
112
+ follow_friction_type: number;
113
+ has_anonymous_profile_picture: boolean;
114
+ media_count: number;
115
+ geo_media_count: number;
116
+ follower_count: number;
117
+ following_count: number;
118
+ following_tag_count: number;
119
+ biography: string;
120
+ external_url: string;
121
+ external_lynx_url: string;
122
+ show_fb_link_on_profile: boolean;
123
+ primary_profile_link_type: number;
124
+ has_biography_translation: boolean;
125
+ total_igtv_videos: number;
126
+ has_videos: boolean;
127
+ total_ar_effects: number;
128
+ usertags_count: number;
129
+ is_favorite: boolean;
130
+ is_interest_account: boolean;
131
+ has_chaining: boolean;
132
+ hd_profile_pic_versions: HDProfilePic[];
133
+ hd_profile_pic_url_info: HDProfilePic;
134
+ mutual_followers_count: number;
135
+ profile_context: string;
136
+ profile_context_links_with_user_ids: ProfileContextLinksWithUserID[];
137
+ profile_context_mutual_follow_ids: number[];
138
+ has_highlight_reels: boolean;
139
+ has_guides: boolean;
140
+ can_be_reported_as_fraud: boolean;
141
+ is_eligible_for_smb_support_flow: boolean;
142
+ smb_support_partner: null;
143
+ direct_messaging: string;
144
+ address_street: string;
145
+ business_contact_method: string;
146
+ category: string;
147
+ city_id: number;
148
+ city_name: string;
149
+ contact_phone_number: string;
150
+ is_call_to_action_enabled: boolean;
151
+ latitude: number;
152
+ longitude: number;
153
+ public_email: string;
154
+ public_phone_country_code: string;
155
+ public_phone_number: string;
156
+ zip: string;
157
+ instagram_location_id: string;
158
+ is_business: boolean;
159
+ professional_conversion_suggested_account_type: number;
160
+ account_type: number;
161
+ can_hide_category: boolean;
162
+ can_hide_public_contacts: boolean;
163
+ should_show_category: boolean;
164
+ should_show_public_contacts: boolean;
165
+ interop_messaging_user_fbid: number;
166
+ account_badges: any[];
167
+ include_direct_blacklist_status: boolean;
168
+ is_potential_business: boolean;
169
+ show_post_insights_entry_point: boolean;
170
+ request_contact_enabled: boolean;
171
+ is_bestie: boolean;
172
+ has_unseen_besties_media: boolean;
173
+ show_account_transparency_details: boolean;
174
+ auto_expand_chaining: boolean;
175
+ highlight_reshare_disabled: boolean;
176
+ is_memorialized: boolean;
177
+ open_external_url_with_in_app_browser: boolean;
178
+ }
179
+ export interface HDProfilePic {
180
+ width: number;
181
+ height: number;
182
+ url: string;
183
+ }
184
+ export interface ProfileContextLinksWithUserID {
185
+ start: number;
186
+ end: number;
187
+ username: string;
188
+ }
189
+ export interface Friendship {
190
+ following: boolean;
191
+ followed_by: boolean;
192
+ incoming_request: boolean;
193
+ outgoing_request: boolean;
194
+ muting: boolean;
195
+ blocking: boolean;
196
+ is_bestie: boolean;
197
+ is_blocking_reel: boolean;
198
+ is_muting_reel: boolean;
199
+ is_private: boolean;
200
+ is_restricted: boolean;
201
+ }
202
+ export interface FriendResp {
203
+ status: string;
204
+ friendship_status: Friendship;
205
+ }
206
+ export interface LikeResponse {
207
+ status: string;
208
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,49 @@
1
+ export * from './PostModels.js';
2
+ export * from './StoriesMetadata.js';
3
+ export * from './UserGraphQlV2.js';
4
+ export * from './UserMetadata.js';
5
+ export * from './LoginData.js';
6
+ /** instagram username */
7
+ export type username = string;
8
+ /** instagram password */
9
+ export type password = string;
10
+ /** instagram post url can be post, reel, tv */
11
+ export type url = string;
12
+ /** Media Type */
13
+ export declare enum MediaType {
14
+ IMAGE = 1,
15
+ VIDEO = 2,
16
+ CAROUSEL = 8
17
+ }
18
+ export declare enum ProductType {
19
+ CAROUSEL = "carousel_container",
20
+ REEL = "clips",
21
+ TV = "igtv",
22
+ STORY = "story",
23
+ SINGLE = "feed"
24
+ }
25
+ export declare enum Typename {
26
+ GraphImage = "GraphImage",
27
+ GraphSidecar = "GraphSidecar",
28
+ GraphVideo = "GraphVideo"
29
+ }
30
+ export declare enum IGPostType {
31
+ 'carousel_container' = "p",
32
+ 'clips' = "reel",
33
+ 'igtv' = "tv",
34
+ 'story' = "story",
35
+ 'feed' = "p"
36
+ }
37
+ /** Mime Type */
38
+ export type MimeType = 'image/jpeg' | 'image/png' | 'video/mp4' | 'video/gif';
39
+ /** csrf token */
40
+ export type csrfToken = string;
41
+ /** instagram post type */
42
+ export type postType = 'p' | 'reel' | 'tv' | 'story' | 'feed';
43
+ /** a formatted shortcode */
44
+ export interface formattedShortcode {
45
+ type: postType | string;
46
+ shortcode: string;
47
+ url: string;
48
+ media_id: number | string;
49
+ }
@@ -0,0 +1,34 @@
1
+ export * from './PostModels.js';
2
+ export * from './StoriesMetadata.js';
3
+ export * from './UserGraphQlV2.js';
4
+ export * from './UserMetadata.js';
5
+ export * from './LoginData.js';
6
+ /** Media Type */
7
+ export var MediaType;
8
+ (function (MediaType) {
9
+ MediaType[MediaType["IMAGE"] = 1] = "IMAGE";
10
+ MediaType[MediaType["VIDEO"] = 2] = "VIDEO";
11
+ MediaType[MediaType["CAROUSEL"] = 8] = "CAROUSEL";
12
+ })(MediaType || (MediaType = {}));
13
+ export var ProductType;
14
+ (function (ProductType) {
15
+ ProductType["CAROUSEL"] = "carousel_container";
16
+ ProductType["REEL"] = "clips";
17
+ ProductType["TV"] = "igtv";
18
+ ProductType["STORY"] = "story";
19
+ ProductType["SINGLE"] = "feed";
20
+ })(ProductType || (ProductType = {}));
21
+ export var Typename;
22
+ (function (Typename) {
23
+ Typename["GraphImage"] = "GraphImage";
24
+ Typename["GraphSidecar"] = "GraphSidecar";
25
+ Typename["GraphVideo"] = "GraphVideo";
26
+ })(Typename || (Typename = {}));
27
+ export var IGPostType;
28
+ (function (IGPostType) {
29
+ IGPostType["carousel_container"] = "p";
30
+ IGPostType["clips"] = "reel";
31
+ IGPostType["igtv"] = "tv";
32
+ IGPostType["story"] = "story";
33
+ IGPostType["feed"] = "p";
34
+ })(IGPostType || (IGPostType = {}));
@@ -0,0 +1,28 @@
1
+ import { formattedShortcode, postType } from '../types/index.js';
2
+ /**
3
+ * convert instagram shortcode into media_id
4
+ * @param shortcode
5
+ * @returns
6
+ */
7
+ export declare const shortcodeToMediaID: (shortcode: string) => string;
8
+ export declare const shortcodeFromMediaID: (mediaId: string) => string;
9
+ /** Instagram post regex */
10
+ export declare const IGPostRegex: RegExp;
11
+ /**
12
+ * format instagram long url to get shortcode
13
+ * @param url a instagram post url
14
+ * @returns {formattedShortcode}
15
+ */
16
+ export declare const shortcodeFormatter: (url: string) => formattedShortcode;
17
+ /**
18
+ * is Instagram Url?
19
+ * @param url instagram post url
20
+ * @returns
21
+ */
22
+ export declare const isIgPostUrl: (url: string) => boolean;
23
+ /**
24
+ * get instagram post type
25
+ * @param type product_type
26
+ * @returns
27
+ */
28
+ export declare const getPostType: (type: string) => postType;
@@ -0,0 +1,76 @@
1
+ import { IGPostType, ProductType } from '../types/index.js';
2
+ import bigInt from "big-integer";
3
+ // https://stackoverflow.com/questions/16758316/where-do-i-find-the-instagram-media-id-of-a-image
4
+ // https://gist.github.com/sclark39/9daf13eea9c0b381667b61e3d2e7bc11
5
+ const lower = 'abcdefghijklmnopqrstuvwxyz';
6
+ const upper = lower.toUpperCase();
7
+ const numbers = '0123456789';
8
+ const igAlphabet = upper + lower + numbers + '-_';
9
+ const bigintAlphabet = numbers + lower;
10
+ /**
11
+ * convert instagram shortcode into media_id
12
+ * @param shortcode
13
+ * @returns
14
+ */
15
+ export const shortcodeToMediaID = (shortcode) => {
16
+ const o = shortcode.replace(/\S/g, m => {
17
+ const c = igAlphabet.indexOf(m);
18
+ const b = bigintAlphabet.charAt(c);
19
+ return (b !== "") ? b : `<${c}>`;
20
+ });
21
+ return bigInt(o, 64).toString(10);
22
+ };
23
+ export const shortcodeFromMediaID = (mediaId) => {
24
+ const o = bigInt(mediaId).toString(64);
25
+ return o.replace(/<(\d+)>|(\w)/g, (_m, m1, m2) => {
26
+ return igAlphabet.charAt((m1)
27
+ // tslint:disable-next-line:radix
28
+ ? parseInt(m1)
29
+ : bigintAlphabet.indexOf(m2));
30
+ });
31
+ };
32
+ /** Instagram post regex */
33
+ export const IGPostRegex = /(?:https?:\/\/)?(?:www\.)?(?:instagram\.com(?:\/.+?)?\/(p|reel(?:s|)|tv)\/)([\w-]+)(?:\/)?(\?.*)?$/gim;
34
+ /**
35
+ * format instagram long url to get shortcode
36
+ * @param url a instagram post url
37
+ * @returns {formattedShortcode}
38
+ */
39
+ export const shortcodeFormatter = (url) => {
40
+ const splitted = /(?:https?:\/\/)?(?:www\.)?(?:instagram\.com(?:\/.+?)?\/(p|reel(?:s|)|tv)\/)([\w-]+)(?:\/)?(\?.*)?$/gim.exec(url) || '';
41
+ return {
42
+ type: splitted[1],
43
+ shortcode: splitted[2],
44
+ url: 'https://www.instagram.com/' + splitted[1] + '/' + splitted[2],
45
+ media_id: shortcodeToMediaID(splitted[2])
46
+ };
47
+ };
48
+ /**
49
+ * is Instagram Url?
50
+ * @param url instagram post url
51
+ * @returns
52
+ */
53
+ export const isIgPostUrl = (url) => {
54
+ return /(?:https?:\/\/)?(?:www\.)?(?:instagram\.com(?:\/.+?)?\/(p|reel(?:s|)|tv)\/)([\w-]+)(?:\/)?(\?.*)?$/gim.test(url);
55
+ };
56
+ /**
57
+ * get instagram post type
58
+ * @param type product_type
59
+ * @returns
60
+ */
61
+ export const getPostType = (type) => {
62
+ switch (type) {
63
+ case ProductType.CAROUSEL:
64
+ return IGPostType.carousel_container;
65
+ case ProductType.REEL:
66
+ return IGPostType.clips;
67
+ case ProductType.SINGLE:
68
+ return IGPostType.feed;
69
+ case ProductType.TV:
70
+ return IGPostType.igtv;
71
+ case ProductType.STORY:
72
+ return IGPostType.story;
73
+ default:
74
+ return IGPostType.feed;
75
+ }
76
+ };
package/package.json ADDED
@@ -0,0 +1,73 @@
1
+ {
2
+ "name": "insta-api-wrapper",
3
+ "version": "1.0.0",
4
+ "description": "Anonymous Stories, Search & Download reels, posts, highlights... on Insta",
5
+ "main": "lib/index.js",
6
+ "type": "module",
7
+ "types": "lib/index.d.ts",
8
+ "scripts": {
9
+ "test": "jest --config jestconfig.json",
10
+ "build": "tsc",
11
+ "format": "prettier --write \"src/**/*.ts\" \"src/**/*.js\"",
12
+ "lint": "tslint -p tsconfig.json",
13
+ "prepare": "npm run build",
14
+ "prepublishOnly": "npm run lint",
15
+ "preversion": "npm run lint",
16
+ "version": "npm run format && git add -A src",
17
+ "postversion": "git push && git push --tags"
18
+ },
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "git+https://github.com/appit-online/insta-api-wrapper.git"
22
+ },
23
+ "keywords": [
24
+ "instagram",
25
+ "insta",
26
+ "insta search",
27
+ "insta search",
28
+ "insta video search",
29
+ "insta story search",
30
+ "insta video urls",
31
+ "angular insta search",
32
+ "insta api",
33
+ "insta crawler",
34
+ "insta info",
35
+ "insta story",
36
+ "insta stories",
37
+ "insta story urls",
38
+ "insta information"
39
+ ],
40
+ "funding": {
41
+ "url": "https://paypal.me/dave7117",
42
+ "type": "paypal"
43
+ },
44
+ "author": "AppIT",
45
+ "license": "ISC",
46
+ "files": [
47
+ "lib/**/*"
48
+ ],
49
+ "bugs": {
50
+ "url": "https://github.com/appit-online/insta-api-wrapper/issues"
51
+ },
52
+ "homepage": "https://github.com/appit-online/insta-api-wrapper#readme",
53
+ "devDependencies": {
54
+ "@types/jest": "^30.0.0",
55
+ "@types/node": "^24.0.7",
56
+ "@types/node-forge": "^1.3.13",
57
+ "@types/node-localstorage": "^1.3.3",
58
+ "jest": "^30.0.3",
59
+ "prettier": "^3.6.2",
60
+ "ts-jest": "^29.4.0",
61
+ "tslint": "^6.1.3",
62
+ "tslint-config-prettier": "^1.18.0",
63
+ "typescript": "~5.5.4"
64
+ },
65
+ "dependencies": {
66
+ "big-integer": "^1.6.52",
67
+ "got": "^14.4.7",
68
+ "node-forge": "^1.3.1",
69
+ "node-localstorage": "^3.0.5",
70
+ "rxjs": "^7.8.1",
71
+ "uuid": "^11.1.0"
72
+ }
73
+ }