Orbit API
- Tier: Premium, Ultimate
- Offering: GitLab.com
- Status: Beta
The availability of this feature is controlled by a feature flag. For more information, see the history. This feature is available for testing, but not ready for production use.
Use this API to run queries, retrieve schemas, and check cluster health for Orbit.
Endpoint reference
For the full reference of Orbit endpoints, including paths, parameters, and responses, see the interactive API reference. The following sections cover query DSL behavior and worked examples that the generated reference doesn’t show.
Named queries
Prefer POST /api/v4/orbit/query/:name over POST /api/v4/orbit/query for
programmatic consumers. A named query’s structure lives on the server, so it
cannot drift from the DSL grammar or ontology.
Query templates
The named query templates listed at GET /api/v4/orbit/query/templates
include the query DSL (raw_query) rendered for the authenticated user. The
rendered DSL is not the same for every user:
- Identity values, like the ID of the authenticated user, are resolved
server-side from the request credentials. The same request returns
different
raw_queryvalues for different users. Do not cache or share templates across users. - Placeholders for caller-supplied values, like the selected nodes in
expand_neighbors, are filled with server-declared example values. Replace them with real values before you execute the query.
Prefer executing named queries directly over using templates. Use templates only where displaying the query DSL text is the goal, such as populating a query editor or explorer with the text of a preset.
Query examples
The following examples show the Orbit query DSL for each query type. All
examples use POST /api/v4/orbit/query.
Retrieve a user by username:
curl --request POST \
--header "PRIVATE-TOKEN: <your_access_token>" \
--header "Content-Type: application/json" \
--data '{
"query": {
"query_type": "search",
"node": {"id": "u", "entity": "User", "filters": {"username": "john_smith"}}
}
}' \
--url "https://gitlab.example.com/api/v4/orbit/query"Example response:
{
"result": [
{
"u_id": 1,
"u_username": "john_smith",
"u_name": "John Smith",
"u_state": "active",
"u_type": "User"
}
],
"query_type": "search",
"row_count": 1
}Find merged merge requests in a project:
curl --request POST \
--header "PRIVATE-TOKEN: <your_access_token>" \
--header "Content-Type: application/json" \
--data '{
"query": {
"query_type": "traversal",
"nodes": [
{"id": "p", "entity": "Project", "node_ids": [8]},
{"id": "mr", "entity": "MergeRequest", "filters": {"state": "merged"}}
],
"relationships": [{"type": "IN_PROJECT", "from": "mr", "to": "p"}]
}
}' \
--url "https://gitlab.example.com/api/v4/orbit/query"Example response:
{
"result": [
{
"p_name": "Diaspora Client",
"p_full_path": "diaspora/diaspora-client",
"mr_id": 43,
"mr_iid": 1,
"mr_title": "Resolve connection timeout on large payloads",
"mr_state": "merged"
},
{
"mr_id": 44,
"mr_iid": 2,
"mr_title": "Replace deprecated API calls in federation module",
"mr_state": "merged"
}
],
"query_type": "traversal",
"row_count": 2
}Count merge requests per project:
curl --request POST \
--header "PRIVATE-TOKEN: <your_access_token>" \
--header "Content-Type: application/json" \
--data '{
"query": {
"query_type": "aggregation",
"nodes": [
{"id": "p", "entity": "Project"},
{"id": "mr", "entity": "MergeRequest"}
],
"relationships": [{"type": "IN_PROJECT", "from": "mr", "to": "p"}],
"aggregations": [{"function": "count", "target": "mr", "group_by": "p", "alias": "mr_count"}]
}
}' \
--url "https://gitlab.example.com/api/v4/orbit/query"Example response:
{
"result": [
{"p_name": "Diaspora Client", "p_full_path": "diaspora/diaspora-client", "mr_count": 8},
{"p_name": "Puppet", "p_full_path": "brightbox/puppet", "mr_count": 6}
],
"query_type": "aggregation",
"row_count": 2
}Find outgoing neighbors of a user:
curl --request POST \
--header "PRIVATE-TOKEN: <your_access_token>" \
--header "Content-Type: application/json" \
--data '{
"query": {
"query_type": "neighbors",
"node": {"id": "u", "entity": "User", "node_ids": [43]},
"neighbors": {"node": "u"}
}
}' \
--url "https://gitlab.example.com/api/v4/orbit/query"Example response:
{
"result": [
{
"_gkg_relationship_type": "MEMBER_OF",
"_gkg_neighbor_type": "Project",
"id": 5,
"name": "Diaspora Client"
},
{
"_gkg_relationship_type": "MEMBER_OF",
"_gkg_neighbor_type": "Group",
"id": 29,
"name": "diaspora"
},
{
"_gkg_relationship_type": "AUTHORED",
"_gkg_neighbor_type": "MergeRequest",
"id": 43,
"title": "Resolve connection timeout on large payloads"
}
],
"query_type": "neighbors",
"row_count": 3
}Find the shortest path between two projects:
curl --request POST \
--header "PRIVATE-TOKEN: <your_access_token>" \
--header "Content-Type: application/json" \
--data '{
"query": {
"query_type": "path_finding",
"nodes": [
{"id": "p1", "entity": "Project", "node_ids": [8]},
{"id": "p2", "entity": "Project", "node_ids": [5]}
],
"path": {"type": "shortest", "from": "p1", "to": "p2", "max_depth": 3}
}
}' \
--url "https://gitlab.example.com/api/v4/orbit/query"Example response:
{
"result": [
{
"depth": 2,
"path": [
{"id": 8, "entity_type": "Project", "name": "Diaspora Client", "full_path": "diaspora/diaspora-client"},
{"id": 43, "entity_type": "User", "name": "John Smith", "username": "john_smith"},
{"id": 5, "entity_type": "Project", "name": "Puppet", "full_path": "brightbox/puppet"}
],
"edges": ["MEMBER_OF", "MEMBER_OF"]
}
],
"query_type": "path_finding",
"row_count": 1
}Access and cluster health
GET /api/v4/orbit/status always returns 200 OK,
regardless of access or service health. When the user has no access, system
is null:
{
"user": {
"available": false
},
"system": null
}