Code Monkey home page Code Monkey logo

plemmy's Introduction

Plemmy: a Python package for accessing the Lemmy API

drawing

GitHub version PyPI version GitHub license

Plemmy allows you to interact with any Lemmy instance using Python and the LemmyHttp API.

WARNING: Plemmy is still in development and needs testing!

Installation

For the most up-to-date version of Plemmy, clone and install from the repository:

git clone https://github.com/lemmyworld/plemmy
cd plemmy
python -m pip install .

A PyPI repository is updated whenever a new version is available:

python -m pip install plemmy

Basic usage

Interact with a Lemmy instance using the LemmyHttp object:

from plemmy import LemmyHttp

# create object for Lemmy.ml, log in
srv = LemmyHttp("https://lemmy.world")
srv.login("<username_or_email>", "<password>")

Access specific communities:

from plemmy.responses import GetCommunityResponse

# obtain community, parse JSON
api_response = srv.get_community(name="Lemmy")
response = GetCommunityResponse(api_response)

# community info
community = response.community_view.community
print(community.name)
print(community.actor_id)
print(community.id)

# list community moderators
for person in response.moderators:
    print(person.moderator.name, person.community.name)

Create a post:

from plemmy.responses import PostResponse

# create post, parse JSON
api_response = srv.create_post(community.id, "Test post please ignore", "Body text")
response = PostResponse(api_response)

# post info
post = response.post_view.post
print(post.creator_id)
print(post.community_id)
print(post.name)
print(post.body)

Full documentation is on its way, but in the meantime check out our source code and some examples.

Reporting issues, making contributions, etc.

Don't hesitate to report a bug or unexpected results! Want to contribute? Make a pull request. Contact @tjkessler with any questions.

plemmy's People

Contributors

tjkessler avatar jheidecker avatar feelixs avatar gwbischof avatar benja810 avatar socphoenix avatar deliciouslysmug avatar ihyoudou avatar jlukeblakey avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.