I’m currently setting up a Python wrapper for Lemmy’s API, my aim being to develop a moderation bot (more info here), so I’m building the wrapper as the bot requests it.
It’s my first time doing this, so don’t hesitate to contribute if you find it useful: https://codeberg.org/retiolus/Lemmy.py
Usage example:
from lemmy import Lemmy
# Login to your account
lemmy = Lemmy("https://lemmy.ml")
lemmy.log_in("username_or_email", "password")
# Get a community ID
community_id = lemmy.discover_community("community_name")
# Get all posts from a community by ID
community_posts = lemmy.post.list(community_id=community_id)
# Get the modlog of your server
modlog = lemmy.modlog.get()
# Post a new publication on a community
lemmy.post.create(community_id=community_id, name="First Post!", body="This is the first community post.")
Awesome! I couldn’t find how do I get the
auth
token when I read the official API docs.There is no “app”
auth
token yet, as I know, so you get your token from a normal log in.Ah, I see. I’m reading your code and it’s very helpfull. Thanks!