Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/Fedihosting-Foundation/plemmy
A Python package for accessing the LemmyHttp API
https://github.com/Fedihosting-Foundation/plemmy
api lemmy
Last synced: 3 months ago
JSON representation
A Python package for accessing the LemmyHttp API
- Host: GitHub
- URL: https://github.com/Fedihosting-Foundation/plemmy
- Owner: Fedihosting-Foundation
- License: apache-2.0
- Created: 2023-06-19T02:45:36.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-08-03T13:17:24.000Z (3 months ago)
- Last Synced: 2024-08-03T14:31:33.978Z (3 months ago)
- Topics: api, lemmy
- Language: Python
- Homepage:
- Size: 183 KB
- Stars: 43
- Watchers: 8
- Forks: 15
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-lemmy - plemmy - Foundation/plemmy) ![GitHub commit activity](https://img.shields.io/github/commit-activity/y/Fedihosting-Foundation/plemmy) (Projects / Libraries)
README
# Plemmy: a Python package for accessing the Lemmy API
[![GitHub version](https://badge.fury.io/gh/Fedihosting-Foundation%2Fplemmy.svg)](https://badge.fury.io/gh/Fedihosting-Foundation%2Fplemmy)
[![PyPI version](https://badge.fury.io/py/plemmy.svg)](https://badge.fury.io/py/plemmy)
[![GitHub license](https://img.shields.io/badge/license-Apache-blue.svg)](https://raw.githubusercontent.com/Fedihosting-Foundation/plemmy/master/LICENSE.txt)Plemmy allows you to interact with any Lemmy instance using Python and the [LemmyHttp API](https://join-lemmy.org/api/classes/LemmyHttp.html).
**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:
```python
from plemmy import LemmyHttp# create object for Lemmy.world, log in
srv = LemmyHttp("https://lemmy.world")
srv.login("", "")
```Access specific communities:
```python
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:
```python
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](https://github.com/Fedihosting-Foundation/plemmy/tree/main/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](https://github.com/tjkessler) with any questions.