1) how to get all the repositories ? 2) How to check exisiting Repositories ? (REST API 2.0)
Asked by Sohit Kumar:

**Please help me sir/mam..,how to achieve these by RESTAPI2.0**   
I have some requirement \>   
1)i have a text field by entering the repository name,i want to know the repository is valid or not.  

2)how to know the repository belongs to which group.

3)how to add user.


Answers:
author: Theodora Boudale
body: Hi [@Sohit Kumar](/t5/user/viewprofilepage/user-id/4527346) and welcome to the community!

**1.** You can get all repositories owned by a certain workspace with the following API endpoint:

* <https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Bworkspace%7D>

It is possible to filter the response to get only the names of the repositories with the *fields* parameter

* <https://developer.atlassian.com/bitbucket/api/2/reference/meta/partial-response>

This is an example API call with curl:

```
curl -u username:app-password https://api.bitbucket.org/2.0/repositories/<workspace-id>?fields=values.name
```

**2.** You mentioned
> how to know the repository belongs to which group.

I am not sure I understand what you are referring to by 'group'. Repositories are owned by workspaces and they belong to a certain project in that workspace. Are you perhaps referring to the project each repo belongs to?

Or do you mean which user groups have access to the repo?

**3.** It is not possible to add users with API 2 yet, but we have temporary support for certain API 1 endpoints.

If you want to ++add a user to a user group++, you can check the following page, section "Issue an invitation to a group", it includes an example:

* <https://support.atlassian.com/bitbucket-cloud/docs/invitations-resource/>

If you want to ++add a user to a certain repository++, you can check the following page, section "POST send an invite" (it also includes an example):

* <https://support.atlassian.com/bitbucket-cloud/docs/invitations-endpoint/>

Kind regards,  
Theodora

comments: author: Sohit Kumar
body: HI, Kind thanks for your briefly response.  

I have more question related to this :-

1. Is there anyway or any api available to check whether the email is Atlassian registered account or not ?
2. suppose I want know that repository is existing or not by just passing the repo name ?
3. And I have followed your references **(repositories)** can you give/explain me with a example/sample alias ?


author: Theodora Boudale
body: Hi [@Sohit Kumar](/t5/user/viewprofilepage/user-id/4527346) ,
> Is there anyway or any api available to check whether the email is Atlassian registered account or not ?

I'm afraid that we don't have such an API endpoint.

If you're an admin of a workspace or repo, you can invite someone using their email address, but we don't have an API endpoint to show if an Atlassian account exists with that email. May I ask why you would need to check that?

> suppose I want know that repository is existing or not by just passing the repo name

If you use <https://api.bitbucket.org/2.0/repositories/>\<workspace-id\>/\<repo-name\>

and the repo does not exist, you will get an error message saying so in the response. Please note though that the same error will show if a repository with that name exists in that workspace and you don't have access to it.

> And I have followed your references (repositories) can you give/explain me with a example/sample alias ?

I'm not sure what example you are looking for, is it for checking whether a repository exists? Or for something else?

Kind regards,  
Theodora


Tags: api

rest-api