Skip to content

Interface: CollectionApi ​

The account's saved-posts collections and the posts it has liked.

Methods ​

create() ​

ts
create(name, mediaIds?): Promise<{
[key: string]: unknown;
  collection_id: string;
  collection_media_count?: number | null;
  collection_name?: string;
  collection_type?: string;
}>;

Creates a collection, optionally holding some posts (by pk) from the start.

Parameters ​

ParameterType
namestring
mediaIds?readonly string[]

Returns ​

Promise<{ [key: string]: unknown; collection_id: string; collection_media_count?: number | null; collection_name?: string; collection_type?: string; }>


delete() ​

ts
delete(collectionId): Promise<void>;

Deletes a collection; the posts in it stay saved.

Parameters ​

ParameterType
collectionIdstring

Returns ​

Promise<void>


liked() ​

ts
liked(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;
}>>;

The posts the account has liked.

Parameters ​

ParameterType
options?CursorOptions

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; }>>


list() ​

ts
list(): Promise<object[]>;

Every collection, the automatic ones included.

Returns ​

Promise<object[]>


medias() ​

ts
medias(collectionId, 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 posts saved in a collection.

Parameters ​

ParameterType
collectionIdstring
options?CursorOptions

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; }>>


paginateLiked() ​

ts
paginateLiked(): 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 liked posts.

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; }>


paginateMedias() ​

ts
paginateMedias(collectionId): 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 posts saved in a collection.

Parameters ​

ParameterType
collectionIdstring

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; }>

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