Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,456,899
Community Members
 
Community Events
176
Community Groups

Is there any APIs to pull all the repositories from a particular Organisation


Is there any APIs to pull all the repositories from a particular Organisation?( using one param like workspaceID, projectkey etc  )

1.{{const

{ data, headers } = await bitbucket.teams.listRepositories({ workspace, page, pagelen, q, sort, fields })}}


2. {{const { data, headers }

= await bitbucket.teams.listRepositoriesForUser(

{ workspace, page, pagelen, q, sort, fields }

)}}

3.

{{const

{ data, headers } = await bitbucket.users.listRepositories({ workspace, page, pagelen, q, sort, fields })}}
 
4.{{const { data, headers }

= await bitbucket.users.listRepositoriesForTeam(

{ workspace, page, pagelen, q, sort, fields }

)


I tried these 4 Apis in postman, but these all are deprecated 

1 answer

1 accepted

0 votes
Answer accepted

Hello Amiya,

 

So, let me try to help you with your issue.

You are totally right, all of those API's that you have listed are now deprecated. Actually, if you see the API description, in our Atlassian Developer's portal, you should see the following information: "This endpoint has been removed. You should use the workspace endpoint instead. For more information, see this post."

Also, as you may know, Bitbucket use Teams similar to GitHub's organizations. But, teams resource has been deprecated, and the workspaces endpoint should be used instead.

Try to take a look at the documentation provided above. And, as a plus information, I would recommend you to use/try the "Atlassian REST API Browser" from the marketplace (Atlassian REST Api Browser) as you can see all the APIs and also make requests directly from that browser to test your results.

 

Hope that it helps!! And that you have a great week ahead!

Please, do not hesitate on contacting us again in case you need any additional information!

Kindly Regards,

Guilherme Franchi

Atlassian Support Engineer

Hi Guilherme Franchi,

I have also looked into the workspace endpoint but could not find any api that can be used to pull all the repos. 
All the Apis that are mentioned to do so are deprecated.

If you find any API that can be used to pull all the repos of a team/organisation/project kindly provide me any that.


Thanks for the response
Amiya 

Hi @Amiya Kumar Sahoo 

 

Thanks for replying me back.

Actually, there is not a single API capable of doing so. What you will need to do is to work with a series of APIs, based on the application that you working with, to be able/capable of doing that.

I will use an example here, where we can set an OAuth2 authentication, using curl, and getting all the repository from my workspace. (For mor information about OAuth2 you can check the following page: OAuth2).

The first thing that you need to do is to create a consumer:

Creating a consumer

OAuth needs a key and secret, together these are know as an OAuth consumer. You can create a consumer on any existing workspace. To create a consumer, do the following:

  1. From your profile avatar in the bottom left, click on the workspace in the Recent workspaces list or click All workspaces to open an entire list from which to choose.

  2. Click Settings on the left sidebar to open the Workspace settings.

  3. Click OAuth consumers under Apps and features on the left navigation.

  4. Click the Add consumer button.  

    The system requests the following information:

    Field

    Description

    NameThe display name for your consumer. This must be unique within your account. This is required.DescriptionAn optional description of what your consumer does.Callback URL

    Required for OAuth 2.0 consumers.

    When making requests you can include a call back URL in the request:

    • If you do include the URL in a request it must be appended to the same URL configured in the consumer. So if your consumer callback URL is example.com/add-on the URL in your request must be something similar to example.com/add-on/function.

    • If you don't include the URL in the request we redirect to the callback URL in the consumer.

    URLAn optional URL where the curious can go to learn more about your cool application.

  5. Click Save
    The system generates a key and a secret for you.

  6. Toggle the consumer name to see the generated Key and Secret value for your consumer.

 

Once you have that setup, you can request a token, using that Key and Secret value from your consumer:


# Making a request of an OAuth2 token, using a private client_credentials
curl -X POST https://bitbucket.org/site/oauth2/access_token -d grant_type=client_credentials -u "CONSUMER_KEY:CONSUMER_SECRET"

The above POST curl call will return you with access_token that you will need to save to be able to make the next request.

Now, what I want to do is to get all the names of the repositories that I have in my name, based on my workspace:

# Show all the full name repositories that I have under my name,
# and format it out using jq
curl --request GET \
--url 'https://api.bitbucket.org/2.0/repositories/MY_WORKSPACE_USERID' \
--header 'Authorization: Bearer USE_THE_TOKEN_PROVIDED' \
--header 'Accept: application/json' | jq -r '.values[] | .full_name'

And the above GET request will return me all the names/repositories that I have under my name/workspace:

#Results:
MY_WORKSPACE_USERID/bitbucketstationlocations
MY_WORKSPACE_USERID/icecreamcontroller
MY_WORKSPACE_USERID/jetturbineavionics

With the above results, you can create a script or even an application to read it and make the pull/clone that you are looking for.

You can also check the following pages:

 

Hope that it helps!

 

Regards,

Guilherme Franchi

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events