Skip to content

Interface: MediaApi ​

Single media reads and actions.

Methods ​

archive() ​

ts
archive(mediaId): Promise<void>;

Hides one of the account's posts from the profile, keeping it in the archive.

Parameters ​

ParameterType
mediaIdstring

Returns ​

Promise<void>


comment() ​

ts
comment(
   mediaId, 
   text, 
   options?
): Promise<{
[key: string]: unknown;
  content_type?: string;
  created_at?: number;
  pk?: string;
  status?: string;
  text?: string;
  user?: {
   [key: string]: unknown;
     biography?: string;
     external_url?: string | null;
     follower_count?: number | null;
     following_count?: number | null;
     full_name?: string;
     is_private?: boolean;
     is_verified?: boolean;
     media_count?: number | null;
     pk?: string;
     profile_pic_url?: string | null;
     username?: string;
  };
}>;

Comments on a post, or replies to a comment.

Parameters ​

ParameterType
mediaIdstring
textstring
options?CommentOptions

Returns ​

Promise<{ [key: string]: unknown; content_type?: string; created_at?: number; pk?: string; status?: string; text?: string; user?: { [key: string]: unknown; biography?: string; external_url?: string | null; follower_count?: number | null; following_count?: number | null; full_name?: string; is_private?: boolean; is_verified?: boolean; media_count?: number | null; pk?: string; profile_pic_url?: string | null; username?: string; }; }>


comments() ​

ts
comments(mediaId, options?): Promise<Page<{
[key: string]: unknown;
  content_type?: string;
  created_at?: number;
  pk?: string;
  status?: string;
  text?: string;
  user?: {
   [key: string]: unknown;
     biography?: string;
     external_url?: string | null;
     follower_count?: number | null;
     following_count?: number | null;
     full_name?: string;
     is_private?: boolean;
     is_verified?: boolean;
     media_count?: number | null;
     pk?: string;
     profile_pic_url?: string | null;
     username?: string;
  };
}>>;

One page of the comments on a post.

Parameters ​

ParameterType
mediaIdstring
options?CommentListOptions

Returns ​

Promise<Page<{ [key: string]: unknown; content_type?: string; created_at?: number; pk?: string; status?: string; text?: string; user?: { [key: string]: unknown; biography?: string; external_url?: string | null; follower_count?: number | null; following_count?: number | null; full_name?: string; is_private?: boolean; is_verified?: boolean; media_count?: number | null; pk?: string; profile_pic_url?: string | null; username?: string; }; }>>


delete() ​

ts
delete(mediaId, mediaType?): Promise<void>;

Deletes one of the account's own posts.

Parameters ​

ParameterType
mediaIdstring
mediaType?"PHOTO" | "VIDEO" | "CAROUSEL" | "STORY"

Returns ​

Promise<void>


deleteComment() ​

ts
deleteComment(mediaId, commentId): Promise<void>;

Deletes a comment.

Parameters ​

ParameterType
mediaIdstring
commentIdstring

Returns ​

Promise<void>


deleteComments() ​

ts
deleteComments(mediaId, commentIds): Promise<void>;

Deletes several comments on a post at once.

Parameters ​

ParameterType
mediaIdstring
commentIdsreadonly string[]

Returns ​

Promise<void>


edit() ​

ts
edit(mediaId, options): Promise<{
[key: string]: unknown;
  caption?:   | {
   [key: string]: unknown;
     text?: string;
   }
     | null;
  code?: string;
  comment_count?: number | null;
  id?: string;
  image_versions2?: {
   [key: string]: unknown;
     candidates?: object[];
  };
  like_count?: number | null;
  media_type?: number;
  pk?: string;
  taken_at?: number;
  user?: {
   [key: string]: unknown;
     biography?: string;
     external_url?: string | null;
     follower_count?: number | null;
     following_count?: number | null;
     full_name?: string;
     is_private?: boolean;
     is_verified?: boolean;
     media_count?: number | null;
     pk?: string;
     profile_pic_url?: string | null;
     username?: string;
  };
  usertags?:   | {
   [key: string]: unknown;
     in?: object[];
   }
     | null;
  video_versions?: object[] | null;
}>;

