Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Q&A

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

77%
+5 −0
Q&A 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 endpoint, I should be able to get a ...

1 answer  ·  posted 1y ago by elvis_depresley‭  ·  last activity 1y ago by tgxn‭

Question rest lemmy curl
#2: Nominated for promotion by user avatar Alexei‭ · 2023-07-13T08:24:52Z (over 1 year ago)
#1: Initial revision by user avatar elvis_depresley‭ · 2023-07-02T14:49:16Z (over 1 year ago)
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"
]
```