Skip to content

A Python library for parsing and creating ActivityPub messages

Notifications You must be signed in to change notification settings

jointakahe/taktivitypub

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 APObject

my_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()

About

A Python library for parsing and creating ActivityPub messages

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages