this post was submitted on 04 Jul 2023
0 points (NaN% liked)

Lemmy Support

4629 readers
1 users here now

Support / questions about Lemmy.

Matrix Space: #lemmy-space

founded 5 years ago
MODERATORS
 

I would like to be able to use the command line (curl) to get a list of communities I am currently subscribed to.

I know that there is a full-blown API, but it only briefly covers what it is possible with simple a curl request, and most of it seems to refer to an API that runs in javascript (which seems excessively complex for what I want to do?)

A simple curl request like this seems to work,

curl "https://mander.xyz/api/v3/community/list" | jq

But I wouldn't know how to make it list only communities that I subscribe to? Does anyone know more?

top 3 comments
sorted by: hot top controversial new old
[–] nachtigall@feddit.de 0 points 1 year ago* (last edited 1 year ago) (1 children)

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 the jwt from the response) and type_=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

[–] PCChipsM922U@sh.itjust.works 0 points 1 year ago (1 children)

What if the account has 2FA?

[–] nachtigall@feddit.de 0 points 1 year ago* (last edited 1 year ago)

In that case add a totp_2fa_token field to the login struct which holds the top token. The rest remains the same.