Forum Discussion

Coline's avatar
Coline
Contributor
10 years ago

API call for badges

Hello,

Is there an API call we can use in order to create a board for badges?

(the last ones that have been earned for exemple)

 

Thanks!

  • PaoloT's avatar
    PaoloT
    Lithium Alumni (Retired)

    Hi Coline 

     

    you can definitely look up a user's badges using this call - there are several parameters that can be passed to sort them in the desired order as well.

     

    Thanks,

  • OlivierS's avatar
    OlivierS
    Lithium Alumni (Retired)

    Coline 

     

    I don't think such call exist.

     

    What you could try to do is to call the User Resource with our API v2, filtering by the last_visit time. And then check if the users returned have earned a badge during the same period of time (user/bageds/item/earned_date).

     

     

     

     

    • OlivierS's avatar
      OlivierS
      Lithium Alumni (Retired)

      Coline 

       

      A better approach would be to go through your existing badge list with our API call.

      And use the following optional parameter (badges.sort_orderto get the latest ones awarded (awarded_desc):

       

      badges.sort_order (optional) badges_sort_order   The order to sort the badges returned. Possible values are" creation_time_desc, creation_time_asc, activation_time_desc, activation_time_asc, position_desc, position_asc, title_asc, title_desc, awarded_asc, awarded_desc, qualified_asc, qualified_desc
      • dechra's avatar
        dechra
        Ace

        Using LiQL to fiddle around with a Badging leaderboard.

         

        Any chance we can get this to work with Badges?

         

        select user_badges.count(*) FROM users WHERE id = '2024'

         

        I'm seeing this returned when I try:

         

        "developer_message" : "Field 'user_badges.count(*)' does not exist for object 'users'.

         

         

        Thanks!