igdm-cli
igdm-cli copied to clipboard
feature request: view older messages
Providing additional information here:
It's been a long time I didn't use the API, but I can't remember if it's paginated or not. As a reminder, the API used is not official so I'm not sure if it's documented or even usable.
It's possible to specify an offset which is referred to as cursor. For example:
(async () => {
const recentInbox = await ig.direct.getInbox();
let nextCursor = recentInbox.oldest_cursor;
while (nextCursor) {
const olderInbox = await ig.direct.getInbox({ cursor: nextCursor });
// Iterate through conversations and access messages
for (const thread of olderInbox) {
for (const item of thread.items) {
// Process the message item
console.log(item.text);
}
}
nextCursor = olderInbox.oldest_cursor;
}
})();