using pixelfed's api for site photos18.06.2023
Motivation: I wanted a way to display my photos somewhere.
I use Instagram, but apparently their API is quite protected, and I didn’t want to have to jump through hoops for something as simple as this.
That’s when I had the idea to try PixelFed.
PixelFed is a decentralized photo-sharing platform - basically Instagram, but exists on multiple independently-run servers. If you’ve heard of Mastodon - Pixelfed is its photo-sharing cousin.
I had been aware of PixelFed prior to this (thanks to #selfhosted), but never had a real reason to use it. After all, no one I know uses PixelFed - and that’s the whole point of photo sharing, isn’t it? Unless - the goal is to have my photos hosted somewhere that are easily accessible to me (and only me).
After some Googling, I discovered PixelFed
Atoms, which are basically just a newer form of RSS. A PixelFed Atom feed provides a list of user posts. I could (presumably) parse the RSS feed and extract image sources from there. However, items only appeared for public photos with descriptions. I didn’t want my (possibly) personal photos appearing on the PixelFed explore page, so the Atom route wasn’t quite viable.
I eventually found myself at the PixelFed API page. The documentation is… sparse. It said something to the effect of “our API is based on Mastodon”, but that’s not particularly helpful. Playing around with PixelFed a bit and looking at the network requests in the browser, I realized what they mean: photos are
statuses (I suppose that’s what Mastodon tweets are). Semantically, I’m not sure if that makes sense to me - but it was good enough to start making some requests. I got a personal access token from the profile settings page > applications, and sent a Postman request:
curl --location --request GET 'https://pixelfed.social/api/v1/accounts/<YOUR-PROFILE-ID>/statuses' \
--header 'Authorization: Bearer <YOUR-BEARER-TOKEN>'
And I can get a list of photos to map through for my website.
FYI: the API will return all photos, even private ones!
If you got all the way here, here’s a photo of my Bichon:
2023-07-23 update: this is so dumb and extra