get the list of all users with confluence api - how to
Asked by mzhydenko:

Hi!

I tried to do smth like confluence/rest/api/user?username=a and username=\* and some other cases but it shows an error

```
No user found with key : null
```

so is the key the must parameter?

and is there a wildcard for any parameter so I could get the list of all users

or any other way I could do it?

any help would be really appreciated


Answers:
author: miikhy
body: Hi!

The documentation mentions that a parameter is required and there is no known wildcard option. That being said, the usual trick I use is to query the confluence-users group members which list all users having access:

/rest/api/group/confluence-users/member

You can also create a group with all users even unlicensed and use the same endpoint.

Feels like a workaround but it's working well!

Hope it helps!

Cheers

comments: author: mzhydenko
body: Hi [@miikhy](/t5/user/viewprofilepage/user-id/449205)

Thanks for your answer. I tried the exact query you sent but It returns admin user only, did I misunderstood you and there are some extra things/steps I need to do?


author: miikhy
body: Hi [@mzhydenko](/t5/user/viewprofilepage/user-id/2380417),

Have you tried adding ?limit=500 to get more results?

Also, the group name in the URL is the group you're browsing, are non-admin users members of this group? Just tried it locally and it worked well :(

Cheers


author: mzhydenko
body: Thank you [@miikhy](/t5/user/viewprofilepage/user-id/449205)!

I\`ll try that and hope it\`ll work for me too.

Have a nice day :)


author: miikhy
body: Great!

Keep us posted!

Cheers


author: Nathaniel Miller
body: This worked for me, thank you so much!

I did want to point out though that *confluence-users* is the default user group that gets some one access, but it could be something else if configured so. for instance, my company uses the group atlassian-users to grant access to Confluence, JIRA, and BitBucket.


author: Shroomy
body: And this is why the accepted answer should not be accepted.

The suggested answer only returns **licensed** users, not all users.

Edit:

In fact it will return both active and disabled users. But only active users will count as licensed users. My point was that you may have users without any groups. They will not be included and there is no other way to get them.


author: Shroomy
body: FYI:

In case anyone might want to spend an extra buck on a plugin/app, I have successfully managed to export all users (also over 1000 users) using the API for Techtime User Management for Jira/Confluence.

Since it allows you to get all users you can also iterate over each user and do whatever you want with it. That is, if you know some programming of course.

<https://marketplace.atlassian.com/apps/1215285/>

<https://techtime.co.nz/display/TECHTIME/User+Management+-+Retrieve+Group+Membership+using+REST+API>


author: Steve Suranie
body: I thought I'd update this with my Python code as it seems the API has changed:   

You will need to have an API token to run this. You will also need to know the group name.   

```
def getGroupMembers(self, strGrpName):

 #group/member?name={name}

 strAuth = "Basic YOUR BASE64ENCODED CREDENTIALS AND TOKEN"

 strURL = (f'https://xxxxxx.atlassian.net/wiki/rest/api/group/member?name={strGrpName}')

 strConfHeaders = {'Authorization': strAuth, 'Content-Type': 'application/json'}

 response = requests.get(strURL, headers=strConfHeaders)

 if response.status_code == 200:

     return {"success":True, "data":response.json()}

 elif response.status_code > 200:

     return {"success":False, "msg":"There was an error with your requests: \n\n" + "Status Code: " + str(response.status_code) + "\nURL: " + strURL}
```

```
?Use:?

dictMemberResults = getGroupMembers(A-GROUP-NAME)
if dictMemberResults["success"] == True:
    lstUsers = dictMemberResults["data"]["results"]
     for thisUser in lstUsers: 
         if thisUser["displayName"] == A-USER-NAME:
              return thisUser
else:
    print(dictMemberResults["msg"])
```

comments: author: Shroomy
body: Cloud or data center?


author: Steve Suranie
body: Cloud.


author: Deep (TechTime Initiative Group)
body: I know I'm a bit late to the party but you future reference. There is one more way to get a list of all users without specifying the limi by making a get request to the following end point:

```
http://localhost:1990/confluence/rest/user-management/1.0/users
```

This will return you all the users. I hope this helps :)

comments: author: F_ GARFAGNI
body: Yes it helps !  
It works file with Jira Server v8.5.  
Thank you for this trick.


author: Deep (TechTime Initiative Group)
body: I will be surprised if the end point worked for Jira as I mentioned, this endpoint is for confluence, having said that I haven't tried it for Jira. Just to reconfirm, it did work for you when you tried it for Jira and not confluence, right?


author: Frank
body: I tried that URL, but got a 401 - Unauthorized response on a server where I am not admin. Probably it is meant - as the name suggests - for user management, and that needs the user to be admin.


author: Deep (TechTime Initiative Group)
body: You can only access the Users page if you are a system admin hence, it will only work if you're the admin of the instance. If you try it with the admin user, it will work. Normal users cannot access the 'Users' page in the first place.


author: Shroomy
body: For data center Confluence this returns a 500 error. There is also no official documentation on this API call.


Tags: addon-org.techtime.confluence.plugins.usermanagement

api

confluence-server

server