API v2 Events - AccessLevel and Sorting
I'm using the API v2 to extract Events for a custom event list in another site. So far, the API is working.
I can get a list of event objects, but they seem to be in the order in which they were entered, not in the order of their dates! (date order should be the default sort, IMHO) Is there a way I can specify the sort order in the request URL?
Also, the API returns ALL events regardless of access level: is there a way to restrict the returned set to be just public events?
Sorting events via API have been published in 5.9 release.
AccessLevel filtering is not in our near plans, sorry. But user’s support can change this situation. So we are changing status of this idea back to “Collecting comments”.
Michael Lin (WA Admin) commented
I agree. the current sort order is useless. adding an order by on the api side is so easy. Most people want the upcoming events first. that i think should be the default sort for the api. that's what you show on the UI also.
Ken N commented
Thanks for the reply. Of course, it's all possible on the client side, as you say. So that's what I'm doing tonight.
But - it's easy enough to sort on the API-side, and 9 out of 10 users would want the list in forward chronological order... why wouldn't you do that, if you're not going to make 'sort' a param? The current sort (by order of event entry) is of no use to anyone.
Likewise, it's easy enough to have access restrictions as a param, and it's arguably a security hole if the API defaults to "show everything", so the safest default would be public...
There is no way to set sorting order for any API response, and there are no garantee of default sorting order. If you need to display events in some order, then it's better to sort them on client side. Most programing languages provide tools for it.
Filtering events by access level is also not supported, you can use "AccessLevel" field to filter events on client side.