Bluesky Comments
I saw a really cool implementation of a comment system on someones site using their mastodon instance. I also run a mastodon instance, but none of my friends actually use it. Which would make it harder for them to comment on my posts.
A lot of them have moved to Bluesky from Twitter, and I heard it's pretty open with it's API so I thought I'd give it a try doing something similar, but with it instead of Mastodon.
There's an API endpoint for getting a thread at
/xrpc/app.bsky.feed.getPostThread
but it requires a
uri
parameter. This URI parameter is made up of my user
did
, the collection
and the object
id
. Making the final pattern something like this:
at://<did>/<collection>/<id>
I know the collection for posts is
app.bsky.feed.post
from reading through their docs, and
the object id is just the characters at the end of the post URL, but
getting the user did was a bit harder.
The API endpoint /xrpc/app.bsky.actor.getProfile
allows
you to get a bunch of information about a user, including their
did
. It's just passed as a query parameter.
/xrpc/app.bsky.actor.getProfile?actor=pfy.ch
Which returns my did:
did:plc:lpxtxymhlfbs5foxba7mfewt
So - to get this posts comments I'll pass this AT-URI:
at://did:plc:lpxtxymhlfbs5foxba7mfewt/app.bsky.feed.post/3livnrzudt22s
and it returns all replies to that post!
I dont handle embeds, threads or links yet - only top level replies. But it should be pretty easy to add those if I decide to down the line. Overall it was surprisingly easy to get working & I'll likely start posting about my stuff here more often on Bluesky since they're now intertwined with my website. Really hoping that Bluesky doesnt get enshittified and close their API down in 5 years. 🤞