Streaming live at 10am (PST)

API - how to order collection items in response

Hi,

I’m making an API call to get a list of items in a collection (I’m using limit and offset in the API call which will be set dynamically depending on the user who is logged in).

It’ll be something like this:

https://api.webflow.com/collections/COLLECTION_ID/items?limit=10&offset=5

This will return me the 5th to 15th items in a collection, however is there a way to select the 5th to 15th items in the collection if I order by a particular field in that collection - for example order by “Published Date” or to order by “Sorting” field? Not sure if this is possible! Any ideas would be great - how is this achieved in the front end when ordering a Collection List in the Designer?

Thanks!
Andrew

Hi @andrewrubio

I can’t advise on the API side, but in the Designer you can order a collection list by choosing ‘limit items’ in the sort/filter and then specifying the range.

You can also look at giving the collection a # number field, and each item you want ordering a number - then in the collection list using ‘sort order’ to read from that field…

Hope that helps

According to the documentation, there are no filtering or sorting paramaters. There is only limit and offset.

http://developers.webflow.com/#get-all-items-for-a-collection

If you add a sort parameter it raises an error stating that the sort parameter must be an array.
It seems there’s an undocumented feature for sorting. I couldn’t make it work so far.

I’m actually looking for a filter feature, but sorting would be a second best that would allow me to traverse my items faster.

Ok, now I got this:

You can use https://api.webflow.com/collections/COLLECTION_ID/items?limit=10&offset=5&sort[0]=MYFIELD&sort[1]=ASC

I know it is probably too late to help you, but it may help someone else.