Comment on What are the activity_id formats for various platforms?
Jayjader@jlai.lu 22 hours ago
From my own experience querying public mastodon timelines via API:
- Mastodon user accounts have an ActivityPub URI of
https://<instance.domain.tld>/api/v1/users/<username>
- Mastodon posts have an ActivityPub URI of
https://<instance.domain.tld>/api/v1/users/<post_author_username>/statuses/<post_id>
(they also have aurl
property ofhttps://<instance.domain.tld>/@<post_author_username>/<post_id>
but that tends to serve the html view of the post)
To see for yourself, pick an instance that allows viewing their public timeline without logging in (mastodon.social
is perfect for this) and follow the “Playing with public data” section of the docs. That page ellides most of the info you’re looking for in the example payloads they give (as the JSON payloads themself are quite large and nested), but I can assure you that AP_IDs for user accounts and posts can be found pretty quickly from a single timeline query.
I don’t think Mastodon has any notion of community, nor does it distinguish between posts and comments (when following a lemmy community, both posts and comments show up in my masto feed as “top-level” statuses (ie posts)).
admiralpatrick@lemmy.world 21 hours ago
Cool, thanks. I was close with
/user
guessing from memory.I think the
/users/…/post_id
will be sufficient. It just needs to know that the given URL is an AP_ID before passing it off to the API call toresolveObject
. Since it already knowsinstance.domain.tld
is a federated instance, it just needs to see if the path is an AP_ID or the HTML (or something else). Thus, I don’t have to parse the whole thing, just check that enough of it matches.Thanks!