Skip to main content

A Python package for accessing the LemmyHttp API

Project description

Pythonlemmy: a Python package for accessing the Lemmy API

drawing

GitHub version PyPI version GitHub license

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

WARNING: Pythonlemmy is still in development and needs testing!

Installation

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

python -m pip install pythonlemmy

Basic usage

Interact with a Lemmy instance using the LemmyHttp object:

from pythonlemmy import LemmyHttp

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

Access specific communities:

from pythonlemmy.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 pythonlemmy.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

pythonlemmy-0.1.2.tar.gz (26.6 kB view details)

Uploaded Source

Built Distribution

pythonlemmy-0.1.2-py3-none-any.whl (32.1 kB view details)

Uploaded Python 3

File details

Details for the file pythonlemmy-0.1.2.tar.gz.

File metadata

  • Download URL: pythonlemmy-0.1.2.tar.gz
  • Upload date:
  • Size: 26.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.5

File hashes

Hashes for pythonlemmy-0.1.2.tar.gz
Algorithm Hash digest
SHA256 3eb9d171244e69a3f20ddab3d0be1440b8ddd2e3f0a1fb066c1e3515f4a9a2ae
MD5 3e97f81aa844d1e9ac91d6f60a49ffef
BLAKE2b-256 9ca180d4310fd96383f8d88d13fb7afae655960f7ac5ac63de39ecec02bf3467

See more details on using hashes here.

File details

Details for the file pythonlemmy-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: pythonlemmy-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 32.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.5

File hashes

Hashes for pythonlemmy-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 e3b6f5a1730ce580b620b6a3e07021c48be47943450e4b53f3cfcec21bd5a15a
MD5 ad801b3079b1eaa0ea5963cb69b5fbeb
BLAKE2b-256 e6618340abbf974994451f816a8c1939f61d12f91d6461c62993a029e4ba15a2

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