# Does this api return private projects as well ?, GET api/components/search\_project

**URL:** <https://community.sonarsource.com/t/does-this-api-return-private-projects-as-well-get-api-components-search-project/121043>\
**Category:** SonarQube Server / Community Build\
**Tags:** sonarqube, sonarqube-cloud, coverage\
**Created:** [August 21, 2024, 10:07am UTC](https://community.sonarsource.com/t/does-this-api-return-private-projects-as-well-get-api-components-search-project/121043 "2024-08-21T10:07:05Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Piyush](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/piyush/32/45758_2.png) [@Piyush](https://community.sonarsource.com/u/Piyush)\
**Post date:** [August 21, 2024, 10:07am UTC](https://community.sonarsource.com/t/does-this-api-return-private-projects-as-well-get-api-components-search-project/121043/1 "2024-08-21T10:07:05Z")

</div>

### GET api/components/search\_project

I have 3 questions

Q) does this api return private projects as well with public projects ?  
Here, i am using the token, and i just want to fetch my org. public + private projects  
Q) does this api (or all documented api) work same on all cloud based & self managed plans ?  
Q) currently, i am using cloud based free plan: so my base url for all api is “[https://sonarcloud.io](https://sonarcloud.io)”  
ex: [https://sonarcloud.io/api/components/search\_project](https://sonarcloud.io/api/components/search_project)  
so will this base url will be same in all the all cloud based & self managed plans or will they be different in some planes or self managed plans ?

I am referring to these 2 documents

> **[SonarQube](https://next.sonarqube.com/sonarqube/web_api/api/components/search_projects?internal=true)**

> **[SonarQube](https://next.sonarqube.com/sonarqube/web_api_v2)**

---

<div class="post-metadata">

**Author:** ![acalero](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/acalero/32/70247_2.png) [@acalero](https://community.sonarsource.com/u/acalero)\
**Post date:** [August 21, 2024, 10:19am UTC](https://community.sonarsource.com/t/does-this-api-return-private-projects-as-well-get-api-components-search-project/121043/2 "2024-08-21T10:19:04Z")

</div>

Hi Piyush!

Welcome to the community!

> Q) does this api return private projects as well with public projects ?

It will return both, but only those projects where the user token has browse permissions.

> Q) does this api (or all documented api) work same on all cloud based & self managed plans ?

No. Requests to SonarCloud API sometimes add new parameters for the organization key.

> so will this base url will be same in all the all cloud based & self managed plans or will they be different in some planes or self managed plans ?

No, on Cloud based plans the base url will be “[https://sonarcloud.io](https://sonarcloud.io)” meanwhile on self managed plans it will be “[https://yoursonardomain](https://yoursonardomain)”. On both cases the endpoint will be the same, just add it to the base URL:

1. [https://sonarcloud.io/api/components/search\_projects](https://sonarcloud.io/api/components/search_projects)
2. [https://yoursonardomain/api/components/search\_projects](https://yoursonardomain/api/components/search_projects)

Thanks and best regards.

---

<div class="post-metadata">

**Author:** ![Piyush](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/piyush/32/45758_2.png) [@Piyush](https://community.sonarsource.com/u/Piyush)\
**Post date:** [August 21, 2024, 10:28am UTC](https://community.sonarsource.com/t/does-this-api-return-private-projects-as-well-get-api-components-search-project/121043/3 "2024-08-21T10:28:12Z")

</div>

> [@acalero](#):
>
> It will return both, but only those projects where the user token has browse permissions.

Thanks Antonio

**RE: It will return both, but only those projects where the user token has browse permissions.**

How & where can i check that my token is allowed to fetched these projects or not, I am a admin, and the token i created with admin account, so won’t i get the all public + private projects fetch permission by-default ?

**RE: No. Requests to SonarCloud API sometimes add new parameters for the organization key.**

I assume, that the all api payload will be same, and on response there will only be some fields addition not deletion, am i correct ?  
mainly i am using these below apis  
/api/components/search\_projects  
/api/measures/search\_history

---

<div class="post-metadata">

**Author:** ![acalero](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/acalero/32/70247_2.png) [@acalero](https://community.sonarsource.com/u/acalero)\
**Post date:** [August 21, 2024, 10:56am UTC](https://community.sonarsource.com/t/does-this-api-return-private-projects-as-well-get-api-components-search-project/121043/4 "2024-08-21T10:56:11Z")

</div>

> How & where can i check that my token is allowed to fetched these projects or not, I am a admin, and the token i created with admin account, so won’t i get the all public + private projects fetch permission by-default ?

Even if you are admin you might not have “browse” permission on all projects.

> I assume, that the all api payload will be same, and on response there will only be some fields addition not deletion, am i correct ?

As far as I know the request will be different and it will fail (not in all endpoints) if you don’t provide the organization key param for SonarCloud, and it will fail (not in all endpoints) if you provide the organization parameter for SonarQube. You must check the base url to build the request with the right parameters.

Responses will be more or less the same, maybe with additional fields for organization when requesting to SonarCloud.

---

<div class="post-metadata">

**Author:** ![Piyush](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/piyush/32/45758_2.png) [@Piyush](https://community.sonarsource.com/u/Piyush)\
**Post date:** [August 21, 2024, 11:55am UTC](https://community.sonarsource.com/t/does-this-api-return-private-projects-as-well-get-api-components-search-project/121043/5 "2024-08-21T11:55:11Z")

</div>

> [@acalero](#):
>
> Even if you are admin you might not have “browse” permission on all projects.

Thanks Antonio Calero

**RE: Even if you are admin you might not have “browse” permission on all projects.**

Do we have any option in dashboard, where i can enable browse for all the organization projects ?

---

<div class="post-metadata">

**Author:** ![acalero](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/acalero/32/70247_2.png) [@acalero](https://community.sonarsource.com/u/acalero)\
**Post date:** [August 21, 2024, 12:32pm UTC](https://community.sonarsource.com/t/does-this-api-return-private-projects-as-well-get-api-components-search-project/121043/6 "2024-08-21T12:32:20Z")

</div>

> **[Permissions templates & SonarCloud](https://docs.sonarsource.com/sonarcloud/administering-sonarcloud/manage-org-projects/manage-project-permissions/#set-default-template)**
>
> As the organization admin, using permission templates allows you to define permissions granted by default on new projects and various sets of permissions.

There is no option. The only way is to apply a template to all the projects, but this will override each project permissions setting.

Best regards.

---

<div class="post-metadata">

**Author:** ![Piyush](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/piyush/32/45758_2.png) [@Piyush](https://community.sonarsource.com/u/Piyush)\
**Post date:** [August 21, 2024, 1:12pm UTC](https://community.sonarsource.com/t/does-this-api-return-private-projects-as-well-get-api-components-search-project/121043/7 "2024-08-21T13:12:39Z")

</div>

Thank u very much Antonio Calero for resolving my queries swiftly
