I've looked at the Bitbucket API docs and this post BitBucket get list of all contributors. The second link asks about users belonging to a repo, but in my case I just want a list of ALL licensed users. Is there really NO way to do this or did I miss it in the docs?
-
Are you asking about Bitbucket Server? Both links you've provided are for Bitbucket Cloud (bitbucket.org), which has a different API structure. – Jim Redmond Apr 02 '18 at 18:53
-
Sorry yes, Bitbucket server – Chris F Apr 02 '18 at 19:11
3 Answers
Execute something like this:
curl -s --user USER:PASS --request GET https://BITBUCKET-SERVER/rest/api/1.0/admin/users?limit=1000 | jq --raw-output '.values[] | .name + " => " + .displayName'
And you'll get the "username => name" list of users.

- 19,950
- 3
- 39
- 50
-
Thanks, I tried this and get "parse error: Invalid numeric literal at line 1, column 10". I do have jq installed – Chris F Apr 02 '18 at 19:46
-
Uhm... to check if it's a concatenation issue, run only this: curl -s --user USER:PASS --request GET https://BITBUCKET-SERVER/rest/api/1.0/admin/users?limit=1000 | jq --raw-output '.values[] | .name' – Marcelo Ávila de Oliveira Apr 02 '18 at 19:52
-
Forgot the api version. So this works: curl -s --user USER:PASS --request GET BITBUCKET-SERVER/rest/api/1.0/admin/users?limit=1000 | jq --raw-output '.values[] | .name' – Chris F Apr 02 '18 at 20:07
Just for anyone else looking for this: The currently accepted answer provides a way to list all users, but this will include unlicensed users, i.e. user records that are not currently consuming a seat.
If you want to get a list of all licensed users, follow the steps described in How do I find which users count against my Bitbucket Server license? to install an add-on which will give you exactly this.

- 4,775
- 28
- 40
Here is some python code that did the trick for me. I had many users (10k+) but <1000 users with permissions. I also have basic authentication (username/passoword) enabled for my bitbucket server. By querying both "users" and "permissions" and merging the results using pandas, I got a pretty good result.
import pandas as pd
import numpy as np
import json
import requests
import datetime
import urllib3
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
bitbucket_url = "https://my-bitbucket-server"
users_url = bitbucket_url + "/rest/api/1.0/admin/users?limit=1000&start="
permissions_url = bitbucket_url + "/rest/api/1.0/admin/permissions/users?limit=1000&start="
out_filename = r"C:\mypath\authenticatedUsers.csv"
username = "myusername"
password = "mypassword"
def get_responses(url,username,password):
json_responses = []
with requests.Session() as s:
s.auth = (username,password)
start = 0
while(True):
response = s.get(url + str(start),verify=False)
json_response = json.loads(response.text)
if "values" not in json_response:
print("Error:" + response.text)
json_responses += json_response["values"]
if(len(json_response["values"]) < 1000):
break
start += 1000
return json_responses
users = pd.DataFrame(get_responses(users_url,username=username,password=password))
users["DaysSinceAuth"] = np.floor((datetime.datetime.now().timestamp() - users.lastAuthenticationTimestamp/1000)/3600/24)
permissions = get_responses(permissions_url,username=username,password=password)
permissions = pd.DataFrame([{"id":p["user"]["id"],"permission":p["permission"]} for p in permissions])
usersmerged = users.merge(permissions,how="inner",on="id")
usersmerged.to_csv(out_filename)

- 4,519
- 3
- 23
- 18