Skip to content

Latest commit

 

History

History
35 lines (25 loc) · 1.38 KB

user.md

File metadata and controls

35 lines (25 loc) · 1.38 KB

User

Fetching a users details usually follows a webfinger against the user to validate they exist.

Given a valid webfinger such as the following

https://mastinator.com/.well-known/webfinger?resource=acct:[email protected]

We can then query their self location to determine their inbox,

{
    "subject": "acct:[email protected]",
    "links": [
        {
            "rel": "self",
            "type": "application/activity+json",
            "href": "https://mastinator.com/u/someaccount"
        }
    ]
}

The important part in the above is the links.rel where self indicates that the href for this object contains the location of this users details.

We can then issue a get request to this endpoint to get the details for the user.

curl --location --request GET 'https://mastinator.com/u/someaccount' \
--header 'Accept: application/ld+json; profile="https://www.w3.org/ns/activitystreams"

For mastodon the accept headers of application/activity+json, application/ld+json; profile="https://www.w3.org/ns/activitystreams or application/json will work for the above call, but many instance types will reject the first two. It is safer to use the first one which strictly speaking is more correct anyway.

Note that fetching the url without this header will usually result in a redirect to the HTML version of the users inbox, or return HTML directly.