New photos API

I added a new API endpoint to Micro.blog for getting recent photos for a user. This is something we’ve been wanting for Sunlit, and hopefully it will be useful for other developers as well. It works for any Micro.blog user, even if they are hosting their blog somewhere else. For example, a request to Micro.blog for my username would look like this:

  GET /posts/manton/photos
  Authorization: Bearer ABCDEFG

The response is JSON Feed, and includes the photo thumbnail URL in addition to the HTML for the blog post and full-sized image. Here’s an abridged version of a response:

  {
    "id": "12345",
    "content_html": "Test photo.<p><img src=\"…\">",
    "image": "…",
    "_microblog": {
      "thumbnail_url": "…"
    }
  }

For blogs hosted on Micro.blog, there’s also a feed of all your photos hosted at your own domain. Mine is here:

  • manton.org/photos/index.json

And there’s a special photos-only feed for the Discover section of Micro.blog. Here are a couple of the URLs:

  • micro.blog/feeds/photos.json — good for showing thumbnails in a grid
  • micro.blog/posts/discover/photos — good for showing posts in a timeline

Basing our API on JSON Feed has helped keep Micro.blog open by default. The URLs that don’t require authentication can even be dropped in a reader like Feedbin to use outside of the Micro.blog apps.

We’re working on an updated version of Sunlit that will use this new photos endpoint. Anyone can join the beta on TestFlight here and you’ll be notified when the app is ready to test.

Manton Reece @manton
🕸💍