this post was submitted on 04 Jul 2023
7 points (88.9% liked)
Lemmy Support
4656 readers
10 users here now
Support / questions about Lemmy.
founded 5 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
For subscribed communities you have to add an
auth
parameter (that you can obtain by POST'ing{"username_or_email": "your_name", "password": "your_password"}
to/user/login
, then extracting thejwt
from the response) andtype_=Subscribed
. A complete request would look like that:curl "https://mander.xyz/api/v3/community/list?auth=verylongstring&type_=Subscribed" | jq
EDIT: added missing quotes for JSON keys, thanks to @NeonWoofGenesis@lemmy.henlo.fi
Rofl I don't know why someone downvoted you, this was nice information thanks.
I like to add that the keys must be wrapped in double quotes to be parsed as proper JSON.
You are totally right, seems like I forgot them ^^'
While this is the correct syntax, in reality the API is broken and isn't returning communities (either filtered or sorted first) by their listingtype == "Subscribed"
This works! Thanks.
If you're up for it, one last question: just running
curl "https://mander.xyz/api/v3/community/list?auth=longstring&type_=Subscribed
gives me only a few subscribed communities.I can increase the number of subscribed communities that I get back, by adding
&limit=
.curl "https://mander.xyz/api/v3/community/list?auth=longstring&type_=Subscribed&limit=50"
However, putting the limit too low I don't get all my subscribed communities, while putting the limit too high results in an error.
Is there a way to set limit to "max" or the limit to "nil" or something like that?
Wait, I see, the fetch limit is 50...
Any ideas how I could easily get all communities I subscribed to?
Ok, I'll keep the monologue going: turns out I can loop through pages with that limit:
curl "https://mander.xyz/api/v3/community/list?auth=longstring&type_=Subscribed&limit=50&page=1
And then
curl "https://mander.xyz/api/v3/community/list?auth=longstring&type_=Subscribed&limit=50&page=2
Etc.
What if the account has 2FA?
In that case add a
totp_2fa_token
field to the login struct which holds the top token. The rest remains the same.