Skip to main content

Python API for LemmyHttp

Project description

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/tjkessler/plemmy
cd plemmy
python setup.py install

A PyPI repository is periodically updated:

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.ml")
srv.login("<username_or_email>", "<password>")

Access specific communities:

from plemmy.responses import GetComunityResponse

# 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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

plemmy-0.3.1.tar.gz (21.3 kB view details)

Uploaded Source

Built Distribution

plemmy-0.3.1-py2.py3-none-any.whl (21.5 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file plemmy-0.3.1.tar.gz.

File metadata

  • Download URL: plemmy-0.3.1.tar.gz
  • Upload date:
  • Size: 21.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.3

File hashes

Hashes for plemmy-0.3.1.tar.gz
Algorithm Hash digest
SHA256 209bd1862c633ebcf75a0ba72e414cf886cc1e7f0216e6d91f0ef274776b04d5
MD5 e5b353eb8020b80128ff61f26a62e4a0
BLAKE2b-256 55a94899a35806640dbf679bd445829fdac56d7c822dcf624f946acdde628977

See more details on using hashes here.

File details

Details for the file plemmy-0.3.1-py2.py3-none-any.whl.

File metadata

  • Download URL: plemmy-0.3.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 21.5 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.3

File hashes

Hashes for plemmy-0.3.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 97621383904f6cf066b5ce918ed826d7bfd4c24d39ade322e8e136143a7ea1c4
MD5 194d8951cabb94521b2f1891e4e80859
BLAKE2b-256 a615c358bf6ce5cd155da3782fe036b5af250338369911854ce817ef539789d5

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page