Skip to content

A conversation ​

Reached from the inbox or "New message".

Every example starts from saved, the checkpoint the index describes; the launch hands the feed, and a tab edge lands on the tab's root.

Open a conversation ​

ts
// Open a conversation from the inbox and read its messages.
const messages = await AndroidIgpapi.launch({
  checkpoint: saved,
  screen: FeedTimelineScreen,
  main: feed =>
    Effect.gen(function* () {
      const tab = yield* feed.openDirectTab();
      const item = tab.threads[0];
      if (item === undefined) return [];
      // The thread subscribes presence and loads the conversation.
      const thread = yield* item.open();
      return thread.messages.map(message => message.data.item_type);
    }),
});
console.log(messages);

Write a message ​

A message typed in a conversationA message typed in a conversation: sendMessage(text).

ts
// Send a text message in a conversation of the inbox.
const sent = await AndroidIgpapi.launch({
  checkpoint: saved,
  screen: FeedTimelineScreen,
  main: feed =>
    Effect.gen(function* () {
      const tab = yield* feed.openDirectTab();
      const item = tab.threads[0];
      if (item === undefined) return undefined;
      const thread = yield* item.open();
      return yield* thread.sendMessage('Hello from igpapi');
    }),
});
console.log(sent);

A failed sendA send that failed: your program gets a typed error (Errors).

The attachment menuThe + menu (location, poll, images): not offered.

React to a message ​

The message menu with the reaction barThe long-press menu with the reaction bar: react('like'). Unsend is not offered.

The unsend noticeUnsend: not offered.

ts
// React to a message with a like.
const reacted = await AndroidIgpapi.launch({
  checkpoint: saved,
  screen: FeedTimelineScreen,
  main: feed =>
    Effect.gen(function* () {
      const tab = yield* feed.openDirectTab();
      const item = tab.threads[0];
      if (item === undefined) return undefined;
      const thread = yield* item.open();
      const message = thread.messages[0];
      if (message === undefined) return undefined;
      return yield* message.react('like');
    }),
});
console.log(reacted);

Write from a profile ​

ts
// Write to a person from their profile: the "Message" button opens the conversation.
const fromProfile = await AndroidIgpapi.launch({
  checkpoint: saved,
  screen: FeedTimelineScreen,
  main: feed =>
    Effect.gen(function* () {
      const tab = yield* feed.openSearchTab();
      let typed = yield* tab.openSearchInput();
      typed = yield* typed.change('instagram');
      const results = yield* typed.search('instagram');
      const users = yield* results.openUsers();
      const first = users.results[0];
      if (first === undefined) return undefined;
      const profile = yield* first.openProfile();
      const thread = yield* profile.openDirectThread();
      return yield* thread.sendMessage('Hi from your profile');
    }),
});
console.log(fromProfile);

The pages of this site are the README files of the repository. The API reference is generated from the source.