Someone’s started a Python wrapper around the lemmy API

3 years ago by maegul to c/fediverse

db0 65 points 3 years ago

Hey everyone, "someone" here, AMA :D

path: 0 596899, hotness: undefined, score: 65, children: 10
SwingingKoala 9 points 3 years ago
path: 0 596899 597054, hotness: undefined, score: 9, children: 1
db0 18 points 3 years ago

We have quite a few examples and the code is statically typed and well commented. I hope we can figure out an automatic doc creation system

path: 0 596899 597054 597076, hotness: undefined, score: 18, children: 0
Richardisaguy 6 points 3 years ago

Do you like garlic bread?

path: 0 596899 611757, hotness: undefined, score: 6, children: 1
db0 6 points 3 years ago

very

path: 0 596899 611757 612243, hotness: undefined, score: 6, children: 0
makingStuffForFun 5 points 3 years ago

I'd love to write a bot for my own community. I used to use praw, when reddit was a thing.

Can you see your wrapper being used this way? If so, is it ready for this yet? If so, is there any example code or docs on this?

Thanks for your work, it's very much appreciated.

path: 0 596899 598029, hotness: undefined, score: 5, children: 1
db0 5 points 3 years ago

Yes there isn't a reason not to use it as a bot. We don't have all the API endpoints yet as we add them usually as we need them, but if you need one we don't have, just open a PR or send an issue and we'll handle it.

path: 0 596899 598029 601477, hotness: undefined, score: 5, children: 0
Machefi 5 points 3 years ago
path: 0 596899 598946, hotness: undefined, score: 5, children: 1
varaki 3 points 3 years ago
path: 0 596899 598946 603570, hotness: undefined, score: 3, children: 0
redrumBot 1 point 3 years ago

I think that this question from my non bot account has not reached you:

@carlesmu@lemmygrad.ml wrote:

Thanks for the wrapper :)

Two questions:

  1. Where can I find the relation between languages and the languages_id ints?

  2. When I log in into a lemmy instance I check the protected member _requestor.nodeinfo to detect if the problem it’s the connection or the user/password:

     lemmy = Lemmy(instance)
    
     if not lemmy.log_in(user, password):
         if not lemmy._requestor.nodeinfo:
             raise LemmyException(f"Sorry, cannot connect to lemmy instance {instance}.")
         raise LemmyException(
             f"Sorry, cannot login {user} into {instance}. Bad user or wrong password."
         )
    

    There is a better way to validate it?

path: 0 596899 655983, hotness: undefined, score: 1, children: 1
db0 2 points 3 years ago

I believe pythorhead writes a specific log when you try too login to a non python instance. The node info likewise has a function to retrieve it

path: 0 596899 655983 656157, hotness: undefined, score: 2, children: 0
Demigodrick 13 points 3 years ago path: 0 596634, hotness: undefined, score: 13, children: 0
db0 9 points 3 years ago path: 0 596975, hotness: undefined, score: 9, children: 0
BrownPolarBear 8 points 3 years ago

"someone"

path: 0 596406, hotness: undefined, score: 8, children: 0
fediverse
fediverse

@lemmy.ml

login for more options
26114
1275
112

A community dedicated to fediverse news and discussion.

go to feed...