I am looking for the REST API for Bitbucket to show the number of repositories. I spent a while researching, but still am at a loss.
https://developer.atlassian.com/bitbucket/api/2/reference/resource/users
https://developer.atlassian.com/bitbucket/api/2/reference/meta/filtering#supp-endpoints
I also found this:
https://docs.atlassian.com/bitbucket-server/rest/6.6.1/bitbucket-rest.html
If I input this:
https://api.bitbucket.org/2.0/repositories
It provides information for a user and repository named "tweakmsg", so I suppose it is a stock response?
When I try finding the repositories for my user on my Atlassian bitbucket account, it gives an error:
https://api.bitbucket.org/2.0/repositories/users/{my user id}
{"type": "error", "error": {"message": "Repository users/{543f3bdf-9cc8-481b-8468-9021a69824d4} not found"}}
Hi @[deleted]
From the answer by Blizzard in this, using
https://api.bitbucket.org/2.0/repositories?role=member
gives me all the repositories that I'm a member of.
Hope this helps
Thanks!
Good news is I made progress and the first link is the weblink that is useful as a reference for my purposes: https://developer.atlassian.com/bitbucket/api/2/reference/resource/
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
1. Using my own user account as a test and trying to access repos:
https://api.bitbucket.org/2.0/repositories?role=member
The result is empty! I tried all the options (from contributor, owner, admin) Even tho I am listed as an owner to one repository.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
2. I was able to access initial information using the team UUID.
Then am trying to use the teams/<uuid>/repositories, but based on the documentation it only returns empty:
{“pagelen”: 10, “values”: [], “page”: 1, “size”: 0}
I supposedly have admin access to this team.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @[deleted]
How are you calling the API? cURL? Postman? Java? C#? Other?
You need to be authenticating with your Bitbucket username and an API token associated with that username - are you doing this? It may be useful to show the full call that you're sending off, with the token anonymised.
If you don't pass in authorisation, or the authorisation fails, then it will return all the public repositories, of which tweakmsg is the first one.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Thanks for the reply!
1.
Using API (Browser - Chrome). I have also used curl in the past.
I have noticed that when I go to:
https://api.bitbucket.org/2.0/users/<uuid>/members
to check my access:
{"type": "error", "error": {"message": "Forbidden"}}
This is the output.
2. https://api.bitbucket.org/2.0/teams/<team uuid>/permissions/repositories
Shows a login prompt. I enter my username and pw. I cannot log in with my account (loops to ask for login again). Once again, I supposedly have admin access to the team, but also, it seems I am unable to log in to view this.
Does there need to be a separate permission granted for users to use api.bitbucket.org?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ok, I'll authenticate using curl, and let you know! :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi, I have access to a token which is 32 characters long. Is the same length as an expected API token to curl? Thanks!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
After trying a few things, creating the App Password works for me. https://confluence.atlassian.com/bitbucket/app-passwords-828781300.html?_ga=2.120538568.1500375385.1568137015-2069897606.1563555800
Thanks, I was able to successfully find:
https://api.bitbucket.org/2.0/teams/<team uuid>/permissions/repositories
I tried looking at the repositories to get the repo count:
https://api.bitbucket.org/2.0/teams/<team uuid>/repositories
{"pagelen": 10, "values": [], "page": 1, "size": 0}
which shouldn't be the case. Appreciate your help!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
https://developer.atlassian.com/bitbucket/api/2/reference/resource/teams/%7Busername%7D/repositories <-- Even after reading this, I would assume we can view the repositories. But the default value is an 'error' even in the documentation. Can someone please confirm that this endpoint is in use? Thanks!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ok, I found the answer. Both the project and repository need to be set to public in order to view the https://developer.atlassian.com/bitbucket/api/2/reference/resource/teams/%7Busername%7D/repositories.
This API also redirects to https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Busername%7D.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
^ The above means that `All repositories owned by a user/team. This includes private repositories, but filtered down to the ones that the calling user has access to.` is deprecated...
Any help with viewing repositories without having to make access public?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Warren Hi! Wondering if I can view repositories without making access public. Since it looks like private repositories cannot be viewed as shown the deprecated link above. I am looking for a way to count the number of repositories and can filter the repo based on number of links. Thanks!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @[deleted]
I was struggling to follow all the info that you've given here, but I can say that all our repositories are Private and I can view them via the API, so you don't need to make them all public to see them. The user whose details are used for the API call will need access rights to view those repositories.
You may want to post your question on the Developer Community site as well, to increase your chances of getting help
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Warren,
Thank you for the reply. Unfortunately, even though I am in the administrator group, I cannot see the projects nor repositories.
Can you paste to me the API that you are using to be able to see the repositories? I tried using users which have admin access and also the team uuid.
It would be ideal to be able to view the API without having to use additional credentials
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @[deleted]
Reading back what you've written, I think the issue may be that you are using the browser, which isn't allowing you to authenticate. I would recommend that you try doing this via Postman (either online or download the free app) to know that your authentication is working. You can see from the screenshot below that I'm using Basic Auth and my username and API token to successfully get data returned.
Once you get to this point using Postman and know that it is working, you can then try some other route.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks so much!! I'll try that! :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ok, I've been able to get my results using Postman. :) I was able to authenticate using the browser as well. This is for my own user.
When I use the team uuid, I cannot view the repos. Any help with this, as this is my main goal :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Warren
Definitely the following link works for others, but not for me:
They are using:
https://api.bitbucket.org/2.0/repositories/{TeamName}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
After some digging,
https://developer.atlassian.com/cloud/bitbucket/bitbucket-cloud-rest-api-scopes/?utm_source=%2Fbitbucket%2Fconcepts%2Fbitbucket-rest-scopes.html&utm_medium=302
perhaps I need the repository `scope`. Will try this
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Warren Thank you so much!
It worked!! Using postman, and adding the parameter: `scopes=repository` worked, as that was missing in the API call!!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @[deleted]
I'm glad that you're finally able to get the results that you need. I have never used scopes=repository so I guess that mine were correctly set by default.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you so much for all your help, Warren! Yes, I think you had the settings by default.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.