Changes the caption or the tagged people of one of the account's posts.

Parameters ​

ParameterType
mediaIdstring
optionsEditMediaOptions

Returns ​

Promise<{ [key: string]: unknown; caption?: | { [key: string]: unknown; text?: string; } | null; code?: string; comment_count?: number | null; id?: string; image_versions2?: { [key: string]: unknown; candidates?: object[]; }; like_count?: number | null; media_type?: number; pk?: string; taken_at?: number; user?: { [key: string]: unknown; biography?: string; external_url?: string | null; follower_count?: number | null; following_count?: number | null; full_name?: string; is_private?: boolean; is_verified?: boolean; media_count?: number | null; pk?: string; profile_pic_url?: string | null; username?: string; }; usertags?: | { [key: string]: unknown; in?: object[]; } | null; video_versions?: object[] | null; }>


info() ​

ts
info(mediaId): Promise<{
[key: string]: unknown;
  caption?:   | {
   [key: string]: unknown;
     text?: string;
   }
     | null;
  code?: string;
  comment_count?: number | null;
  id?: string;
  image_versions2?: {
   [key: string]: unknown;
     candidates?: object[];
  };
  like_count?: number | null;
  media_type?: number;
  pk?: string;
  taken_at?: number;
  user?: {
   [key: string]: unknown;
     biography?: string;
     external_url?: string | null;
     follower_count?: number | null;
     following_count?: number | null;
     full_name?: string;
     is_private?: boolean;
     is_verified?: boolean;
     media_count?: number | null;
     pk?: string;
     profile_pic_url?: string | null;
     username?: string;
  };
  usertags?:   | {
   [key: string]: unknown;
     in?: object[];
   }
     | null;
  video_versions?: object[] | null;
}>;

A post with its caption, counts and author.

Parameters ​

ParameterType
mediaIdstring

Returns ​

Promise<{ [key: string]: unknown; caption?: | { [key: string]: unknown; text?: string; } | null; code?: string; comment_count?: number | null; id?: string; image_versions2?: { [key: string]: unknown; candidates?: object[]; }; like_count?: number | null; media_type?: number; pk?: string; taken_at?: number; user?: { [key: string]: unknown; biography?: string; external_url?: string | null; follower_count?: number | null; following_count?: number | null; full_name?: string; is_private?: boolean; is_verified?: boolean; media_count?: number | null; pk?: string; profile_pic_url?: string | null; username?: string; }; usertags?: | { [key: string]: unknown; in?: object[]; } | null; video_versions?: object[] | null; }>


like() ​

ts
like(mediaId): Promise<void>;

Likes a post.

Parameters ​

ParameterType
mediaIdstring

Returns ​

Promise<void>


likeComment() ​

ts
likeComment(commentId): Promise<void>;

Likes a comment.

Parameters ​

ParameterType
commentIdstring

Returns ​

Promise<void>


likers() ​

ts
likers(mediaId): Promise<object[]>;

The users who liked a post.

Parameters ​

ParameterType
mediaIdstring

Returns ​

Promise<object[]>


paginateComments() ​

ts
paginateComments(mediaId): AsyncGenerator<{
[key: string]: unknown;
  content_type?: string;
  created_at?: number;
  pk?: string;
  status?: string;
  text?: string;
  user?: {
   [key: string]: unknown;
     biography?: string;
     external_url?: string | null;
     follower_count?: number | null;
     following_count?: number | null;
     full_name?: string;
     is_private?: boolean;
     is_verified?: boolean;
     media_count?: number | null;
     pk?: string;
     profile_pic_url?: string | null;
     username?: string;
  };
}>;

Walks the comments on a post, one at a time across pages.

Parameters ​

ParameterType
mediaIdstring

Returns ​

