component_tree: Navigate through components based on the chosen strategy with specified measures

API: sonarcloud.io:sonarqube
Endpoint: /api/measures/component_tree
Response format: application/json
Auth: unknown
Method: GET
Last Status: 400
Latency: 138ms

Description

Navigate through components based on the chosen strategy with specified measures. The baseComponentId or the component parameter must be provided. Requires the following permission: 'Browse' on the specified project. When limiting search with the q parameter, directories are not returned.

Parameters (18)

additionalFields (string, query, optional)

Comma-separated list of additional fields that can be returned in the response.

Constraints: {'enum': ['metrics', 'periods']}

asc (string, query, optional, default: true)

Ascending sort

Constraints: {'enum': ['true', 'false', 'yes', 'no']}

baseComponentId (string, query, optional)

Base component id. The search is based on this component.

branch (string, query, optional)

Branch key

component (string, query, optional)

Component key. The search is based on this component.

developerId (string, query, optional)

Deprecated parameter, used previously with the Developer Cockpit plugin. No measures are returned if parameter is set.

developerKey (string, query, optional)

Deprecated parameter, used previously with the Developer Cockpit plugin. No measures are returned if parameter is set.

metricKeys (string, query, required)

Comma-separated list of metric keys. Types DATA, DISTRIB are not allowed.

metricPeriodSort (string, query, optional)

Sort measures by leak period or not ?. The 's' parameter must contain the 'metricPeriod' value.

Constraints: {'enum': ['1']}

metricSort (string, query, optional)

Metric key to sort by. The 's' parameter must contain the 'metric' or 'metricPeriod' value. It must be part of the 'metricKeys' parameter

metricSortFilter (string, query, optional, default: all)

Filter components. Sort must be on a metric. Possible values are: - all: return all components- withMeasuresOnly: filter out components that do not have a measure on the sorted metric

Constraints: {'enum': ['all', 'withMeasuresOnly']}

p (string, query, optional, default: 1)

1-based page number

ps (string, query, optional, default: 100)

Page size. Must be greater than 0 and less or equal than 500

pullRequest (string, query, optional)

Pull request id

q (string, query, optional)

Limit search to: - component names that contain the supplied string- component keys that are exactly the same as the supplied string

qualifiers (string, query, optional)

Comma-separated list of component qualifiers. Filter the results with the specified qualifiers. Possible values are: - BRC - Sub-projects- DIR - Directories- FIL - Files- TRK - Projects- UTS - Test Files

Constraints: {'enum': ['BRC', 'DIR', 'FIL', 'TRK', 'UTS']}

s (string, query, optional, default: name)

Comma-separated list of sort fields

Constraints: {'enum': ['metric', 'metricPeriod', 'name', 'path', 'qualifier']}

strategy (string, query, optional, default: all)

Strategy to search for base component descendants: - children: return the children components of the base component. Grandchildren components are not returned- all: return all the descendants components of the base component. Grandchildren are returned.- leaves: return all the descendant components (files, in general) which don't have other children. They are the leaves of the component tree.

Constraints: {'enum': ['children', 'leaves', 'all']}

Examples (1)

Navigate through components based on the chosen strategy with specified measures openapi-spec
curl 'https://sonarcloud.io/api/measures/component_tree?additionalFields=periods%2Cmetrics&baseComponentId=AU-TpxcA-iU5OvuD2FLz&branch=feature%2Fmy_branch&component=my_project&metricKeys=ncloc%2Ccomplexity%2Cviolations&metricSort=ncloc&p=42&ps=20&pullRequest=5461&q=FILE_NAM&s=name%2Cpath'
import requests

resp = requests.get(
    "https://sonarcloud.io/api/measures/component_tree",
    params={
        'additionalFields': 'periods,metrics',
        'baseComponentId': 'AU-TpxcA-iU5OvuD2FLz',
        'branch': 'feature/my_branch',
        'component': 'my_project',
        'metricKeys': 'ncloc,complexity,violations',
        'metricSort': 'ncloc',
        'p': '42',
        'ps': '20',
        'pullRequest': '5461',
        'q': 'FILE_NAM',
        's': 'name,path',
    },
)
data = resp.json()
import zingu_apis

api = zingu_apis.api("sonarqube")
result = api.fetch("api/measures/component_tree", additionalFields="periods,metrics", baseComponentId="AU-TpxcA-iU5OvuD2FLz", branch="feature/my_branch", component="my_project", metricKeys="ncloc,complexity,violations", metricSort="ncloc", p=42, ps=20, pullRequest=5461, q="FILE_NAM", s="name,path")

for item in result:
    print(item)
const resp = await fetch("https://sonarcloud.io/api/measures/component_tree?additionalFields=periods%2Cmetrics&baseComponentId=AU-TpxcA-iU5OvuD2FLz&branch=feature%2Fmy_branch&component=my_project&metricKeys=ncloc%2Ccomplexity%2Cviolations&metricSort=ncloc&p=42&ps=20&pullRequest=5461&q=FILE_NAM&s=name%2Cpath");
const data = await resp.json();

Probe History

Latency

Status Codes

TimeStatusLatencySize
2026-04-16 00:50:27.400447 400 138ms
2026-04-15 01:07:20.614968 400 150ms
2026-04-14 02:52:06.672460 400 165ms
2026-04-12 13:13:13.592389 400 178ms
2026-04-10 01:49:15.720916 400 98ms
2026-04-09 01:35:12.133491 400 170ms