instagram-graph-api-sdk 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,2225 @@
1
+ import { AxiosRequestConfig } from 'axios';
2
+
3
+ /**
4
+ * Common Types for Instagram Graph API SDK
5
+ */
6
+ /**
7
+ * SDK Configuration options
8
+ */
9
+ interface InstagramClientConfig {
10
+ /** Instagram User access token */
11
+ accessToken: string;
12
+ /** API version (default: 'v22.0') */
13
+ apiVersion?: string;
14
+ /** Request timeout in milliseconds (default: 30000) */
15
+ timeout?: number;
16
+ }
17
+ /**
18
+ * Pagination cursor for API responses
19
+ */
20
+ interface PagingCursors {
21
+ before?: string;
22
+ after?: string;
23
+ }
24
+ /**
25
+ * Pagination info for list responses
26
+ */
27
+ interface Paging {
28
+ cursors?: PagingCursors;
29
+ next?: string;
30
+ previous?: string;
31
+ }
32
+ /**
33
+ * Generic paginated response
34
+ */
35
+ interface PaginatedResponse<T> {
36
+ data: T[];
37
+ paging?: Paging;
38
+ }
39
+ /**
40
+ * Generic single item response
41
+ */
42
+ interface SingleResponse<T> {
43
+ data: T;
44
+ }
45
+ /**
46
+ * Success response for mutations
47
+ */
48
+ interface SuccessResponse {
49
+ success: boolean;
50
+ }
51
+ /**
52
+ * ID response for creates
53
+ */
54
+ interface IdResponse {
55
+ id: string;
56
+ }
57
+ /**
58
+ * Fields parameter type (comma-separated list)
59
+ */
60
+ type FieldsParam = string | string[];
61
+ /**
62
+ * Convert fields to comma-separated string
63
+ */
64
+ declare function formatFields(fields?: FieldsParam): string | undefined;
65
+ /**
66
+ * Base options for list requests
67
+ */
68
+ interface ListOptions {
69
+ /** Maximum number of items to return */
70
+ limit?: number;
71
+ /** Pagination cursor (after) */
72
+ after?: string;
73
+ /** Pagination cursor (before) */
74
+ before?: string;
75
+ }
76
+ /**
77
+ * Options with fields selection
78
+ */
79
+ interface FieldsOptions {
80
+ /** Fields to include in response */
81
+ fields?: FieldsParam;
82
+ }
83
+ /**
84
+ * Combined list options with fields
85
+ */
86
+ interface ListWithFieldsOptions extends ListOptions, FieldsOptions {
87
+ }
88
+ /**
89
+ * Time period for insights
90
+ */
91
+ type InsightsPeriod = 'day' | 'week' | 'days_28' | 'month' | 'lifetime';
92
+ /**
93
+ * Metric breakdown type
94
+ */
95
+ type MetricBreakdown = 'age' | 'city' | 'country' | 'gender';
96
+
97
+ /**
98
+ * HTTP Client for Instagram Graph API
99
+ *
100
+ * Axios-based HTTP client with interceptors for authentication,
101
+ * error handling, and rate limiting.
102
+ */
103
+
104
+ /**
105
+ * HTTP Client configuration options
106
+ */
107
+ interface HttpClientConfig {
108
+ /** Instagram User access token */
109
+ accessToken: string;
110
+ /** API version (e.g., 'v22.0') */
111
+ apiVersion: string;
112
+ /** Request timeout in milliseconds */
113
+ timeout?: number;
114
+ /** Custom headers */
115
+ headers?: Record<string, string>;
116
+ }
117
+ /**
118
+ * HTTP Client for making requests to Instagram Graph API
119
+ */
120
+ declare class HttpClient {
121
+ private readonly client;
122
+ private readonly config;
123
+ constructor(config: HttpClientConfig);
124
+ /**
125
+ * Set up request and response interceptors
126
+ */
127
+ private setupInterceptors;
128
+ /**
129
+ * Update access token
130
+ */
131
+ setAccessToken(accessToken: string): void;
132
+ /**
133
+ * GET request
134
+ */
135
+ get<T>(path: string, params?: Record<string, unknown>, config?: AxiosRequestConfig): Promise<T>;
136
+ /**
137
+ * POST request
138
+ */
139
+ post<T>(path: string, data?: Record<string, unknown>, params?: Record<string, unknown>, config?: AxiosRequestConfig): Promise<T>;
140
+ /**
141
+ * DELETE request
142
+ */
143
+ delete<T>(path: string, params?: Record<string, unknown>, config?: AxiosRequestConfig): Promise<T>;
144
+ /**
145
+ * POST with form data (for file uploads)
146
+ */
147
+ postForm<T>(path: string, data: Record<string, unknown>, config?: AxiosRequestConfig): Promise<T>;
148
+ }
149
+
150
+ /**
151
+ * Media Types for Instagram Graph API SDK
152
+ */
153
+
154
+ /**
155
+ * Media type
156
+ */
157
+ type MediaType = 'IMAGE' | 'VIDEO' | 'CAROUSEL_ALBUM';
158
+ /**
159
+ * Media product type
160
+ */
161
+ type MediaProductType = 'FEED' | 'REELS' | 'STORY';
162
+ /**
163
+ * Instagram Media object
164
+ */
165
+ interface IGMedia {
166
+ /** The Media's ID */
167
+ id: string;
168
+ /** Caption text */
169
+ caption?: string;
170
+ /** Media type */
171
+ media_type?: MediaType;
172
+ /** Media product type (FEED, REELS, STORY) */
173
+ media_product_type?: MediaProductType;
174
+ /** URL to the media */
175
+ media_url?: string;
176
+ /** Permalink to the media on Instagram */
177
+ permalink?: string;
178
+ /** Thumbnail URL (for videos) */
179
+ thumbnail_url?: string;
180
+ /** ISO 8601 timestamp */
181
+ timestamp?: string;
182
+ /** Username of the owner */
183
+ username?: string;
184
+ /** Like count */
185
+ like_count?: number;
186
+ /** Comments count */
187
+ comments_count?: number;
188
+ /** Is comments enabled */
189
+ is_comment_enabled?: boolean;
190
+ /** Is shared to feed */
191
+ is_shared_to_feed?: boolean;
192
+ /** Owner ID */
193
+ owner?: {
194
+ id: string;
195
+ };
196
+ /** Shortcode */
197
+ shortcode?: string;
198
+ }
199
+ /**
200
+ * Available fields for IGMedia
201
+ */
202
+ declare const IG_MEDIA_FIELDS: readonly ["id", "caption", "media_type", "media_product_type", "media_url", "permalink", "thumbnail_url", "timestamp", "username", "like_count", "comments_count", "is_comment_enabled", "is_shared_to_feed", "owner", "shortcode"];
203
+ type IGMediaField = (typeof IG_MEDIA_FIELDS)[number];
204
+ /**
205
+ * Carousel child media
206
+ */
207
+ interface IGMediaChild {
208
+ id: string;
209
+ media_type?: MediaType;
210
+ media_url?: string;
211
+ timestamp?: string;
212
+ }
213
+ /**
214
+ * Media collaborator
215
+ */
216
+ interface MediaCollaborator {
217
+ id: string;
218
+ username?: string;
219
+ }
220
+ /**
221
+ * Product tag on media
222
+ */
223
+ interface ProductTag {
224
+ product_id: string;
225
+ merchant_id?: string;
226
+ name?: string;
227
+ image_url?: string;
228
+ x?: number;
229
+ y?: number;
230
+ }
231
+ /**
232
+ * Media children response
233
+ */
234
+ type MediaChildrenResponse = PaginatedResponse<IGMediaChild>;
235
+ /**
236
+ * Get media options
237
+ */
238
+ interface GetMediaOptions {
239
+ fields?: IGMediaField[];
240
+ }
241
+ /**
242
+ * Get media children options
243
+ */
244
+ interface GetMediaChildrenOptions {
245
+ fields?: string[];
246
+ }
247
+
248
+ /**
249
+ * User Types for Instagram Graph API SDK
250
+ */
251
+
252
+ /**
253
+ * Instagram User account type
254
+ */
255
+ type IGAccountType = 'BUSINESS' | 'MEDIA_CREATOR' | 'PERSONAL';
256
+ /**
257
+ * Instagram User profile fields
258
+ */
259
+ interface IGUser {
260
+ /** The User's ID */
261
+ id: string;
262
+ /** The User's account type */
263
+ account_type?: IGAccountType;
264
+ /** The User's biography */
265
+ biography?: string;
266
+ /** The number of followers */
267
+ followers_count?: number;
268
+ /** The number of accounts following */
269
+ follows_count?: number;
270
+ /** The number of media objects */
271
+ media_count?: number;
272
+ /** The User's username */
273
+ username?: string;
274
+ /** The User's name */
275
+ name?: string;
276
+ /** The User's profile picture URL */
277
+ profile_picture_url?: string;
278
+ /** The User's website */
279
+ website?: string;
280
+ /** Instagram user ID */
281
+ ig_id?: number;
282
+ }
283
+ /**
284
+ * Available fields for IGUser
285
+ */
286
+ declare const IG_USER_FIELDS: readonly ["id", "account_type", "biography", "followers_count", "follows_count", "media_count", "username", "name", "profile_picture_url", "website", "ig_id"];
287
+ type IGUserField = (typeof IG_USER_FIELDS)[number];
288
+ /**
289
+ * Business Discovery response
290
+ */
291
+ interface BusinessDiscovery {
292
+ business_discovery: Partial<IGUser> & {
293
+ media?: PaginatedResponse<IGMedia>;
294
+ };
295
+ id: string;
296
+ }
297
+ /**
298
+ * Content publishing limit
299
+ */
300
+ interface ContentPublishingLimit {
301
+ quota_usage: number;
302
+ config: {
303
+ quota_total: number;
304
+ quota_duration: number;
305
+ };
306
+ }
307
+ /**
308
+ * User mentions response
309
+ */
310
+ interface UserMention {
311
+ id: string;
312
+ timestamp?: string;
313
+ caption?: string;
314
+ media_type?: string;
315
+ media_url?: string;
316
+ permalink?: string;
317
+ username?: string;
318
+ }
319
+ /**
320
+ * Recently searched hashtag
321
+ */
322
+ interface RecentlySearchedHashtag {
323
+ id: string;
324
+ name?: string;
325
+ }
326
+ /**
327
+ * Available catalog
328
+ */
329
+ interface AvailableCatalog {
330
+ catalog_id: string;
331
+ catalog_name?: string;
332
+ shop_name?: string;
333
+ product_count?: number;
334
+ }
335
+ /**
336
+ * Catalog product
337
+ */
338
+ interface CatalogProduct {
339
+ product_id: string;
340
+ merchant_id?: string;
341
+ product_name?: string;
342
+ image_url?: string;
343
+ retailer_id?: string;
344
+ review_status?: string;
345
+ is_checkout_flow?: boolean;
346
+ }
347
+ /**
348
+ * User profile request options
349
+ */
350
+ interface GetUserProfileOptions {
351
+ fields?: IGUserField[];
352
+ }
353
+ /**
354
+ * User media request options
355
+ */
356
+ interface GetUserMediaOptions {
357
+ fields?: string[];
358
+ limit?: number;
359
+ after?: string;
360
+ before?: string;
361
+ }
362
+ /**
363
+ * Business discovery options
364
+ */
365
+ interface BusinessDiscoveryOptions {
366
+ username: string;
367
+ fields?: string[];
368
+ }
369
+
370
+ /**
371
+ * Auth API Module
372
+ *
373
+ * Handles authentication and token operations.
374
+ */
375
+
376
+ /**
377
+ * Token response from Instagram API
378
+ */
379
+ interface TokenResponse {
380
+ access_token: string;
381
+ token_type: string;
382
+ }
383
+ /**
384
+ * Long-lived token response
385
+ */
386
+ interface LongLivedTokenResponse$1 {
387
+ access_token: string;
388
+ token_type: string;
389
+ expires_in: number;
390
+ }
391
+ /**
392
+ * Auth API class for Instagram authentication operations
393
+ */
394
+ declare class AuthApi {
395
+ private readonly http;
396
+ constructor(http: HttpClient);
397
+ /**
398
+ * Get current user information
399
+ * @param fields - Fields to retrieve
400
+ */
401
+ me(fields?: string): Promise<IGUser>;
402
+ /**
403
+ * Refresh a long-lived token (Instagram Login)
404
+ * Returns a new long-lived token with 60 days expiry
405
+ */
406
+ refreshToken(): Promise<LongLivedTokenResponse$1>;
407
+ /**
408
+ * Exchange short-lived token for long-lived token (Instagram Login)
409
+ * @param shortLivedToken - Short-lived access token (1 hour expiry)
410
+ * @param appSecret - Instagram App Secret
411
+ */
412
+ exchangeToken(shortLivedToken: string, appSecret: string): Promise<LongLivedTokenResponse$1>;
413
+ }
414
+
415
+ /**
416
+ * OAuth Types
417
+ *
418
+ * Types for Instagram Business Login OAuth flow.
419
+ */
420
+ /**
421
+ * Available Instagram Business Login scopes
422
+ */
423
+ type InstagramScope = 'instagram_business_basic' | 'instagram_business_manage_messages' | 'instagram_business_manage_comments' | 'instagram_business_content_publish' | 'instagram_business_manage_insights';
424
+ /**
425
+ * OAuth configuration for your Instagram app
426
+ */
427
+ interface OAuthConfig {
428
+ clientId: string;
429
+ clientSecret: string;
430
+ redirectUri: string;
431
+ }
432
+ /**
433
+ * Parameters for building the authorization URL
434
+ */
435
+ interface AuthorizationUrlParams {
436
+ /** Your Instagram App ID */
437
+ clientId: string;
438
+ /** Must exactly match one of your Valid OAuth Redirect URIs */
439
+ redirectUri: string;
440
+ /** List of permissions to request */
441
+ scopes: InstagramScope[];
442
+ /** Optional CSRF protection state */
443
+ state?: string;
444
+ /** Response type, always 'code' */
445
+ responseType?: 'code';
446
+ /** Force re-authentication even if user has active session */
447
+ forceReauth?: boolean;
448
+ }
449
+ /**
450
+ * Parameters for exchanging authorization code for tokens
451
+ */
452
+ interface ExchangeCodeParams {
453
+ /** Your Instagram App ID */
454
+ clientId: string;
455
+ /** Your Instagram App Secret */
456
+ clientSecret: string;
457
+ /** Authorization code from callback (will be cleaned of #_ suffix) */
458
+ code: string;
459
+ /** Must exactly match the redirect_uri used in authorization */
460
+ redirectUri: string;
461
+ }
462
+ /**
463
+ * Short-lived token response from Instagram API
464
+ * Valid for 1 hour
465
+ */
466
+ interface ShortLivedTokenResponse {
467
+ access_token: string;
468
+ user_id: string;
469
+ permissions: string;
470
+ }
471
+ /**
472
+ * Long-lived token response from Instagram API
473
+ * Valid for 60 days
474
+ */
475
+ interface LongLivedTokenResponse {
476
+ access_token: string;
477
+ token_type: string;
478
+ /** Token lifetime in seconds (typically ~5184000 for 60 days) */
479
+ expires_in: number;
480
+ }
481
+ /**
482
+ * Complete OAuth token response with user info
483
+ * Returned by exchangeCodeForToken()
484
+ */
485
+ interface OAuthTokenResponse {
486
+ /** Long-lived access token (60 days) */
487
+ access_token: string;
488
+ token_type: string;
489
+ /** Token lifetime in seconds */
490
+ expires_in: number;
491
+ /** Instagram User ID */
492
+ user_id: string;
493
+ }
494
+ /**
495
+ * OAuth error response from Instagram
496
+ */
497
+ interface OAuthError {
498
+ error: string;
499
+ error_reason?: string;
500
+ error_description?: string;
501
+ }
502
+ /**
503
+ * OAuth callback parameters (parsed from redirect URL)
504
+ */
505
+ interface OAuthCallbackParams {
506
+ /** Authorization code (if successful) */
507
+ code?: string;
508
+ /** State parameter (if provided in authorization request) */
509
+ state?: string;
510
+ /** Error type (if user denied or error occurred) */
511
+ error?: string;
512
+ /** Error reason */
513
+ error_reason?: string;
514
+ /** Human-readable error description */
515
+ error_description?: string;
516
+ }
517
+
518
+ /**
519
+ * Instagram OAuth Module
520
+ *
521
+ * Static methods for Instagram Business Login OAuth flow.
522
+ * These methods don't require an access token.
523
+ *
524
+ * @example
525
+ * ```typescript
526
+ * import { InstagramOAuth } from 'instagram-graph-api-sdk';
527
+ *
528
+ * // 1. Build authorization URL
529
+ * const authUrl = InstagramOAuth.buildAuthorizationUrl({
530
+ * clientId: 'your-app-id',
531
+ * redirectUri: 'https://your-app.com/callback',
532
+ * scopes: ['instagram_business_basic', 'instagram_business_manage_messages'],
533
+ * state: 'csrf-token',
534
+ * });
535
+ *
536
+ * // 2. Redirect user to authUrl...
537
+ *
538
+ * // 3. In callback, exchange code for token
539
+ * const tokens = await InstagramOAuth.exchangeCodeForToken({
540
+ * clientId: 'your-app-id',
541
+ * clientSecret: 'your-app-secret',
542
+ * code: 'code-from-callback',
543
+ * redirectUri: 'https://your-app.com/callback',
544
+ * });
545
+ *
546
+ * console.log(tokens.access_token); // Long-lived token (60 days)
547
+ * console.log(tokens.user_id); // Instagram User ID
548
+ * ```
549
+ */
550
+
551
+ /**
552
+ * Instagram OAuth - Static methods for authentication flow
553
+ *
554
+ * Use these methods for user onboarding (Instagram Business Login).
555
+ * After obtaining a token, create an InstagramClient instance to make API calls.
556
+ */
557
+ declare class InstagramOAuth {
558
+ /**
559
+ * Build the Instagram authorization URL
560
+ *
561
+ * Direct users to this URL to start the OAuth flow.
562
+ * They will be asked to grant permissions to your app.
563
+ *
564
+ * @param params - Authorization URL parameters
565
+ * @returns Full authorization URL to redirect user to
566
+ *
567
+ * @example
568
+ * ```typescript
569
+ * const url = InstagramOAuth.buildAuthorizationUrl({
570
+ * clientId: process.env.INSTAGRAM_APP_ID,
571
+ * redirectUri: `${process.env.APP_URL}/api/instagram/callback`,
572
+ * scopes: [
573
+ * 'instagram_business_basic',
574
+ * 'instagram_business_manage_messages',
575
+ * ],
576
+ * state: crypto.randomUUID(), // CSRF protection
577
+ * });
578
+ *
579
+ * // Redirect user to url
580
+ * ```
581
+ */
582
+ static buildAuthorizationUrl(params: AuthorizationUrlParams): string;
583
+ /**
584
+ * Parse OAuth callback parameters from URL
585
+ *
586
+ * Use this to extract code, state, and error info from the callback URL.
587
+ *
588
+ * @param url - The callback URL (or just the search params)
589
+ * @returns Parsed callback parameters
590
+ *
591
+ * @example
592
+ * ```typescript
593
+ * const params = InstagramOAuth.parseCallback(request.url);
594
+ *
595
+ * if (params.error) {
596
+ * // User denied access
597
+ * console.log(params.error_description);
598
+ * } else {
599
+ * // Exchange code for token
600
+ * const tokens = await InstagramOAuth.exchangeCodeForToken({
601
+ * code: params.code!,
602
+ * ...
603
+ * });
604
+ * }
605
+ * ```
606
+ */
607
+ static parseCallback(url: string): OAuthCallbackParams;
608
+ /**
609
+ * Exchange authorization code for tokens
610
+ *
611
+ * This is the recommended method - it handles the full flow:
612
+ * 1. Exchange code for short-lived token (1 hour)
613
+ * 2. Exchange short-lived for long-lived token (60 days)
614
+ *
615
+ * @param params - Exchange parameters
616
+ * @returns Long-lived token response with user ID
617
+ * @throws Error if exchange fails
618
+ *
619
+ * @example
620
+ * ```typescript
621
+ * const tokens = await InstagramOAuth.exchangeCodeForToken({
622
+ * clientId: process.env.INSTAGRAM_APP_ID!,
623
+ * clientSecret: process.env.INSTAGRAM_APP_SECRET!,
624
+ * code: codeFromCallback,
625
+ * redirectUri: `${process.env.APP_URL}/api/instagram/callback`,
626
+ * });
627
+ *
628
+ * // Store tokens.access_token and tokens.user_id in your database
629
+ * // Token expires in tokens.expires_in seconds (~60 days)
630
+ * ```
631
+ */
632
+ static exchangeCodeForToken(params: ExchangeCodeParams): Promise<OAuthTokenResponse>;
633
+ /**
634
+ * Get short-lived token from authorization code
635
+ *
636
+ * Use this if you need more control over the token exchange process.
637
+ * The short-lived token is valid for 1 hour.
638
+ *
639
+ * @param params - Exchange parameters
640
+ * @returns Short-lived token response
641
+ * @throws Error if exchange fails
642
+ */
643
+ static getShortLivedToken(params: ExchangeCodeParams): Promise<ShortLivedTokenResponse>;
644
+ /**
645
+ * Exchange short-lived token for long-lived token
646
+ *
647
+ * Long-lived tokens are valid for 60 days and can be refreshed.
648
+ *
649
+ * @param params - Exchange parameters
650
+ * @returns Long-lived token response
651
+ * @throws Error if exchange fails
652
+ */
653
+ static getLongLivedToken(params: {
654
+ clientSecret: string;
655
+ accessToken: string;
656
+ }): Promise<LongLivedTokenResponse>;
657
+ /**
658
+ * Get the default scopes for Instagram Business Login
659
+ *
660
+ * @returns Array of commonly used scopes
661
+ */
662
+ static getDefaultScopes(): InstagramScope[];
663
+ /**
664
+ * Get all available Instagram Business Login scopes
665
+ *
666
+ * @returns Array of all available scopes
667
+ */
668
+ static getAllScopes(): InstagramScope[];
669
+ }
670
+
671
+ /**
672
+ * Users API Module
673
+ *
674
+ * Handles all user-related API operations.
675
+ */
676
+
677
+ /**
678
+ * Users API class for Instagram user operations
679
+ */
680
+ declare class UsersApi {
681
+ private readonly http;
682
+ private readonly userId;
683
+ constructor(http: HttpClient, userId: string);
684
+ /**
685
+ * Get user profile information
686
+ * @param options - Fields to retrieve
687
+ */
688
+ getProfile(options?: GetUserProfileOptions): Promise<IGUser>;
689
+ /**
690
+ * Get user's media
691
+ * @param options - Pagination and fields options
692
+ */
693
+ getMedia(options?: GetUserMediaOptions): Promise<PaginatedResponse<IGMedia>>;
694
+ /**
695
+ * Get user's stories
696
+ */
697
+ getStories(): Promise<PaginatedResponse<IGMedia>>;
698
+ /**
699
+ * Get user's live media
700
+ */
701
+ getLiveMedia(): Promise<PaginatedResponse<IGMedia>>;
702
+ /**
703
+ * Get content publishing limit (quota usage)
704
+ */
705
+ getContentPublishingLimit(): Promise<ContentPublishingLimit>;
706
+ /**
707
+ * Discover another business account by username
708
+ * @param options - Username and fields to retrieve
709
+ */
710
+ getBusinessDiscovery(options: BusinessDiscoveryOptions): Promise<BusinessDiscovery>;
711
+ /**
712
+ * Get media where user is mentioned
713
+ */
714
+ getMentionedMedia(): Promise<PaginatedResponse<IGMedia>>;
715
+ /**
716
+ * Get comments where user is mentioned
717
+ */
718
+ getMentionedComment(): Promise<PaginatedResponse<{
719
+ id: string;
720
+ text?: string;
721
+ }>>;
722
+ /**
723
+ * Get media user is tagged in
724
+ */
725
+ getTags(): Promise<PaginatedResponse<IGMedia>>;
726
+ /**
727
+ * Get recently searched hashtags
728
+ */
729
+ getRecentlySearchedHashtags(): Promise<PaginatedResponse<RecentlySearchedHashtag>>;
730
+ /**
731
+ * Get available product catalogs
732
+ */
733
+ getAvailableCatalogs(): Promise<PaginatedResponse<AvailableCatalog>>;
734
+ /**
735
+ * Search products in a catalog
736
+ * @param catalogId - Catalog ID to search in
737
+ * @param query - Search query
738
+ */
739
+ searchCatalogProducts(catalogId: string, query: string): Promise<PaginatedResponse<CatalogProduct>>;
740
+ }
741
+
742
+ /**
743
+ * Comment Types for Instagram Graph API SDK
744
+ */
745
+ /**
746
+ * Instagram Comment
747
+ */
748
+ interface IGComment {
749
+ /** Comment ID */
750
+ id: string;
751
+ /** Comment text */
752
+ text?: string;
753
+ /** Username of commenter */
754
+ username?: string;
755
+ /** ISO 8601 timestamp */
756
+ timestamp?: string;
757
+ /** Like count */
758
+ like_count?: number;
759
+ /** Is comment hidden */
760
+ hidden?: boolean;
761
+ /** User who posted the comment */
762
+ from?: {
763
+ id: string;
764
+ username?: string;
765
+ };
766
+ /** Media this comment is on */
767
+ media?: {
768
+ id: string;
769
+ };
770
+ /** Parent comment (for replies) */
771
+ parent_id?: string;
772
+ /** Replies to this comment */
773
+ replies?: {
774
+ data: IGComment[];
775
+ };
776
+ }
777
+ /**
778
+ * Available fields for IGComment
779
+ */
780
+ declare const IG_COMMENT_FIELDS: readonly ["id", "text", "username", "timestamp", "like_count", "hidden", "from", "media", "parent_id", "replies"];
781
+ type IGCommentField = (typeof IG_COMMENT_FIELDS)[number];
782
+ /**
783
+ * Get comments options
784
+ */
785
+ interface GetCommentsOptions {
786
+ fields?: IGCommentField[];
787
+ limit?: number;
788
+ after?: string;
789
+ }
790
+ /**
791
+ * Reply to comment options
792
+ */
793
+ interface ReplyToCommentOptions {
794
+ message: string;
795
+ }
796
+ /**
797
+ * Update comment options (hide/unhide)
798
+ */
799
+ interface UpdateCommentOptions {
800
+ hide: boolean;
801
+ }
802
+
803
+ /**
804
+ * Insights Types for Instagram Graph API SDK
805
+ */
806
+ /**
807
+ * Insight metric value
808
+ */
809
+ interface InsightValue {
810
+ value: number | Record<string, number>;
811
+ end_time?: string;
812
+ }
813
+ /**
814
+ * Insight data point
815
+ */
816
+ interface InsightData {
817
+ id: string;
818
+ name: string;
819
+ period: string;
820
+ values: InsightValue[];
821
+ title: string;
822
+ description: string;
823
+ }
824
+ /**
825
+ * Insights response
826
+ */
827
+ interface InsightsResponse {
828
+ data: InsightData[];
829
+ }
830
+ /**
831
+ * Account insight metrics
832
+ * Updated to match current Instagram Graph API v22.0
833
+ */
834
+ type AccountMetric = 'reach' | 'follower_count' | 'website_clicks' | 'profile_views' | 'online_followers' | 'accounts_engaged' | 'total_interactions' | 'likes' | 'comments' | 'shares' | 'saves' | 'replies' | 'engaged_audience_demographics' | 'reached_audience_demographics' | 'follower_demographics' | 'follows_and_unfollows' | 'profile_links_taps' | 'views';
835
+ /**
836
+ * Media insight metrics
837
+ */
838
+ type MediaMetric = 'engagement' | 'impressions' | 'reach' | 'saved' | 'video_views' | 'likes' | 'comments' | 'shares' | 'plays' | 'total_interactions';
839
+ /**
840
+ * Insights period
841
+ */
842
+ type InsightPeriod = 'day' | 'week' | 'days_28' | 'month' | 'lifetime';
843
+ /**
844
+ * Get account insights options
845
+ */
846
+ interface GetAccountInsightsOptions {
847
+ metric: AccountMetric[];
848
+ period?: InsightPeriod;
849
+ since?: number;
850
+ until?: number;
851
+ metric_type?: 'total_value' | 'time_series';
852
+ breakdown?: 'age' | 'city' | 'country' | 'gender';
853
+ }
854
+ /**
855
+ * Get media insights options
856
+ */
857
+ interface GetMediaInsightsOptions {
858
+ metric: MediaMetric[];
859
+ }
860
+ /**
861
+ * Demographics breakdown
862
+ */
863
+ interface DemographicsBreakdown {
864
+ [key: string]: number;
865
+ }
866
+
867
+ /**
868
+ * Media API Module
869
+ *
870
+ * Handles all media-related API operations.
871
+ */
872
+
873
+ /**
874
+ * Media API class for Instagram media operations
875
+ */
876
+ declare class MediaApi {
877
+ private readonly http;
878
+ constructor(http: HttpClient);
879
+ /**
880
+ * Get media by ID
881
+ * @param mediaId - Media ID
882
+ * @param options - Fields to retrieve
883
+ */
884
+ get(mediaId: string, options?: GetMediaOptions): Promise<IGMedia>;
885
+ /**
886
+ * Get carousel children
887
+ * @param mediaId - Carousel media ID
888
+ * @param options - Fields to retrieve
889
+ */
890
+ getChildren(mediaId: string, options?: GetMediaChildrenOptions): Promise<PaginatedResponse<IGMediaChild>>;
891
+ /**
892
+ * Get comments on media
893
+ * @param mediaId - Media ID
894
+ * @param options - Pagination and fields options
895
+ */
896
+ getComments(mediaId: string, options?: GetCommentsOptions): Promise<PaginatedResponse<IGComment>>;
897
+ /**
898
+ * Get media insights
899
+ * @param mediaId - Media ID
900
+ * @param options - Metrics to retrieve
901
+ */
902
+ getInsights(mediaId: string, options: GetMediaInsightsOptions): Promise<InsightsResponse>;
903
+ /**
904
+ * Get media collaborators
905
+ * @param mediaId - Media ID
906
+ */
907
+ getCollaborators(mediaId: string): Promise<PaginatedResponse<MediaCollaborator>>;
908
+ /**
909
+ * Get product tags on media
910
+ * @param mediaId - Media ID
911
+ */
912
+ getProductTags(mediaId: string): Promise<PaginatedResponse<ProductTag>>;
913
+ }
914
+
915
+ /**
916
+ * Publishing Types for Instagram Graph API SDK
917
+ */
918
+ /**
919
+ * Container media type for publishing
920
+ */
921
+ type ContainerMediaType = 'IMAGE' | 'VIDEO' | 'REELS' | 'STORIES' | 'CAROUSEL';
922
+ /**
923
+ * Container status code
924
+ */
925
+ type ContainerStatusCode = 'EXPIRED' | 'ERROR' | 'FINISHED' | 'IN_PROGRESS' | 'PUBLISHED';
926
+ /**
927
+ * Base container creation options
928
+ */
929
+ interface BaseContainerOptions {
930
+ /** Caption for the media */
931
+ caption?: string;
932
+ /** Location tag ID */
933
+ location_id?: string;
934
+ /** User tags */
935
+ user_tags?: UserTag[];
936
+ /** Collaborators (creator accounts to invite) */
937
+ collaborators?: string[];
938
+ /** Alt text for accessibility */
939
+ alt_text?: string;
940
+ }
941
+ /**
942
+ * User tag for media
943
+ */
944
+ interface UserTag {
945
+ username: string;
946
+ x?: number;
947
+ y?: number;
948
+ }
949
+ /**
950
+ * Image container creation options
951
+ */
952
+ interface CreateImageContainerOptions extends BaseContainerOptions {
953
+ /** URL to the image (must be publicly accessible) */
954
+ image_url: string;
955
+ /** Whether this is a carousel item */
956
+ is_carousel_item?: boolean;
957
+ }
958
+ /**
959
+ * Video container creation options
960
+ */
961
+ interface CreateVideoContainerOptions extends BaseContainerOptions {
962
+ /** URL to the video (must be publicly accessible) */
963
+ video_url: string;
964
+ /** Media type: VIDEO, REELS, or STORIES */
965
+ media_type: 'VIDEO' | 'REELS' | 'STORIES';
966
+ /** Whether to share reel to feed */
967
+ share_to_feed?: boolean;
968
+ /** Whether this is a carousel item */
969
+ is_carousel_item?: boolean;
970
+ /** Cover URL for video */
971
+ cover_url?: string;
972
+ /** Thumb offset for video cover (ms) */
973
+ thumb_offset?: number;
974
+ /** Audio name for reels */
975
+ audio_name?: string;
976
+ }
977
+ /**
978
+ * Carousel container creation options
979
+ */
980
+ interface CreateCarouselContainerOptions extends BaseContainerOptions {
981
+ /** Array of child container IDs */
982
+ children: string[];
983
+ }
984
+ /**
985
+ * Resumable upload options
986
+ */
987
+ interface ResumableUploadOptions extends BaseContainerOptions {
988
+ /** Media type: VIDEO, REELS, or STORIES */
989
+ media_type: 'VIDEO' | 'REELS' | 'STORIES';
990
+ /** Upload type */
991
+ upload_type: 'resumable';
992
+ }
993
+ /**
994
+ * Container creation response
995
+ */
996
+ interface ContainerResponse {
997
+ id: string;
998
+ }
999
+ /**
1000
+ * Container status response
1001
+ */
1002
+ interface ContainerStatus {
1003
+ id: string;
1004
+ status_code?: ContainerStatusCode;
1005
+ status?: string;
1006
+ }
1007
+ /**
1008
+ * Publish response
1009
+ */
1010
+ interface PublishResponse {
1011
+ id: string;
1012
+ }
1013
+ /**
1014
+ * Trial reel options
1015
+ */
1016
+ interface TrialReelOptions {
1017
+ /** Graduation strategy */
1018
+ graduation_strategy: 'MANUAL' | 'SS_PERFORMANCE';
1019
+ }
1020
+
1021
+ /**
1022
+ * Publishing API Module
1023
+ *
1024
+ * Handles content publishing operations.
1025
+ */
1026
+
1027
+ /**
1028
+ * Publishing API class for content publishing operations
1029
+ */
1030
+ declare class PublishingApi {
1031
+ private readonly http;
1032
+ private readonly userId;
1033
+ constructor(http: HttpClient, userId: string);
1034
+ /**
1035
+ * Create an image container
1036
+ * @param options - Image URL and optional caption, location, tags
1037
+ */
1038
+ createImageContainer(options: CreateImageContainerOptions): Promise<ContainerResponse>;
1039
+ /**
1040
+ * Create a video/reel/story container
1041
+ * @param options - Video URL, media type, and optional settings
1042
+ */
1043
+ createVideoContainer(options: CreateVideoContainerOptions): Promise<ContainerResponse>;
1044
+ /**
1045
+ * Create a carousel container
1046
+ * @param options - Child container IDs and optional caption
1047
+ */
1048
+ createCarouselContainer(options: CreateCarouselContainerOptions): Promise<ContainerResponse>;
1049
+ /**
1050
+ * Create a resumable upload session
1051
+ * @param options - Media type and settings
1052
+ */
1053
+ createResumableUpload(options: ResumableUploadOptions): Promise<ContainerResponse>;
1054
+ /**
1055
+ * Get container status
1056
+ * @param containerId - Container ID
1057
+ */
1058
+ getContainerStatus(containerId: string): Promise<ContainerStatus>;
1059
+ /**
1060
+ * Publish a container
1061
+ * @param containerId - Container ID to publish
1062
+ */
1063
+ publishContainer(containerId: string): Promise<PublishResponse>;
1064
+ /**
1065
+ * Wait for container to be ready, then publish
1066
+ * @param containerId - Container ID
1067
+ * @param maxAttempts - Maximum number of status checks (default: 30)
1068
+ * @param intervalMs - Interval between checks in ms (default: 2000)
1069
+ */
1070
+ waitAndPublish(containerId: string, maxAttempts?: number, intervalMs?: number): Promise<PublishResponse>;
1071
+ }
1072
+
1073
+ /**
1074
+ * Messaging Types for Instagram Graph API SDK
1075
+ */
1076
+ /**
1077
+ * Message recipient
1078
+ */
1079
+ interface MessageRecipient {
1080
+ /** Instagram-scoped user ID */
1081
+ id?: string;
1082
+ /** Comment ID for private replies */
1083
+ comment_id?: string;
1084
+ }
1085
+ /**
1086
+ * Message attachment type
1087
+ */
1088
+ type AttachmentType = 'image' | 'video' | 'audio' | 'file' | 'template' | 'like_heart' | 'MEDIA_SHARE';
1089
+ /**
1090
+ * Message attachment payload
1091
+ */
1092
+ interface AttachmentPayload {
1093
+ /** URL of the attachment */
1094
+ url?: string;
1095
+ /** Attachment ID (for uploaded assets) */
1096
+ attachment_id?: string;
1097
+ /** Media ID (for MEDIA_SHARE) */
1098
+ id?: string;
1099
+ /** Template type */
1100
+ template_type?: 'generic' | 'button';
1101
+ /** Template elements */
1102
+ elements?: TemplateElement[];
1103
+ /** Button template text */
1104
+ text?: string;
1105
+ /** Buttons */
1106
+ buttons?: TemplateButton[];
1107
+ }
1108
+ /**
1109
+ * Message attachment
1110
+ */
1111
+ interface MessageAttachment {
1112
+ type: AttachmentType;
1113
+ payload?: AttachmentPayload;
1114
+ }
1115
+ /**
1116
+ * Template element for generic template
1117
+ */
1118
+ interface TemplateElement {
1119
+ title: string;
1120
+ subtitle?: string;
1121
+ image_url?: string;
1122
+ default_action?: {
1123
+ type: 'web_url';
1124
+ url: string;
1125
+ };
1126
+ buttons?: TemplateButton[];
1127
+ }
1128
+ /**
1129
+ * Template button
1130
+ */
1131
+ interface TemplateButton {
1132
+ type: 'web_url' | 'postback';
1133
+ title: string;
1134
+ url?: string;
1135
+ payload?: string;
1136
+ }
1137
+ /**
1138
+ * Quick reply
1139
+ */
1140
+ interface QuickReply {
1141
+ content_type: 'text' | 'user_phone_number' | 'user_email';
1142
+ title?: string;
1143
+ payload?: string;
1144
+ }
1145
+ /**
1146
+ * Message content
1147
+ */
1148
+ interface MessageContent {
1149
+ /** Text message */
1150
+ text?: string;
1151
+ /** Attachment */
1152
+ attachment?: MessageAttachment;
1153
+ /** Quick replies */
1154
+ quick_replies?: QuickReply[];
1155
+ }
1156
+ /**
1157
+ * Send message request
1158
+ */
1159
+ interface SendMessageRequest {
1160
+ recipient: MessageRecipient;
1161
+ message?: MessageContent;
1162
+ /** Sender action (react, unreact) */
1163
+ sender_action?: 'react' | 'unreact' | 'typing_on' | 'typing_off' | 'mark_seen';
1164
+ /** Payload for reactions */
1165
+ payload?: {
1166
+ message_id: string;
1167
+ reaction?: 'love' | 'like' | 'laugh' | 'wow' | 'sad' | 'angry';
1168
+ };
1169
+ /** Messaging type */
1170
+ messaging_type?: 'RESPONSE' | 'UPDATE' | 'MESSAGE_TAG';
1171
+ /** Message tag for outside 24hr window */
1172
+ tag?: 'HUMAN_AGENT';
1173
+ }
1174
+ /**
1175
+ * Send message response
1176
+ */
1177
+ interface SendMessageResponse {
1178
+ recipient_id: string;
1179
+ message_id: string;
1180
+ }
1181
+ /**
1182
+ * Conversation
1183
+ */
1184
+ interface Conversation {
1185
+ id: string;
1186
+ updated_time?: string;
1187
+ }
1188
+ /**
1189
+ * Conversation message
1190
+ */
1191
+ interface ConversationMessage {
1192
+ id: string;
1193
+ created_time?: string;
1194
+ from?: {
1195
+ id: string;
1196
+ username?: string;
1197
+ };
1198
+ to?: {
1199
+ data: Array<{
1200
+ id: string;
1201
+ username?: string;
1202
+ }>;
1203
+ };
1204
+ message?: string;
1205
+ is_unsupported?: boolean;
1206
+ }
1207
+ /**
1208
+ * Get conversations options
1209
+ */
1210
+ interface GetConversationsOptions {
1211
+ platform?: 'instagram';
1212
+ user_id?: string;
1213
+ limit?: number;
1214
+ after?: string;
1215
+ }
1216
+ /**
1217
+ * Send text message options
1218
+ */
1219
+ interface SendTextOptions {
1220
+ /** Use HUMAN_AGENT tag (7 day window) */
1221
+ humanAgent?: boolean;
1222
+ }
1223
+ /**
1224
+ * Send media message options
1225
+ */
1226
+ interface SendMediaOptions {
1227
+ /** Media type */
1228
+ type: 'image' | 'video' | 'audio';
1229
+ /** URL to the media */
1230
+ url: string;
1231
+ }
1232
+ /**
1233
+ * Generic template options
1234
+ */
1235
+ interface GenericTemplateOptions {
1236
+ elements: TemplateElement[];
1237
+ }
1238
+ /**
1239
+ * Button template options
1240
+ */
1241
+ interface ButtonTemplateOptions {
1242
+ text: string;
1243
+ buttons: TemplateButton[];
1244
+ }
1245
+ /**
1246
+ * Quick replies options
1247
+ */
1248
+ interface QuickRepliesOptions {
1249
+ text: string;
1250
+ replies: QuickReply[];
1251
+ }
1252
+ /**
1253
+ * Reaction type
1254
+ */
1255
+ type ReactionType = 'love' | 'like' | 'laugh' | 'wow' | 'sad' | 'angry';
1256
+
1257
+ /**
1258
+ * Messaging API Module
1259
+ *
1260
+ * Handles all messaging operations (Send API).
1261
+ */
1262
+
1263
+ /**
1264
+ * Messaging API class for Instagram messaging operations
1265
+ */
1266
+ declare class MessagingApi {
1267
+ private readonly http;
1268
+ private readonly userId;
1269
+ constructor(http: HttpClient, userId: string);
1270
+ /**
1271
+ * Send a text message
1272
+ * @param recipientId - Instagram-scoped user ID (IGSID)
1273
+ * @param text - Message text
1274
+ * @param options - Optional settings (humanAgent for 7-day window)
1275
+ */
1276
+ sendText(recipientId: string, text: string, options?: SendTextOptions): Promise<SendMessageResponse>;
1277
+ /**
1278
+ * Send a media message (image, video, audio)
1279
+ * @param recipientId - Instagram-scoped user ID
1280
+ * @param options - Media type and URL
1281
+ */
1282
+ sendMedia(recipientId: string, options: SendMediaOptions): Promise<SendMessageResponse>;
1283
+ /**
1284
+ * Send a sticker (like_heart)
1285
+ * @param recipientId - Instagram-scoped user ID
1286
+ */
1287
+ sendLikeHeart(recipientId: string): Promise<SendMessageResponse>;
1288
+ /**
1289
+ * Send a generic template
1290
+ * @param recipientId - Instagram-scoped user ID
1291
+ * @param options - Template elements
1292
+ */
1293
+ sendGenericTemplate(recipientId: string, options: GenericTemplateOptions): Promise<SendMessageResponse>;
1294
+ /**
1295
+ * Send a button template
1296
+ * @param recipientId - Instagram-scoped user ID
1297
+ * @param options - Text and buttons
1298
+ */
1299
+ sendButtonTemplate(recipientId: string, options: ButtonTemplateOptions): Promise<SendMessageResponse>;
1300
+ /**
1301
+ * Send quick replies
1302
+ * @param recipientId - Instagram-scoped user ID
1303
+ * @param options - Text and quick reply options
1304
+ */
1305
+ sendQuickReplies(recipientId: string, options: QuickRepliesOptions): Promise<SendMessageResponse>;
1306
+ /**
1307
+ * Send a private reply to a comment
1308
+ * @param commentId - Comment ID to reply to
1309
+ * @param message - Message text
1310
+ */
1311
+ sendPrivateReply(commentId: string, message: string): Promise<SendMessageResponse>;
1312
+ /**
1313
+ * Share a published post via message
1314
+ * @param recipientId - Instagram-scoped user ID
1315
+ * @param mediaId - Media ID of the post to share
1316
+ */
1317
+ sendMediaShare(recipientId: string, mediaId: string): Promise<SendMessageResponse>;
1318
+ /**
1319
+ * React to a message
1320
+ * @param recipientId - Instagram-scoped user ID
1321
+ * @param messageId - Message ID to react to
1322
+ * @param reaction - Reaction type
1323
+ */
1324
+ reactToMessage(recipientId: string, messageId: string, reaction: ReactionType): Promise<SendMessageResponse>;
1325
+ /**
1326
+ * Remove reaction from a message
1327
+ * @param recipientId - Instagram-scoped user ID
1328
+ * @param messageId - Message ID to unreact from
1329
+ */
1330
+ unreactToMessage(recipientId: string, messageId: string): Promise<SendMessageResponse>;
1331
+ /**
1332
+ * Send typing indicator
1333
+ * @param recipientId - Instagram-scoped user ID
1334
+ * @param typing - Whether to show typing (true) or stop (false)
1335
+ */
1336
+ sendTypingIndicator(recipientId: string, typing?: boolean): Promise<SendMessageResponse>;
1337
+ }
1338
+
1339
+ /**
1340
+ * Conversations API Module
1341
+ *
1342
+ * Handles conversation and message retrieval.
1343
+ */
1344
+
1345
+ /**
1346
+ * Conversations API class for Instagram conversation operations
1347
+ */
1348
+ declare class ConversationsApi {
1349
+ private readonly http;
1350
+ private readonly userId;
1351
+ constructor(http: HttpClient, userId: string);
1352
+ /**
1353
+ * Get list of conversations
1354
+ * @param options - Pagination and filter options
1355
+ */
1356
+ list(options?: GetConversationsOptions): Promise<PaginatedResponse<Conversation>>;
1357
+ /**
1358
+ * Find conversation with a specific user
1359
+ * @param igsid - Instagram-scoped user ID
1360
+ */
1361
+ findByUser(igsid: string): Promise<PaginatedResponse<Conversation>>;
1362
+ /**
1363
+ * Get messages in a conversation
1364
+ * @param conversationId - Conversation ID
1365
+ * @param fields - Fields to retrieve (default: from,to)
1366
+ */
1367
+ getMessages(conversationId: string, fields?: string): Promise<{
1368
+ messages: PaginatedResponse<ConversationMessage>;
1369
+ }>;
1370
+ /**
1371
+ * Get a specific message
1372
+ * @param messageId - Message ID
1373
+ * @param fields - Fields to retrieve
1374
+ */
1375
+ getMessage(messageId: string, fields?: string): Promise<ConversationMessage>;
1376
+ }
1377
+
1378
+ /**
1379
+ * Comments API Module
1380
+ *
1381
+ * Handles comment moderation operations.
1382
+ */
1383
+
1384
+ /**
1385
+ * Comments API class for Instagram comment operations
1386
+ */
1387
+ declare class CommentsApi {
1388
+ private readonly http;
1389
+ constructor(http: HttpClient);
1390
+ /**
1391
+ * Get comment by ID
1392
+ * @param commentId - Comment ID
1393
+ * @param fields - Fields to retrieve
1394
+ */
1395
+ get(commentId: string, fields?: IGCommentField[]): Promise<IGComment>;
1396
+ /**
1397
+ * Get replies to a comment
1398
+ * @param commentId - Comment ID
1399
+ * @param options - Pagination and fields options
1400
+ */
1401
+ getReplies(commentId: string, options?: GetCommentsOptions): Promise<PaginatedResponse<IGComment>>;
1402
+ /**
1403
+ * Reply to a comment
1404
+ * @param commentId - Comment ID to reply to
1405
+ * @param options - Reply message
1406
+ */
1407
+ reply(commentId: string, options: ReplyToCommentOptions): Promise<IdResponse>;
1408
+ /**
1409
+ * Hide a comment
1410
+ * @param commentId - Comment ID
1411
+ */
1412
+ hide(commentId: string): Promise<SuccessResponse>;
1413
+ /**
1414
+ * Unhide a comment
1415
+ * @param commentId - Comment ID
1416
+ */
1417
+ unhide(commentId: string): Promise<SuccessResponse>;
1418
+ /**
1419
+ * Delete a comment
1420
+ * @param commentId - Comment ID
1421
+ */
1422
+ delete(commentId: string): Promise<SuccessResponse>;
1423
+ }
1424
+
1425
+ /**
1426
+ * Hashtag Types for Instagram Graph API SDK
1427
+ */
1428
+
1429
+ /**
1430
+ * Instagram Hashtag
1431
+ */
1432
+ interface IGHashtag {
1433
+ /** Hashtag ID */
1434
+ id: string;
1435
+ /** Hashtag name (without #) */
1436
+ name?: string;
1437
+ }
1438
+ /**
1439
+ * Hashtag search options
1440
+ */
1441
+ interface HashtagSearchOptions {
1442
+ /** User ID for context */
1443
+ user_id: string;
1444
+ /** Search query (hashtag name without #) */
1445
+ q: string;
1446
+ }
1447
+ /**
1448
+ * Hashtag search response
1449
+ */
1450
+ interface HashtagSearchResponse {
1451
+ data: IGHashtag[];
1452
+ }
1453
+ /**
1454
+ * Get hashtag media options
1455
+ */
1456
+ interface GetHashtagMediaOptions {
1457
+ /** User ID for context */
1458
+ user_id: string;
1459
+ /** Fields to return */
1460
+ fields?: string[];
1461
+ /** Maximum results */
1462
+ limit?: number;
1463
+ /** Pagination cursor */
1464
+ after?: string;
1465
+ }
1466
+ /**
1467
+ * Hashtag media response
1468
+ */
1469
+ type HashtagMediaResponse = PaginatedResponse<IGMedia>;
1470
+
1471
+ /**
1472
+ * Hashtags API Module
1473
+ *
1474
+ * Handles hashtag search and media retrieval.
1475
+ */
1476
+
1477
+ /**
1478
+ * Hashtags API class for Instagram hashtag operations
1479
+ */
1480
+ declare class HashtagsApi {
1481
+ private readonly http;
1482
+ constructor(http: HttpClient);
1483
+ /**
1484
+ * Search for a hashtag
1485
+ * @param options - User ID and search query
1486
+ */
1487
+ search(options: HashtagSearchOptions): Promise<HashtagSearchResponse>;
1488
+ /**
1489
+ * Get hashtag information
1490
+ * @param hashtagId - Hashtag ID
1491
+ */
1492
+ get(hashtagId: string): Promise<IGHashtag>;
1493
+ /**
1494
+ * Get recent media with hashtag
1495
+ * @param hashtagId - Hashtag ID
1496
+ * @param options - User ID and pagination options
1497
+ */
1498
+ getRecentMedia(hashtagId: string, options: GetHashtagMediaOptions): Promise<HashtagMediaResponse>;
1499
+ /**
1500
+ * Get top media with hashtag
1501
+ * @param hashtagId - Hashtag ID
1502
+ * @param options - User ID and pagination options
1503
+ */
1504
+ getTopMedia(hashtagId: string, options: GetHashtagMediaOptions): Promise<HashtagMediaResponse>;
1505
+ }
1506
+
1507
+ /**
1508
+ * Insights API Module
1509
+ *
1510
+ * Handles account and media insights.
1511
+ */
1512
+
1513
+ /**
1514
+ * Insights API class for Instagram analytics
1515
+ */
1516
+ declare class InsightsApi {
1517
+ private readonly http;
1518
+ private readonly userId;
1519
+ constructor(http: HttpClient, userId: string);
1520
+ /**
1521
+ * Get account insights
1522
+ * @param options - Metrics, period, and breakdown options
1523
+ */
1524
+ getAccountInsights(options: GetAccountInsightsOptions): Promise<InsightsResponse>;
1525
+ /**
1526
+ * Get media insights
1527
+ * @param mediaId - Media ID
1528
+ * @param options - Metrics to retrieve
1529
+ */
1530
+ getMediaInsights(mediaId: string, options: GetMediaInsightsOptions): Promise<InsightsResponse>;
1531
+ }
1532
+
1533
+ /**
1534
+ * Welcome Flow Types for Instagram Graph API SDK
1535
+ */
1536
+ /**
1537
+ * Welcome message flow action
1538
+ */
1539
+ interface FlowAction {
1540
+ /** Action type */
1541
+ type: 'QUICK_REPLY' | 'ICE_BREAKER' | 'CTA';
1542
+ /** Title shown to user */
1543
+ title?: string;
1544
+ /** Payload sent back on click */
1545
+ payload?: string;
1546
+ /** URL for CTA actions */
1547
+ url?: string;
1548
+ }
1549
+ /**
1550
+ * Welcome message flow screen
1551
+ */
1552
+ interface FlowScreen {
1553
+ /** Screen ID */
1554
+ id?: string;
1555
+ /** Screen title */
1556
+ title?: string;
1557
+ /** Screen body text */
1558
+ body?: string;
1559
+ /** Actions on this screen */
1560
+ actions?: FlowAction[];
1561
+ }
1562
+ /**
1563
+ * Welcome message flow
1564
+ */
1565
+ interface WelcomeMessageFlow {
1566
+ /** Flow ID */
1567
+ flow_id?: string;
1568
+ /** Flow name */
1569
+ name?: string;
1570
+ /** Flow screens */
1571
+ screens?: FlowScreen[];
1572
+ /** Whether flow is active */
1573
+ is_active?: boolean;
1574
+ /** ISO 8601 timestamp */
1575
+ created_time?: string;
1576
+ /** ISO 8601 timestamp */
1577
+ updated_time?: string;
1578
+ }
1579
+ /**
1580
+ * Create/Update flow options
1581
+ */
1582
+ interface WelcomeFlowOptions {
1583
+ name: string;
1584
+ screens: FlowScreen[];
1585
+ }
1586
+ /**
1587
+ * Get flows response
1588
+ */
1589
+ interface WelcomeFlowsResponse {
1590
+ data: WelcomeMessageFlow[];
1591
+ }
1592
+
1593
+ /**
1594
+ * Welcome Flows API Module
1595
+ *
1596
+ * Handles welcome message flow operations.
1597
+ */
1598
+
1599
+ /**
1600
+ * Welcome Flows API class for managing welcome message flows
1601
+ */
1602
+ declare class WelcomeFlowsApi {
1603
+ private readonly http;
1604
+ private readonly userId;
1605
+ constructor(http: HttpClient, userId: string);
1606
+ /**
1607
+ * Get all welcome message flows
1608
+ */
1609
+ list(): Promise<WelcomeFlowsResponse>;
1610
+ /**
1611
+ * Get a specific welcome message flow
1612
+ * @param flowId - Flow ID
1613
+ */
1614
+ get(flowId: string): Promise<WelcomeMessageFlow>;
1615
+ /**
1616
+ * Create a new welcome message flow
1617
+ * @param options - Flow name and screens
1618
+ */
1619
+ create(options: WelcomeFlowOptions): Promise<IdResponse>;
1620
+ /**
1621
+ * Update an existing welcome message flow
1622
+ * @param flowId - Flow ID
1623
+ * @param options - Updated flow name and screens
1624
+ */
1625
+ update(flowId: string, options: WelcomeFlowOptions): Promise<SuccessResponse>;
1626
+ /**
1627
+ * Delete a welcome message flow
1628
+ * @param flowId - Flow ID
1629
+ */
1630
+ delete(flowId: string): Promise<SuccessResponse>;
1631
+ }
1632
+
1633
+ /**
1634
+ * Messenger Profile Types for Instagram Graph API SDK
1635
+ * (Ice Breakers, Persistent Menu, etc.)
1636
+ */
1637
+ /**
1638
+ * Ice breaker question
1639
+ */
1640
+ interface IceBreakerQuestion {
1641
+ /** Question text shown to user */
1642
+ question: string;
1643
+ /** Payload sent back when clicked */
1644
+ payload: string;
1645
+ }
1646
+ /**
1647
+ * Ice breaker configuration
1648
+ */
1649
+ interface IceBreaker {
1650
+ /** Questions for this locale */
1651
+ call_to_actions: IceBreakerQuestion[];
1652
+ /** Locale code (e.g., 'en_US', 'zh_CN') */
1653
+ locale?: string;
1654
+ }
1655
+ /**
1656
+ * Set ice breakers options
1657
+ */
1658
+ interface SetIceBreakersOptions {
1659
+ /** Platform (always 'instagram') */
1660
+ platform: 'instagram';
1661
+ /** Ice breaker configurations */
1662
+ ice_breakers: IceBreaker[];
1663
+ }
1664
+ /**
1665
+ * Get ice breakers response
1666
+ */
1667
+ interface IceBreakersResponse {
1668
+ data: IceBreaker[];
1669
+ }
1670
+ /**
1671
+ * Persistent menu button
1672
+ */
1673
+ interface PersistentMenuButton {
1674
+ type: 'web_url' | 'postback';
1675
+ title: string;
1676
+ url?: string;
1677
+ payload?: string;
1678
+ }
1679
+ /**
1680
+ * Persistent menu configuration
1681
+ */
1682
+ interface PersistentMenu {
1683
+ /** Locale code */
1684
+ locale?: string;
1685
+ /** Whether to disable user input */
1686
+ composer_input_disabled?: boolean;
1687
+ /** Menu buttons */
1688
+ call_to_actions: PersistentMenuButton[];
1689
+ }
1690
+ /**
1691
+ * Set persistent menu options
1692
+ */
1693
+ interface SetPersistentMenuOptions {
1694
+ /** Platform (always 'instagram') */
1695
+ platform: 'instagram';
1696
+ /** Persistent menu configurations */
1697
+ persistent_menu: PersistentMenu[];
1698
+ }
1699
+ /**
1700
+ * Sender action type
1701
+ */
1702
+ type SenderAction = 'typing_on' | 'typing_off' | 'mark_seen';
1703
+
1704
+ /**
1705
+ * Messenger Profile API Module
1706
+ *
1707
+ * Handles Ice Breakers, Persistent Menu, and Sender Actions.
1708
+ */
1709
+
1710
+ /**
1711
+ * Messenger Profile API class for managing ice breakers and persistent menu
1712
+ */
1713
+ declare class MessengerProfileApi {
1714
+ private readonly http;
1715
+ private readonly userId;
1716
+ constructor(http: HttpClient, userId: string);
1717
+ /**
1718
+ * Get current ice breakers
1719
+ */
1720
+ getIceBreakers(): Promise<IceBreakersResponse>;
1721
+ /**
1722
+ * Set ice breakers (FAQ questions)
1723
+ * @param iceBreakers - Ice breaker configurations (max 4 questions per locale)
1724
+ */
1725
+ setIceBreakers(iceBreakers: IceBreaker[]): Promise<SuccessResponse>;
1726
+ /**
1727
+ * Delete ice breakers
1728
+ */
1729
+ deleteIceBreakers(): Promise<SuccessResponse>;
1730
+ /**
1731
+ * Get persistent menu
1732
+ */
1733
+ getPersistentMenu(): Promise<{
1734
+ data: PersistentMenu[];
1735
+ }>;
1736
+ /**
1737
+ * Set persistent menu
1738
+ * @param menus - Persistent menu configurations
1739
+ */
1740
+ setPersistentMenu(menus: PersistentMenu[]): Promise<SuccessResponse>;
1741
+ /**
1742
+ * Delete persistent menu
1743
+ */
1744
+ deletePersistentMenu(): Promise<SuccessResponse>;
1745
+ }
1746
+
1747
+ /**
1748
+ * oEmbed Types for Instagram Graph API SDK
1749
+ */
1750
+ /**
1751
+ * oEmbed response
1752
+ */
1753
+ interface OEmbedResponse {
1754
+ /** oEmbed version */
1755
+ version: string;
1756
+ /** oEmbed type */
1757
+ type: 'rich';
1758
+ /** Title (usually username) */
1759
+ title?: string;
1760
+ /** Author name */
1761
+ author_name?: string;
1762
+ /** Author URL */
1763
+ author_url?: string;
1764
+ /** Provider name */
1765
+ provider_name: 'Instagram';
1766
+ /** Provider URL */
1767
+ provider_url: string;
1768
+ /** HTML embed code */
1769
+ html: string;
1770
+ /** Embed width */
1771
+ width?: number;
1772
+ /** Embed height */
1773
+ height?: number | null;
1774
+ /** Thumbnail URL */
1775
+ thumbnail_url?: string;
1776
+ /** Thumbnail width */
1777
+ thumbnail_width?: number;
1778
+ /** Thumbnail height */
1779
+ thumbnail_height?: number;
1780
+ }
1781
+ /**
1782
+ * Get oEmbed options
1783
+ */
1784
+ interface GetOEmbedOptions {
1785
+ /** Instagram post URL */
1786
+ url: string;
1787
+ /** Maximum width */
1788
+ maxwidth?: number;
1789
+ /** Hide caption */
1790
+ hidecaption?: boolean;
1791
+ /** Omit script */
1792
+ omitscript?: boolean;
1793
+ }
1794
+
1795
+ /**
1796
+ * oEmbed API Module
1797
+ *
1798
+ * Handles oEmbed operations for embedding Instagram content.
1799
+ */
1800
+
1801
+ /**
1802
+ * oEmbed API class for embedding Instagram content
1803
+ */
1804
+ declare class OEmbedApi {
1805
+ private readonly http;
1806
+ constructor(http: HttpClient);
1807
+ /**
1808
+ * Get oEmbed data for an Instagram URL
1809
+ * @param options - URL and optional formatting options
1810
+ */
1811
+ get(options: GetOEmbedOptions): Promise<OEmbedResponse>;
1812
+ }
1813
+
1814
+ interface WebhookEntry {
1815
+ id: string;
1816
+ time: number;
1817
+ changes?: WebhookChange[];
1818
+ messaging?: WebhookMessagingEvent[];
1819
+ }
1820
+ interface WebhookChange {
1821
+ field: 'comments' | 'live_comments' | 'mentions' | 'messages' | 'message_reactions' | 'messaging_seen';
1822
+ value: any;
1823
+ }
1824
+ interface WebhookMessagingEvent {
1825
+ sender: {
1826
+ id: string;
1827
+ };
1828
+ recipient: {
1829
+ id: string;
1830
+ };
1831
+ timestamp: number;
1832
+ message?: {
1833
+ mid: string;
1834
+ text?: string;
1835
+ attachments?: any[];
1836
+ is_deleted?: boolean;
1837
+ is_echo?: boolean;
1838
+ reply_to?: {
1839
+ mid: string;
1840
+ };
1841
+ };
1842
+ reaction?: {
1843
+ mid: string;
1844
+ action: 'react' | 'unreact';
1845
+ reaction: string;
1846
+ emoji: string;
1847
+ };
1848
+ read?: {
1849
+ mid: string;
1850
+ };
1851
+ }
1852
+ interface WebhookPayload {
1853
+ object: 'instagram';
1854
+ entry: WebhookEntry[];
1855
+ }
1856
+ interface SubscribedFieldsResponse {
1857
+ data: {
1858
+ link: string;
1859
+ name: string;
1860
+ id: string;
1861
+ category: string;
1862
+ subscribed_fields: string[];
1863
+ }[];
1864
+ }
1865
+
1866
+ declare class WebhooksApi {
1867
+ private readonly http;
1868
+ private readonly userId;
1869
+ constructor(http: HttpClient, userId: string);
1870
+ /**
1871
+ * Subscribe your app to specific fields for this user/page.
1872
+ *
1873
+ * @param fields List of fields to subscribe to (e.g., ['messages', 'comments'])
1874
+ */
1875
+ subscribe(fields: string[]): Promise<{
1876
+ success: boolean;
1877
+ }>;
1878
+ /**
1879
+ * Unsubscribe from specific fields or all fields.
1880
+ *
1881
+ * @param fields Optional list of fields to unsubscribe from. If empty, unsubscribes from all.
1882
+ */
1883
+ unsubscribe(fields?: string[]): Promise<{
1884
+ success: boolean;
1885
+ }>;
1886
+ /**
1887
+ * Get the list of fields your app is currently subscribed to.
1888
+ */
1889
+ getSubscribedFields(): Promise<SubscribedFieldsResponse>;
1890
+ }
1891
+
1892
+ /**
1893
+ * Instagram Graph API SDK - Main Client
1894
+ *
1895
+ * Type-safe TypeScript SDK for Instagram Graph API with Instagram Login.
1896
+ *
1897
+ * @example
1898
+ * ```typescript
1899
+ * import { InstagramClient } from 'instagram-graph-api-sdk';
1900
+ *
1901
+ * const client = new InstagramClient({
1902
+ * accessToken: 'your-access-token',
1903
+ * apiVersion: 'v22.0', // optional, defaults to 'v22.0'
1904
+ * });
1905
+ *
1906
+ * // Get user profile
1907
+ * const profile = await client.users.getProfile({ fields: ['id', 'username'] });
1908
+ * console.log(profile);
1909
+ * ```
1910
+ */
1911
+
1912
+ /**
1913
+ * Instagram Graph API Client
1914
+ *
1915
+ * Main entry point for the SDK. Provides access to all API modules.
1916
+ */
1917
+ declare class InstagramClient {
1918
+ private readonly http;
1919
+ private readonly config;
1920
+ private cachedUserId;
1921
+ /** Authentication API - Token management */
1922
+ readonly auth: AuthApi;
1923
+ /** Users API - Profile, media, insights */
1924
+ readonly users: UsersApi;
1925
+ /** Media API - Get media, children, comments */
1926
+ readonly media: MediaApi;
1927
+ /** Publishing API - Publish images, videos, reels */
1928
+ readonly publishing: PublishingApi;
1929
+ /** Messaging API - Send messages, templates */
1930
+ readonly messaging: MessagingApi;
1931
+ /** Conversations API - List conversations, messages */
1932
+ readonly conversations: ConversationsApi;
1933
+ /** Comments API - Moderation */
1934
+ readonly comments: CommentsApi;
1935
+ /** Hashtags API - Search, media */
1936
+ readonly hashtags: HashtagsApi;
1937
+ /** Insights API - Analytics */
1938
+ readonly insights: InsightsApi;
1939
+ /** Welcome Flows API - Welcome message flows */
1940
+ readonly welcomeFlows: WelcomeFlowsApi;
1941
+ /** Messenger Profile API - Ice breakers, menu */
1942
+ readonly messengerProfile: MessengerProfileApi;
1943
+ /** oEmbed API - Embed content */
1944
+ readonly oembed: OEmbedApi;
1945
+ /** Webhooks API - Manage subscriptions */
1946
+ readonly webhooks: WebhooksApi;
1947
+ /**
1948
+ * Create a new Instagram client
1949
+ * @param config - Client configuration
1950
+ */
1951
+ constructor(config: InstagramClientConfig);
1952
+ /**
1953
+ * Get the current user ID
1954
+ * Fetches from API if not cached
1955
+ */
1956
+ getUserId(): Promise<string>;
1957
+ /**
1958
+ * Update the access token
1959
+ * @param accessToken - New access token
1960
+ */
1961
+ setAccessToken(accessToken: string): void;
1962
+ /**
1963
+ * Get the current configuration
1964
+ */
1965
+ getConfig(): Readonly<Required<InstagramClientConfig>>;
1966
+ /**
1967
+ * Get the API version
1968
+ */
1969
+ getApiVersion(): string;
1970
+ }
1971
+
1972
+ /**
1973
+ * Instagram API Error Classes
1974
+ *
1975
+ * Custom error classes for handling Instagram Graph API errors.
1976
+ */
1977
+ /**
1978
+ * Base error class for Instagram API errors
1979
+ */
1980
+ declare class InstagramAPIError extends Error {
1981
+ readonly code: number;
1982
+ readonly type: string;
1983
+ readonly subcode?: number;
1984
+ readonly fbTraceId?: string;
1985
+ constructor(message: string, code: number, type: string, subcode?: number, fbTraceId?: string);
1986
+ /**
1987
+ * Create an InstagramAPIError from an API response
1988
+ */
1989
+ static fromResponse(response: InstagramErrorResponse): InstagramAPIError;
1990
+ }
1991
+ /**
1992
+ * Authentication error (invalid/expired tokens)
1993
+ */
1994
+ declare class AuthenticationError extends InstagramAPIError {
1995
+ constructor(message: string, code?: number, fbTraceId?: string);
1996
+ }
1997
+ /**
1998
+ * Rate limit exceeded error
1999
+ */
2000
+ declare class RateLimitError extends InstagramAPIError {
2001
+ readonly retryAfter?: number;
2002
+ constructor(message: string, code?: number, fbTraceId?: string, retryAfter?: number);
2003
+ }
2004
+ /**
2005
+ * Validation error (invalid parameters)
2006
+ */
2007
+ declare class ValidationError extends InstagramAPIError {
2008
+ constructor(message: string, code?: number, subcode?: number, fbTraceId?: string);
2009
+ }
2010
+ /**
2011
+ * Network error (connection issues)
2012
+ */
2013
+ declare class NetworkError extends Error {
2014
+ readonly originalError?: Error;
2015
+ constructor(message: string, originalError?: Error);
2016
+ }
2017
+ /**
2018
+ * Instagram API error response structure
2019
+ */
2020
+ interface InstagramErrorResponse {
2021
+ error: {
2022
+ message: string;
2023
+ type: string;
2024
+ code: number;
2025
+ error_subcode?: number;
2026
+ fbtrace_id?: string;
2027
+ };
2028
+ }
2029
+ /**
2030
+ * Check if an error is an Instagram API error
2031
+ */
2032
+ declare function isInstagramAPIError(error: unknown): error is InstagramAPIError;
2033
+ /**
2034
+ * Check if an error is an authentication error
2035
+ */
2036
+ declare function isAuthenticationError(error: unknown): error is AuthenticationError;
2037
+ /**
2038
+ * Check if an error is a rate limit error
2039
+ */
2040
+ declare function isRateLimitError(error: unknown): error is RateLimitError;
2041
+ /**
2042
+ * Check if an error is a validation error
2043
+ */
2044
+ declare function isValidationError(error: unknown): error is ValidationError;
2045
+
2046
+ /**
2047
+ * Instagram Graph API Endpoints
2048
+ *
2049
+ * Centralized endpoint definitions for easy maintenance.
2050
+ * Update this file when Instagram API documentation changes.
2051
+ *
2052
+ * Base URL: https://graph.instagram.com
2053
+ * API Version: Configurable (default: v22.0)
2054
+ */
2055
+ declare const INSTAGRAM_BASE_URL = "https://graph.instagram.com";
2056
+ /**
2057
+ * Build a full API URL with version
2058
+ */
2059
+ declare function buildUrl(version: string, path: string): string;
2060
+ /**
2061
+ * User Endpoints
2062
+ */
2063
+ declare const USER_ENDPOINTS: {
2064
+ /** Get user profile: GET /{user-id} */
2065
+ readonly PROFILE: (userId: string) => string;
2066
+ /** Get user media: GET /{user-id}/media */
2067
+ readonly MEDIA: (userId: string) => string;
2068
+ /** Get user stories: GET /{user-id}/stories */
2069
+ readonly STORIES: (userId: string) => string;
2070
+ /** Get user insights: GET /{user-id}/insights */
2071
+ readonly INSIGHTS: (userId: string) => string;
2072
+ /** Get live media: GET /{user-id}/live_media */
2073
+ readonly LIVE_MEDIA: (userId: string) => string;
2074
+ /** Get content publishing limit: GET /{user-id}/content_publishing_limit */
2075
+ readonly CONTENT_PUBLISHING_LIMIT: (userId: string) => string;
2076
+ /** Get business discovery: GET /{user-id}?fields=business_discovery.username(...) */
2077
+ readonly BUSINESS_DISCOVERY: (userId: string) => string;
2078
+ /** Get mentioned media: GET /{user-id}/mentioned_media */
2079
+ readonly MENTIONED_MEDIA: (userId: string) => string;
2080
+ /** Get mentioned comment: GET /{user-id}/mentioned_comment */
2081
+ readonly MENTIONED_COMMENT: (userId: string) => string;
2082
+ /** Get tags: GET /{user-id}/tags */
2083
+ readonly TAGS: (userId: string) => string;
2084
+ /** Get recently searched hashtags: GET /{user-id}/recently_searched_hashtags */
2085
+ readonly RECENTLY_SEARCHED_HASHTAGS: (userId: string) => string;
2086
+ /** Get available catalogs: GET /{user-id}/available_catalogs */
2087
+ readonly AVAILABLE_CATALOGS: (userId: string) => string;
2088
+ /** Search catalog products: GET /{user-id}/catalog_product_search */
2089
+ readonly CATALOG_PRODUCT_SEARCH: (userId: string) => string;
2090
+ };
2091
+ /**
2092
+ * Media Endpoints
2093
+ */
2094
+ declare const MEDIA_ENDPOINTS: {
2095
+ /** Get media by ID: GET /{media-id} */
2096
+ readonly GET: (mediaId: string) => string;
2097
+ /** Get media children (carousel): GET /{media-id}/children */
2098
+ readonly CHILDREN: (mediaId: string) => string;
2099
+ /** Get media comments: GET /{media-id}/comments */
2100
+ readonly COMMENTS: (mediaId: string) => string;
2101
+ /** Get media insights: GET /{media-id}/insights */
2102
+ readonly INSIGHTS: (mediaId: string) => string;
2103
+ /** Get media collaborators: GET /{media-id}/collaborators */
2104
+ readonly COLLABORATORS: (mediaId: string) => string;
2105
+ /** Get product tags: GET /{media-id}/product_tags */
2106
+ readonly PRODUCT_TAGS: (mediaId: string) => string;
2107
+ };
2108
+ /**
2109
+ * Publishing Endpoints
2110
+ */
2111
+ declare const PUBLISHING_ENDPOINTS: {
2112
+ /** Create media container: POST /{user-id}/media */
2113
+ readonly CREATE_CONTAINER: (userId: string) => string;
2114
+ /** Publish media: POST /{user-id}/media_publish */
2115
+ readonly PUBLISH: (userId: string) => string;
2116
+ /** Get container status: GET /{container-id} */
2117
+ readonly CONTAINER_STATUS: (containerId: string) => string;
2118
+ };
2119
+ /**
2120
+ * Messaging Endpoints
2121
+ */
2122
+ declare const MESSAGING_ENDPOINTS: {
2123
+ /** Send message: POST /{user-id}/messages */
2124
+ readonly SEND: (userId: string) => string;
2125
+ /** Get conversations: GET /{user-id}/conversations */
2126
+ readonly CONVERSATIONS: (userId: string) => string;
2127
+ /** Get conversation by ID: GET /{conversation-id} */
2128
+ readonly CONVERSATION: (conversationId: string) => string;
2129
+ /** Get message by ID: GET /{message-id} */
2130
+ readonly MESSAGE: (messageId: string) => string;
2131
+ };
2132
+ /**
2133
+ * Welcome Message Flow Endpoints
2134
+ */
2135
+ declare const WELCOME_FLOW_ENDPOINTS: {
2136
+ /** Get/Create/Update flows: /{user-id}/welcome_message_flows */
2137
+ readonly FLOWS: (userId: string) => string;
2138
+ };
2139
+ /**
2140
+ * Messenger Profile Endpoints (Ice Breakers, Persistent Menu)
2141
+ */
2142
+ declare const MESSENGER_PROFILE_ENDPOINTS: {
2143
+ /** Get/Set/Delete profile: /{user-id}/messenger_profile */
2144
+ readonly PROFILE: (userId: string) => string;
2145
+ };
2146
+ /**
2147
+ * Comment Endpoints
2148
+ */
2149
+ declare const COMMENT_ENDPOINTS: {
2150
+ /** Get comment: GET /{comment-id} */
2151
+ readonly GET: (commentId: string) => string;
2152
+ /** Get replies: GET /{comment-id}/replies */
2153
+ readonly REPLIES: (commentId: string) => string;
2154
+ /** Reply to comment: POST /{comment-id}/replies */
2155
+ readonly REPLY: (commentId: string) => string;
2156
+ /** Hide/Unhide comment: POST /{comment-id} */
2157
+ readonly UPDATE: (commentId: string) => string;
2158
+ /** Delete comment: DELETE /{comment-id} */
2159
+ readonly DELETE: (commentId: string) => string;
2160
+ };
2161
+ /**
2162
+ * Hashtag Endpoints
2163
+ */
2164
+ declare const HASHTAG_ENDPOINTS: {
2165
+ /** Search hashtag: GET /ig_hashtag_search */
2166
+ readonly SEARCH: "/ig_hashtag_search";
2167
+ /** Get hashtag: GET /{hashtag-id} */
2168
+ readonly GET: (hashtagId: string) => string;
2169
+ /** Get recent media: GET /{hashtag-id}/recent_media */
2170
+ readonly RECENT_MEDIA: (hashtagId: string) => string;
2171
+ /** Get top media: GET /{hashtag-id}/top_media */
2172
+ readonly TOP_MEDIA: (hashtagId: string) => string;
2173
+ };
2174
+ /**
2175
+ * Auth Endpoints (require access token)
2176
+ */
2177
+ declare const AUTH_ENDPOINTS: {
2178
+ /** Get current user: GET /me */
2179
+ readonly ME: "/me";
2180
+ /** Refresh token: GET /refresh_access_token */
2181
+ readonly REFRESH_TOKEN: "/refresh_access_token";
2182
+ /** Exchange token: GET /access_token */
2183
+ readonly ACCESS_TOKEN: "/access_token";
2184
+ };
2185
+ /**
2186
+ * OAuth Endpoints (for Instagram Business Login)
2187
+ * Note: These use different base URLs than the Graph API
2188
+ */
2189
+ declare const OAUTH_ENDPOINTS: {
2190
+ /** Authorization URL - redirect users here to start OAuth flow */
2191
+ readonly AUTHORIZE: "https://www.instagram.com/oauth/authorize";
2192
+ /** Short-lived token exchange: POST with form data */
2193
+ readonly TOKEN: "https://api.instagram.com/oauth/access_token";
2194
+ /** Long-lived token exchange: GET with query params */
2195
+ readonly LONG_LIVED_TOKEN: "https://graph.instagram.com/access_token";
2196
+ };
2197
+ /**
2198
+ * oEmbed Endpoints
2199
+ */
2200
+ declare const OEMBED_ENDPOINTS: {
2201
+ /** Get oEmbed: GET /instagram_oembed */
2202
+ readonly GET: "/instagram_oembed";
2203
+ };
2204
+
2205
+ declare class InstagramWebhooks {
2206
+ /**
2207
+ * Verify that the webhook request came from Meta.
2208
+ * Calculates SHA256 HMAC of the raw body using the App Secret.
2209
+ *
2210
+ * @param body Raw request body as string
2211
+ * @param signature Signature from X-Hub-Signature-256 header (e.g., "sha256=...")
2212
+ * @param appSecret Your Instagram App Secret
2213
+ * @returns true if signature is valid
2214
+ */
2215
+ static verifySignature(body: string, signature: string, appSecret: string): boolean;
2216
+ /**
2217
+ * Type guard and parser for webhook payloads.
2218
+ *
2219
+ * @param body Parsed JSON body
2220
+ * @returns Typed WebhookPayload or throws error
2221
+ */
2222
+ static parsePayload(body: any): WebhookPayload;
2223
+ }
2224
+
2225
+ export { AUTH_ENDPOINTS, type AccountMetric, type AttachmentPayload, type AttachmentType, AuthApi, AuthenticationError, type AuthorizationUrlParams, type AvailableCatalog, type BaseContainerOptions, type BusinessDiscovery, type BusinessDiscoveryOptions, type ButtonTemplateOptions, COMMENT_ENDPOINTS, type CatalogProduct, CommentsApi, type ContainerMediaType, type ContainerResponse, type ContainerStatus, type ContainerStatusCode, type ContentPublishingLimit, type Conversation, type ConversationMessage, ConversationsApi, type CreateCarouselContainerOptions, type CreateImageContainerOptions, type CreateVideoContainerOptions, type DemographicsBreakdown, type ExchangeCodeParams, type FieldsOptions, type FieldsParam, type FlowAction, type FlowScreen, type GenericTemplateOptions, type GetAccountInsightsOptions, type GetCommentsOptions, type GetConversationsOptions, type GetHashtagMediaOptions, type GetMediaChildrenOptions, type GetMediaInsightsOptions, type GetMediaOptions, type GetOEmbedOptions, type GetUserMediaOptions, type GetUserProfileOptions, HASHTAG_ENDPOINTS, type HashtagMediaResponse, type HashtagSearchOptions, type HashtagSearchResponse, HashtagsApi, HttpClient, type HttpClientConfig, type IGAccountType, type IGComment, type IGCommentField, type IGHashtag, type IGMedia, type IGMediaChild, type IGMediaField, type IGUser, type IGUserField, IG_COMMENT_FIELDS, IG_MEDIA_FIELDS, IG_USER_FIELDS, INSTAGRAM_BASE_URL, type IceBreaker, type IceBreakerQuestion, type IceBreakersResponse, type IdResponse, type InsightData, type InsightPeriod, type InsightValue, InsightsApi, type InsightsPeriod, type InsightsResponse, InstagramAPIError, InstagramClient, type InstagramClientConfig, type InstagramErrorResponse, InstagramOAuth, type InstagramScope, InstagramWebhooks, type ListOptions, type ListWithFieldsOptions, type LongLivedTokenResponse$1 as LongLivedTokenResponse, MEDIA_ENDPOINTS, MESSAGING_ENDPOINTS, MESSENGER_PROFILE_ENDPOINTS, MediaApi, type MediaChildrenResponse, type MediaCollaborator, type MediaMetric, type MediaProductType, type MediaType, type MessageAttachment, type MessageContent, type MessageRecipient, MessagingApi, MessengerProfileApi, type MetricBreakdown, NetworkError, OAUTH_ENDPOINTS, type OAuthCallbackParams, type OAuthConfig, type OAuthError, type ShortLivedTokenResponse as OAuthShortLivedTokenResponse, type OAuthTokenResponse, OEMBED_ENDPOINTS, OEmbedApi, type OEmbedResponse, PUBLISHING_ENDPOINTS, type PaginatedResponse, type Paging, type PagingCursors, type PersistentMenu, type PersistentMenuButton, type ProductTag, type PublishResponse, PublishingApi, type QuickRepliesOptions, type QuickReply, RateLimitError, type ReactionType, type RecentlySearchedHashtag, type ReplyToCommentOptions, type ResumableUploadOptions, type SendMediaOptions, type SendMessageRequest, type SendMessageResponse, type SendTextOptions, type SenderAction, type SetIceBreakersOptions, type SetPersistentMenuOptions, type ShortLivedTokenResponse, type SingleResponse, type SubscribedFieldsResponse, type SuccessResponse, type TemplateButton, type TemplateElement, type TokenResponse, type TrialReelOptions, USER_ENDPOINTS, type UpdateCommentOptions, type UserMention, type UserTag, UsersApi, ValidationError, WELCOME_FLOW_ENDPOINTS, type WebhookChange, type WebhookEntry, type WebhookMessagingEvent, type WebhookPayload, WebhooksApi, type WelcomeFlowOptions, WelcomeFlowsApi, type WelcomeFlowsResponse, type WelcomeMessageFlow, buildUrl, formatFields, isAuthenticationError, isInstagramAPIError, isRateLimitError, isValidationError };