AsyncGenerator<{ [key: string]: unknown; content_type?: string; created_at?: number; pk?: string; status?: string; text?: string; user?: { [key: string]: unknown; biography?: string; external_url?: string | null; follower_count?: number | null; following_count?: number | null; full_name?: string; is_private?: boolean; is_verified?: boolean; media_count?: number | null; pk?: string; profile_pic_url?: string | null; username?: string; }; }>


paginateReplies() ​

ts
paginateReplies(mediaId, commentId): AsyncGenerator<{
[key: string]: unknown;
  content_type?: string;
  created_at?: number;
  pk?: string;
  status?: string;
  text?: string;
  user?: {
   [key: string]: unknown;
     biography?: string;
     external_url?: string | null;
     follower_count?: number | null;
     following_count?: number | null;
     full_name?: string;
     is_private?: boolean;
     is_verified?: boolean;
     media_count?: number | null;
     pk?: string;
     profile_pic_url?: string | null;
     username?: string;
  };
}>;

Walks the replies to a comment, one at a time across pages.

Parameters ​

ParameterType
mediaIdstring
commentIdstring

Returns ​

AsyncGenerator<{ [key: string]: unknown; content_type?: string; created_at?: number; pk?: string; status?: string; text?: string; user?: { [key: string]: unknown; biography?: string; external_url?: string | null; follower_count?: number | null; following_count?: number | null; full_name?: string; is_private?: boolean; is_verified?: boolean; media_count?: number | null; pk?: string; profile_pic_url?: string | null; username?: string; }; }>


paginateSaved() ​

ts
paginateSaved(): AsyncGenerator<{
[key: string]: unknown;
  caption?:   | {
   [key: string]: unknown;
     text?: string;
   }
     | null;
  code?: string;
  comment_count?: number | null;
  id?: string;
  image_versions2?: {
   [key: string]: unknown;
     candidates?: object[];
  };
  like_count?: number | null;
  media_type?: number;
  pk?: string;
  taken_at?: number;
  user?: {
   [key: string]: unknown;
     biography?: string;
     external_url?: string | null;
     follower_count?: number | null;
     following_count?: number | null;
     full_name?: string;
     is_private?: boolean;
     is_verified?: boolean;
     media_count?: number | null;
     pk?: string;
     profile_pic_url?: string | null;
     username?: string;
  };
  usertags?:   | {
   [key: string]: unknown;
     in?: object[];
   }
     | null;
  video_versions?: object[] | null;
}>;

Walks the saved posts, one at a time across pages.

Returns ​

AsyncGenerator<{ [key: string]: unknown; caption?: | { [key: string]: unknown; text?: string; } | null; code?: string; comment_count?: number | null; id?: string; image_versions2?: { [key: string]: unknown; candidates?: object[]; }; like_count?: number | null; media_type?: number; pk?: string; taken_at?: number; user?: { [key: string]: unknown; biography?: string; external_url?: string | null; follower_count?: number | null; following_count?: number | null; full_name?: string; is_private?: boolean; is_verified?: boolean; media_count?: number | null; pk?: string; profile_pic_url?: string | null; username?: string; }; usertags?: | { [key: string]: unknown; in?: object[]; } | null; video_versions?: object[] | null; }>


pin() ​

ts
pin(mediaId): Promise<void>;

Pins one of the account's posts to the top of the profile grid.

Parameters ​

ParameterType
mediaIdstring

Returns ​

Promise<void>


pinComment() ​

ts
pinComment(mediaId, commentId): Promise<void>;

Pins a comment to the top of one of the account's posts.

Parameters ​

ParameterType
mediaIdstring
commentIdstring

Returns ​

Promise<void>


replies() ​

ts
replies(
   mediaId, 
   commentId, 
   options?
): Promise<Page<{
[key: string]: unknown;
  content_type?: string;
  created_at?: number;
  pk?: string;
  status?: string;
  text?: string;
  user?: {
   [key: string]: unknown;
     biography?: string;
     external_url?: string | null;
     follower_count?: number | null;
     following_count?: number | null;
     full_name?: string;
     is_private?: boolean;
     is_verified?: boolean;
     media_count?: number | null;
     pk?: string;
     profile_pic_url?: string | null;
     username?: string;
  };
}>>;

