Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jointakahe/taktivitypub
A Python library for parsing and creating ActivityPub messages
https://github.com/jointakahe/taktivitypub
Last synced: about 1 month ago
JSON representation
A Python library for parsing and creating ActivityPub messages
- Host: GitHub
- URL: https://github.com/jointakahe/taktivitypub
- Owner: jointakahe
- Created: 2023-11-12T20:06:12.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-03-13T15:55:24.000Z (9 months ago)
- Last Synced: 2024-08-04T01:26:34.195Z (4 months ago)
- Language: Python
- Size: 43 KB
- Stars: 20
- Watchers: 2
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# taktivitypub
*Note: This is still under early development and is not fully usable yet!*
This is an ActivityPub (and ActivityStreams) object parsing and
generation library, designed to make it easier to both accept the wide
variety of ActivityPub object messages and to make it easier to create messages
accepted by other servers.To parse objects, hand the Python dict you got from the JSON to `APObject.load`:
```
from taktivitypub import APObjectmy_note_data = {"type": "Note", "id": "https://...", ...}
note = APObject.load(my_note_data)
# Now we can use the object fields as normal Python objects
print(note.published.strptime("%Y-%m-%d"))
```It will return the appopriate `APObject` subclass for the type of object you passed - so if you have an object of type `Note`, you will get a `taktivitypub.Note` class back.
To create messages, construct the objects and then call `dump`:
```
note = Note(
id="https://example.com/1",
content="Hi",
attributed_to="https://example.com/andrew",
)
json = note.dump()
```