A couple of questions about the recent uploads API

I’m trying to utilize this API for recent uploads:
https://micro.blog/micropub/media?q=source

And had these questions:

  • Does it paginate or does it simply send the last N uploads?
  • If there’s no pagination, what’s the max value of N?
  • Does it return uploads from all the blogs or is there a way to limit the query to one blog or a subset?

Thanks,
Sam

A couple of observations in practice:

  • The response is sending 100 items.
  • The items are from the last selected blog in the web interface. i.e. If I go into the web interface and switch from my main blog to a test blog, the entire response switches to show me uploads from the test blog after the next call.

Note that the calls are being made to the same account but from other clients, not from the browser. This was surprising.

You’ll want mp-destination. From Posting API:

For users who have multiple microblogs configured, /micropub?q=config will return of the list of sites. You can post to a specific microblog by passing an mp-destination parameter of the URL ( uid from the configured list).

So, that might look something like this in your case: https://micro.blog/micropub/media?q=source&mp-destination=https%3A%2F%2Fsamgrover.micro.blog%2F.

1 Like

Yep, use mp-destination to select a specific blog. For pagination, it also accepts limit and offset parameters. Doesn’t look like we documented this. So, if you want to page through 100 items at a time, the 2nd request can be like offset=100&limit=100, 3rd request offset=300, and so on. You can ask for more than 100 at a time, but I’d probably stick to 100-200 items to keep each request fast.

2 Likes

Thanks guys!

If a destination isn’t specified, can it simply send all recent uploads from all blogs, up to the limit? That seems like how it should behave but it isn’t what I see.

That would also prevent making several calls and combining results together.

1 Like

No, everything via the Micropub API is for an individual blog, and I think it would break things if we changed to including all posts. In the official apps, we always show the hostname for the selected blog, and the user can click on it to pick a different blog to refresh the list. If your UI wouldn’t work for something like that, you’ll need to make multiple calls and merge the results. Sorry!

Got it. Thanks Manton!