SonarCloud API search projects by size

Hello!

For a data analysis project I would need to collect from https://sonarcloud.io/api/components/search_projects the organisation key and project name for all projects with size >=4. Filter in a similar way as in Open Source Projects - SonarCloud. Is this possible or there are other soultions to get a similar result? Web Scraping directly from the latter would be much more challenging.

Thanks in advance.

Hey there.

You’ve already identified the right Web API to use, which returns the organization key and project. What’s the missing piece?

Hi Colin,

the right API would be https://sonarcloud.io/api/components/search_projects that is not included in the documentation. But it gives back project key and organization name as output. I would need to filter to get only project with more than 100k ncloc (or like in the explore section size >=4).

My temporary solution is saving all the possible projects key returned by https://sonarcloud.io/api/components/search_projects and then double check through https://sonarcloud.io/api/measures/component if they have more than 100k ncloc. But I think that with this last method I miss out some of the projects and would be better to filter directly within the first call.

Thank you again!

You can also just add this query parameter: &filter=ncloc+>%3D+100000

Like:

https://sonarcloud.io/api/components/search_projects?boostNewProjects=false&facets=ncloc%2Clanguages&ps=50&f=analysisDate&s=analysisDate&asc=false&filter=ncloc+%3E%3D+100000

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.