Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/db0/pythorhead
A python library for interacting with Lemmy
https://github.com/db0/pythorhead
Last synced: 9 days ago
JSON representation
A python library for interacting with Lemmy
- Host: GitHub
- URL: https://github.com/db0/pythorhead
- Owner: db0
- License: agpl-3.0
- Created: 2023-06-14T16:21:27.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-10-22T07:25:22.000Z (about 2 months ago)
- Last Synced: 2024-10-23T04:01:20.069Z (about 2 months ago)
- Language: Python
- Size: 546 KB
- Stars: 76
- Watchers: 4
- Forks: 25
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
- awesome-lemmy - pythorhead - activity/y/db0/pythorhead) (Projects / Libraries)
README
# Pythörhead
A python library for interacting with Lemmy
![pythorhead logo](https://raw.githubusercontent.com/db0/pythorhead/main/logo.png)
# Examples
See working examples in [examples/](https://github.com/db0/pythorhead/tree/main/examples)
# Exceptions
If you want to raise exceptions on failures instead of returning null, pass `raise_exceptions=True` to the `Lemmy()` constructor.
The normal request timeout is 3 seconds. If you want to change this number, you can set it on the constructor uising `request_timeout=`
## Sample Post Usage
```python
from pythorhead import Lemmylemmy = Lemmy("https://lemmy.dbzer0.com",request_timeout=2)
lemmy.log_in("username", "password")
community_id = lemmy.discover_community("botart")
lemmy.post.create(community_id, "Hello Lemmy World")
```## Sample Comment Usage
```python
from pythorhead import Lemmylemmy = Lemmy("https://lemmy.dbzer0.com")
lemmy.log_in("username", "password")# getting the first post id
post_id = lemmy.post.list()[0]["post"]["id"]# leave a comment
lemmy.comment.create(post_id, "Hello Lemmy World")```