Skip to main content

Custom feeds

Custom feeds are algorithmic feed generators. To users, this is their timeline. This tutorial will explain how to interact with a feed generator in the network.

tip

Anybody can create custom feed. See the Custom Feeds Starter Template to get started.

Getting a feed generator's description

Call app.bsky.feed.getFeedGenerator to view a feedgen's description.

agent.app.bsky.feed.getFeedGenerator({
feed: feedUri
})

The output will match this interface:

getFeedGenerator() output
{
view: { // AppBskyFeedDefs.GeneratorView
uri: string;
cid: string;
did: string;
creator: AppBskyActorDefs.ProfileView;
displayName: string;
description?: string;
descriptionFacets?: AppBskyRichtextFacet.Main[];
avatar?: string;
likeCount?: number;
viewer?: GeneratorViewerState;
indexedAt: string;
}
isOnline: boolean;
isValid: boolean;
}

Viewing a feed generator's posts

Call app.bsky.feed.getFeed to view posts from a feedgen.

agent.app.bsky.feed.getFeed({
feed: feedUri,
limit: 30,
cursor
})

The output will match this interface:

getFeed() output
{
cursor?: string;
feed: AppBskyFeedDefs.FeedViewPost[];
}

Use the returned cursor to fetch additional pages of posts.

Has the user liked a feedgen?

When you call app.bsky.feed.getFeedGenerator, you can examine the viewer field to determine if the user has liked the feedgen.

viewer object
{
like?: string; // the URI of the like record if liked
}

For example:

const res = await agent.app.bsky.feed.getFeedGenerator({
feed: feedUri
})
if (res.data.list.viewer?.like) {
// has liked list
}

Liking and unliking a feedgen

Liking a feed is the same as liking any other item in the network. You just use the URI and CID of the feed generator to identify the feed.

const {data: feedInfo} = agent.app.bsky.feed.getFeedGenerator({
feed: feedUri
})
await agent.like(feedUri, feedInfo.view.cid)

Unliking a feed works the same way:

const {data: feedInfo} = agent.app.bsky.feed.getFeedGenerator({
feed: feedUri
})
await agent.unlike(feedInfo.view.viewer.like)