Skip to main content

A Python package for accessing the LemmyHttp API

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/Fedihosting-Foundation/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.

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.4.2.tar.gz (22.4 kB view details)

Uploaded Source

Built Distribution

plemmy-0.4.2-py3-none-any.whl (23.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: plemmy-0.4.2.tar.gz
  • Upload date:
  • Size: 22.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.9.18

File hashes

Hashes for plemmy-0.4.2.tar.gz
Algorithm Hash digest
SHA256 86cb052714255815bcf6fda2d6bf99b135f50829ca4d43e979009201c04a289f
MD5 6dd28eeea03777eefe73c9aed7b2f3b9
BLAKE2b-256 7fc25aa2f808cc0dc0129075df80ed1ad6d01ea83124d43361932c46d18025d8

See more details on using hashes here.

File details

Details for the file plemmy-0.4.2-py3-none-any.whl.

File metadata

  • Download URL: plemmy-0.4.2-py3-none-any.whl
  • Upload date:
  • Size: 23.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.9.18

File hashes

Hashes for plemmy-0.4.2-py3-none-any.whl
Algorithm Hash digest
SHA256 c0b55a72fcf82e91c7161e7e32cf656d58298a4f0c045949f1f2f7a8fc13d907
MD5 ec3f1de513683583d7a9bdb433be5d00
BLAKE2b-256 2bc80e6fab793a59a53d720bd60dad59f03d83d69a66c4bf06065d989c4edbcd

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