Welcome to Software Development on Codidact!
Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.
Post History
Context Using the lemmy API, I'm trying to get a list of sublemmies (lemmy communities) that a user is following. Reading the documentation, I using the /site endpoint, I should be able to get a ...
#1: Initial revision
Lemmy API: how to get list of followed/subscribed communities.
## Context Using the lemmy API, I'm trying to get a list of sublemmies (lemmy communities) that a user is following. Reading the documentation, I using the [`/site`](https://join-lemmy.org/api/classes/LemmyHttp.html#getSite) endpoint, I should be able to get a response containing a [`my_user`](https://join-lemmy.org/api/interfaces/GetSiteResponse.html#my_user) property. However, when I query it, the response never contains the `my_user` property. I've tried querying with and without sending the [`auth`](https://join-lemmy.org/api/interfaces/GetSite.html#auth) property. I couldn't find any documentation on when the optional `my_user` property is returned. I'm assuming it required authentication. I've tried querying using rust, insomnia and curl. Here are some of the curl queries (without real credentials of course): ### Getting JWT token #### Query ``` curl \ -H "Content-Type: application/json" \ -X POST \ -d '{ "username_or_email": "<username>", "password": "<password>" }' https://lemmy.ml/api/v3/user/login ``` #### Response ``` {"jwt":"<redacted>","registration_created":false,"verify_email_sent":false} ``` ### Using `jq` to list top level keys from the response: #### Query ``` curl \ -H "Content-Type: application/json" \ -X GET \ -d '{ "auth": "<JWT token generated via the /login endpoint>" }' \ https://lemmy.ml/api/v3/site\ | jq 'keys' ``` #### Response (parsed by `jq`) Notice this doesn't include any `my_user` property. ``` [ "admins", "all_languages", "custom_emojis", "discussion_languages", "site_view", "taglines", "version" ] ```