Skip to content

Timelines

Fetch home timelines and other feed-like content.

Response format

All timeline methods return a parsed object:

js
{
  tweets: [ /* parsed tweet objects */ ],
  users: [ /* parsed user objects (when applicable) */ ],
  nextCursor: "DAABCgAB...",      // pass to opts.cursor for the next page
  previousCursor: "DAABCgAA...",  // pass to opts.cursor to go back
  raw: { /* original Twitter response */ },
}

timelines.home(opts?)

Get your home timeline (algorithmic). Uses the GraphQL HomeTimeline query.

OptionTypeDescription
opts.countnumberNumber of results (default 20)
opts.cursorstringPagination cursor
opts.variablesobjectAdditional GraphQL variables
js
const { tweets, nextCursor } = await client.timelines.home();
console.log(tweets[0].text);

// Paginate
const page2 = await client.timelines.home({ cursor: nextCursor });

// Fetch more
const big = await client.timelines.home({ count: 50 });

timelines.homeLatest(opts?)

Get your home timeline sorted by latest (chronological). Uses the GraphQL HomeLatestTimeline query.

OptionTypeDescription
opts.countnumberNumber of results (default 20)
opts.cursorstringPagination cursor
opts.variablesobjectAdditional GraphQL variables
js
const { tweets } = await client.timelines.homeLatest();

timelines.connect(opts?)

Get the "Connect" tab timeline (who to follow suggestions, etc.). Uses the GraphQL ConnectTabTimeline query.

OptionTypeDescription
opts.countnumberNumber of results (default 20)
opts.cursorstringPagination cursor
opts.variablesobjectAdditional GraphQL variables
js
const { users } = await client.timelines.connect();

timelines.moderated(opts?)

Get the moderated timeline (tweets hidden from your profile). Uses the GraphQL ModeratedTimeline query.

OptionTypeDescription
opts.countnumberNumber of results (default 20)
opts.cursorstringPagination cursor
opts.variablesobjectAdditional GraphQL variables
js
const { tweets } = await client.timelines.moderated();

timelines.creatorSubscriptions(opts?)

Get the creator subscriptions timeline. Uses the GraphQL CreatorSubscriptionsTimeline query.

OptionTypeDescription
opts.countnumberNumber of results (default 20)
opts.cursorstringPagination cursor
opts.variablesobjectAdditional GraphQL variables
js
const { tweets } = await client.timelines.creatorSubscriptions();

Pagination

All timeline methods return nextCursor and previousCursor automatically. Pass them as opts.cursor:

js
// First page
const page1 = await client.timelines.home({ count: 20 });
console.log(page1.tweets);

// Next page
const page2 = await client.timelines.home({ cursor: page1.nextCursor });

// Collect multiple pages
const allTweets = [];
let cursor;
for (let i = 0; i < 5; i++) {
  const page = await client.timelines.home({ count: 20, cursor });
  allTweets.push(...page.tweets);
  cursor = page.nextCursor;
  if (!cursor) break;
}

timelines.updatePinned(pinnedTimelineItems)

Set the pinned timelines shown as tabs on your home screen (lists, communities, etc.). Uses the GraphQL UpdatePinnedTimelines mutation. Pass the full ordered array of pinned timeline items.

js
await client.timelines.updatePinned([
  { /* pinned timeline item */ },
]);

not affiliated with X Corp.