Liking and reposting
Liking and reposting posts are core Bluesky actions. A like or repost is itself a record in the user's repository — many SDKs provide dedicated helpers for creating and removing them.
Liking a post
Liking a post requires the post's URI and its CID.
The URI indicates the repository DID, collection, and record key. The CID is the hash of the record itself.
- TypeScript
- Python
- Go
import { like } from '@bsky/sdk'
const { uri: likeUri } = await client.call(like, { uri, cid })
uri = client.like(uri=uri, cid=cid).uri
The Go SDK has no dedicated helper; create an app.bsky.feed.like record pointing at the post:
like := &appbsky.FeedLike{
CreatedAt: time.Now().UTC().Format(time.RFC3339),
Subject: &comatproto.RepoStrongRef{Uri: uri, Cid: cid},
}
resp, _ := comatproto.RepoCreateRecord(ctx, client, &comatproto.RepoCreateRecord_Input{
Repo: client.AccountDID.String(),
Collection: "app.bsky.feed.like",
Record: &lexutil.LexiconTypeDecoder{Val: like},
})
| Parameter | Type | Description | Required |
|---|---|---|---|
uri | string | The URI of the post | Yes |
cid | string | The CID of the post | Yes |
Unliking a post
Unliking a post requires only the post's URI, which refers to its record. In the case of a Like, unliking the post means deleting the Like record.
- TypeScript
- Python
- Go
import { deleteLike } from '@bsky/sdk'
await client.call(deleteLike, likeUri)
client.delete_like(uri)
Delete the like record. Its rkey is the last segment of the URI returned when you created it:
import "strings"
rkey := uri[strings.LastIndex(uri, "/")+1:]
comatproto.RepoDeleteRecord(ctx, client, &comatproto.RepoDeleteRecord_Input{
Repo: client.AccountDID.String(),
Collection: "app.bsky.feed.like",
Rkey: rkey,
})
| Parameter | Type | Description | Required |
|---|---|---|---|
uri | string | The URI of the like record to delete | Yes |
Reposting a post
Reposting and un-reposting looks almost exactly the same as liking and unliking.
- TypeScript
- Python
- Go
import { repost } from '@bsky/sdk'
const { uri: repostUri } = await client.call(repost, { uri, cid })
uri = client.repost(uri=uri, cid=cid).uri
Same pattern as a like, with the app.bsky.feed.repost collection:
repost := &appbsky.FeedRepost{
CreatedAt: time.Now().UTC().Format(time.RFC3339),
Subject: &comatproto.RepoStrongRef{Uri: uri, Cid: cid},
}
resp, _ := comatproto.RepoCreateRecord(ctx, client, &comatproto.RepoCreateRecord_Input{
Repo: client.AccountDID.String(),
Collection: "app.bsky.feed.repost",
Record: &lexutil.LexiconTypeDecoder{Val: repost},
})
| Parameter | Type | Description | Required |
|---|---|---|---|
uri | string | The URI of the post | Yes |
cid | string | The CID of the post | Yes |
Un-reposting a post
Same as unlike, un-reposting a post requires only the post's URI, whose record we want to delete.
- TypeScript
- Python
- Go
import { deleteRepost } from '@bsky/sdk'
await client.call(deleteRepost, repostUri)
client.delete_repost(uri)
Delete the repost record by its rkey, as with unliking:
rkey := uri[strings.LastIndex(uri, "/")+1:]
comatproto.RepoDeleteRecord(ctx, client, &comatproto.RepoDeleteRecord_Input{
Repo: client.AccountDID.String(),
Collection: "app.bsky.feed.repost",
Rkey: rkey,
})
| Parameter | Type | Description | Required |
|---|---|---|---|
uri | string | The URI of the repost record to delete | Yes |
Quote reposting
For information on quote posts, see the Create a post tutorial.