Getting started with building on the fediverse can be a big chore, there’s a lot to learn and handle. Pana is a new library in Go to help simplify things. It provides the buildiing blocks for handling ActivityStreams messages, the message format used between servers to exchanges actvivities and enable federation.
A picture is worth more than a thousand worth, and good examples are worth more than me trying to convince you with words or pictures. Take a look at the examples in pana’s documentation and see if that’s something you can work with.
Pana handles activity messages, but it doesn’t implement the various HTTP endpoints from the ActivityPub specification for you. That’s much harder to do generically and integrate nicely with everyone’s preferred frameworks, data stores etc. So there’s still some work for you to do.
What I’m hoping is that pana will lower the barrier to start developing on the fediverse a lot, so we start to see more small and personal projects built on the fediverse. Don’t worry about engagement or going hyperscale. Build for yourself and your own fun! Please fuck around and find out.
Secret sauce
At the core of pana sits longdistance, another new library I wrote. Longdistance implements a spec compliant JSON-LD 1.0 and 1.1 processor. Pana wraps this library to provide an API that is designed for building social media applications on the fediverse.
Longdistance passes the W3C JSON-LD test suite, so even though it’s new I have a high degree of confidence in its correctness. The implementation could use some cleaning up, as it’s a straight port of the algorithms as described in the specification. But now that it passes the test suite that can safely happen.
Though building longdistance took months, the initial version of pana was put together in a matter of days. Once the underlying library was sorted, everything became easy.
ForgeFed and more
Though ActivityPub and ActivityStreams are usually thought of as a microblogging protocol and platform, it can do far more than that. If you’re interested in building a ForgeFed library in Go for example, don’t try to shoehorn this into pana. Start with longdistance and take a look at how pana wraps it.
You can use the vocabgen
CLI in longdistance to generate a package like the ones in pana’s vocab
subpackages. After that you’ll need to create the types and you should be off to the races. If you need any help, feel free to open up an issue on longdistance’s repo.
Acknowledgements
Building longdistance took months. It was a slow decent into spec madness, obtuse bugs and diving deeper into Linked Data and RDF than I wanted. I nearly gave up, thrice. It took a week to chase down a couple of bugs, complete with debuggers, spec printouts and state written on stickies. My desk looked like a murderboard.
I want to extend a sincere thank you to the dotNetRDF developers. They’re another JSON-LD 1.1 implementation out there that’s fully annotated with chapter and step markers from the final recommendation (and not earlier drafts.) This helped tremendously in resolving bugs. And I was able to contribute a little back by finding a few issues.
Another thank you goes out to Zotan, one of the Iceshrimp.NET developers and the reason I found dotNetRDF in the first place. She acted as a wonderful rubber ducky, and I deeply appreciate how willing she was to talk to me about issues I was having and provide me with pointers and ideas to resolve them. It was nice to have someone to commiserate with.
Finally, of course, my fellow GoToSocial deveploers. They have endured my grumbling about JSON-LD and spec issues for the past few months. A cheeky extra thank you goes ouut to Tobi who provided some early feedback on pana’s API.
Try it out
Pana and longdistance are both new, so I could use your help kicking their tyres, receiving feedback and improving them.
Pana has a whole bunch of ActivityStreams types implemented. Activity, Actor, Object, Note and Question are considered complete and should be correct. Supporting types like Emoji, Hashtag, Mention and Document (for attachments) should also all work. Other things like Article, Place, Event etc. still need doing.
Try it out and let me know how it goes!