naystack - v1.5.10
    Preparing search index...

    Function getInstagramConversations

    • Fetches Instagram conversations (DM threads) with pagination support.

      Parameters

      • token: string

        Instagram access token.

      • limit: number = 25

        Page size. Default: 25.

      • Optionalcursor: string

        Optional pagination cursor (from a previous fetchMore).

      Returns Promise<
          {
              data: | {
                  id: string;
                  messages: { created_time: string; id: string }[]
                  | undefined;
                  participants: { id: string; username: string }[] | undefined;
                  updated_time: string;
              }[]
              | undefined;
              fetchMore: | (
                  () => Promise<{ data: { messages: { id: string; created_time: string; }[] | undefined; participants: { id: string; username: string; }[] | undefined; id: string; updated_time: string; }[] | undefined; fetchMore: (() => Promise<...>) | undefined; }>
              )
              | undefined;
          },
      >

      Promise of { data: InstagramConversation[], fetchMore?: () => Promise<...> }. Call fetchMore() to load the next page.

      import { getInstagramConversations } from "naystack/socials";

      const convos = await getInstagramConversations(accessToken, 25);
      for (const convo of convos.data ?? []) {
      console.log(convo.participants, convo.messages);
      }
      if (convos.fetchMore) {
      const nextPage = await convos.fetchMore();
      }