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?

  • nachtigall@feddit.de
    link
    fedilink
    English
    arrow-up
    6
    arrow-down
    1
    ·
    1 year ago

    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

    • NeonWoofGenesis@lemmy.henlo.fi
      link
      fedilink
      English
      arrow-up
      1
      ·
      edit-2
      1 year ago

      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.

      # POST to login endpoint
      curl -v --data '{"username_or_email": "username", "password": "password"}' --header 'Content-Type: application/json' https://example.com/api/v3/user/login