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.

Comments on Lemmy API: how to get list of followed/subscribed communities.

Parent

Lemmy API: how to get list of followed/subscribed communities.

+5
−0

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 response containing a 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 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"
]
History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.
Why should this post be closed?

0 comment threads

Post
+1
−0

You are correct, my_user is only returned when you supply the auth parameter.

It looks like you're getting the JWT with no issues, based on your response to /api/v3/user/login, but you must be passing the auth parameter incorrectly if you're not getting a my_user object in the response to /api/v3/site.

Try passing it as a query parameter instead of a body parameter: insomnia screenshot showing

History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.

1 comment thread

Works for me (1 comment)
Works for me
elvis_depresley‭ wrote over 1 year ago

I didn't realise the auth was passed in as an URL parameter. This works for me, thank you!