One page of the replies to a comment.

Parameters ​

ParameterType
mediaIdstring
commentIdstring
options?ReplyListOptions

Returns ​

Promise<Page<{ [key: string]: unknown; content_type?: string; created_at?: number; pk?: string; status?: string; text?: string; user?: { [key: string]: unknown; biography?: string; external_url?: string | null; follower_count?: number | null; following_count?: number | null; full_name?: string; is_private?: boolean; is_verified?: boolean; media_count?: number | null; pk?: string; profile_pic_url?: string | null; username?: string; }; }>>


save() ​

ts
save(mediaId, options?): Promise<void>;

Saves a post, to the general saved list or to one collection.

Parameters ​

ParameterType
mediaIdstring
options?SaveOptions

Returns ​

Promise<void>


saved() ​

ts
saved(options?): Promise<Page<{
[key: string]: unknown;
  caption?:   | {
   [key: string]: unknown;
     text?: string;
   }
     | null;
  code?: string;
  comment_count?: number | null;
  id?: string;
  image_versions2?: {
   [key: string]: unknown;
     candidates?: object[];
  };
  like_count?: number | null;
  media_type?: number;
  pk?: string;
  taken_at?: number;
  user?: {
   [key: string]: unknown;
     biography?: string;
     external_url?: string | null;
     follower_count?: number | null;
     following_count?: number | null;
     full_name?: string;
     is_private?: boolean;
     is_verified?: boolean;
     media_count?: number | null;
     pk?: string;
     profile_pic_url?: string | null;
     username?: string;
  };
  usertags?:   | {
   [key: string]: unknown;
     in?: object[];
   }
     | null;
  video_versions?: object[] | null;
}>>;

One page of the saved posts.

Parameters ​

ParameterType
options?CommentListOptions

Returns ​

Promise<Page<{ [key: string]: unknown; caption?: | { [key: string]: unknown; text?: string; } | null; code?: string; comment_count?: number | null; id?: string; image_versions2?: { [key: string]: unknown; candidates?: object[]; }; like_count?: number | null; media_type?: number; pk?: string; taken_at?: number; user?: { [key: string]: unknown; biography?: string; external_url?: string | null; follower_count?: number | null; following_count?: number | null; full_name?: string; is_private?: boolean; is_verified?: boolean; media_count?: number | null; pk?: string; profile_pic_url?: string | null; username?: string; }; usertags?: | { [key: string]: unknown; in?: object[]; } | null; video_versions?: object[] | null; }>>


unarchive() ​

ts
unarchive(mediaId): Promise<void>;

Puts an archived post back on the profile.

Parameters ​

ParameterType
mediaIdstring

Returns ​

Promise<void>


unlike() ​

ts
unlike(mediaId): Promise<void>;

Removes a like from a post.

Parameters ​

ParameterType
mediaIdstring

Returns ​

Promise<void>


unlikeComment() ​

ts
unlikeComment(commentId): Promise<void>;

Removes a like from a comment.

Parameters ​

ParameterType
commentIdstring

Returns ​

Promise<void>


unpin() ​

ts
unpin(mediaId): Promise<void>;

Unpins a post from the profile grid.

Parameters ​

ParameterType
mediaIdstring

Returns ​

Promise<void>


unpinComment() ​

ts
unpinComment(mediaId, commentId): Promise<void>;

Unpins a comment.

Parameters ​

ParameterType
mediaIdstring
commentIdstring

Returns ​

Promise<void>


unsave() ​

ts
unsave(mediaId, options?): Promise<void>;

Removes a post from the saved posts, or from one collection.

Parameters ​

ParameterType
mediaIdstring
options?SaveOptions

Returns ​

Promise<void>

MIT License. Not affiliated with, endorsed or sponsored by Meta or Instagram.