Forum Discussion

jaread83's avatar
jaread83
Champion
8 years ago

Online users API call - what order are these results?

Hi all,

I am using the API V1 call for online and registered users on a custom component:

<#assign users = rest("/users/online/registered?page_size=100").users />

I was wondering... how are these results ordered? I can't seem to find any clear indication of the order of the online users here. If the order is not determined... how can I tell the API call to order them in a way that I wanted (like last visit time for example).

10 Replies

  • jaread83's avatar
    jaread83
    Champion
    8 years ago
    Just tried, it works... but I don't want to include anonymous users in the list. Is there a way to only show registered users?
  • jaread83's avatar
    jaread83
    Champion
    8 years ago
    Brilliant, thanks for your help! I will have a play around and see what I can do with this.
  • jaread83's avatar
    jaread83
    Champion
    8 years ago
    restapi/vc/users/online/registered/sort_by/last_visit/order/ascending

    Returns 501 error

    /restapi/vc/users/online/sort_by/last_visit/order/descending

    Returns anonymous users (user_id = -1)

    The top line that includes registered users only works if I don't inlcude the sort order :(

  • VikasB's avatar
    VikasB
    Boss
    8 years ago

    jaread83

     

    http://community.lithium.com/community-name/restapi/vc/users/online/registered
    returns

    User List: A list of the non-duplicate registered users currently online.

    query arguments

     

    Parameter Type Possible Values Description
    users_online.sortby (optional)string specify - or + in the beginning for descending or ascending respectively. The only available sort fields are last_visit or login. last_visit will default to descending and login will default to ascending
  • VikasB's avatar
    VikasB
    Boss
    8 years ago

    jaread83

    Here is the exact call you are finding

    /restapi/vc/users/online/registered?users_online.sortby=-last_visit
    /restapi/vc/users/online/registered?users_online.sortby=+last_visit
  • jaread83's avatar
    jaread83
    Champion
    8 years ago

    Ah that is exactly what I was looking for. I think it was the inclusion of - and + in the call that was throwing me off a bit. Thanks for your help with this, I am veru grateful for this! My users will be most pleased.