Using API to get recent items

Hello, feels like a dumb question but how do I return the most recent items with GET? If I call mysite.edu/api/items the results are in ascending order. I want descending. Thanks!

It's not a dumb question, but unfortunately the answer is that right now you can't change the sorting of the API results.

We're looking into enabling this for version 2.3, though, so stay tuned.

Thanks!
I guess I can run ?page=x&per_page=50 until it returns null and then grab the last non-null results for now.

You should also be getting back an Omeka-Total-Results header so you could do some "last page" math up front without stepping through every page.

Perfect! get_headers($url) and presto. Thanks!

The next release of Omeka will allow you to specify sort_field and sort_dir parameters for "browse" GET requests.

In case this is useful to anyone else in the interim, this is what I'm doing to grab the most recent items:

$url = 'http://mydomain.edu/api/items';
$headerArray = get_headers($url, 1);
$howMany = ceil($headerArray['Omeka-Total-Results'] / 50);
$json_string = "http://mydomain.edu/api/items?page=" . $howMany;
$jsondata = file_get_contents($json_string);