Is there an Endpoint for reading Group Members?

Hello! I was wondering if there was any way to get a list of the Users in a group, I can get the list of all Users using “/users” Overview

But how would I go about filtering this to a specific group ID? Is there an endpoint available for this operation?

Yes, there is. When you make requests to many of the AC APIs, you may notice a links object. The links object includes additional endpoints you can explore for more details. When you request /api/3/groups or /api/3/groups/{id}, you should see in the links something that looks like /api/3/groups/{id}/userGroups. api/3/groups/{id}/userGroups is the endpoint that will list the Users in that Group.

I hope this helps!

2 Likes

Thanks!

Indeed, that is the endpoint I needed! I think this endpoint has no pagination, correct? I tried passing limit=1 to the query to test it, but it didn’t change the behaviour of the end point.

Documentation says that Endpoints that return collections of resources must limit the number of records returned in a given response , and of collections, it says that are represented by a top level member named after the resource in the plural form. The response of the API makes me think thatuserGroups` is a collection

{"userGroups":[
  {
  "userid":"1",
  "groupid":"3",
  "cdate":null,
  "udate":null,
  "links":{"group":"https:\/\/camilovietnam.api-us1.com\/api\/3\/userGroups\/1\/group",
  "user":"https:\/\/camilovietnam.api-us1.com\/api\/3\/userGroups\/1\/user"},
  "id":"1",
  "group":"3",
  "user":"1"
   },
  {
  "userid":"2",
  "groupid":"3",
  "cdate":"2021-10-04T03:59:04-05:00",
  "udate":"2021-10-04T03:59:04-05:00",
  "links":{"group":"https:\/\/camilovietnam.api-us1.com\/api\/3\/userGroups\/2\/group","user":"https:\/\/camilovietnam.api-us1.com\/api\/3\/userGroups\/2\/user"},
  "id":"2",
  "group":"3",
  "user":"2"
  }
]}

I am writing some API integrations and I wanted to make sure that I didn’t miss any results, but it seems this endpoint doesn’t have any pagination feature.

Again, thanks a lot! This was the endpoint I was looking for :smiley: (star wars reference )

That’s correct. Some of the secondary endpoints do not have paged results.

May the API be with you :wink:

1 Like