Skip to main content
Beyond REST API endpoints for individual Resource Kinds, the Endor Labs REST API exposes a generic graph API through the Query Service endpoint. Use the Query Service to retrieve resources and their related resources in a single call. Send resource requests through the Query Service with a Query that specifies a Resource Kind and optional list parameters to control the returned data. The Query may also specify nested references, connecting related Resource Kinds, and returning all corresponding data in the response.

List projects with package version counts

The following Query returns the number of package versions in the default branch of each project.
  1. Request a list of projects, but only return the uuid, meta.name and processing_status fields for each project.
  2. Connect the project uuid to the corresponding child package version spec.project_uuid field.
  3. Set additional parameters to filter to only resources from the project’s default branch, and to return the count of resources.©
The response includes the original query request along with the list response data under the spec.query_response field. For each project in the list response, each reference’s data appears under the meta.references field.

List projects, with repository versions and CI/CD tool metrics

The following query requests a list of projects, with a reference for the related RepositoryVersion resources for the default branch, and the corresponding CI/CD tool Metric resources.
  1. Request a list of projects, but only return the uuid and meta.name fields for each project.
  2. Connect the project uuid to the corresponding child RepositoryVersion meta.parent_uuid field.
  3. Set additional parameters to filter to only resources from the project’s default branch, and an additional nested reference for Metric objects related to the RepositoryVersions, with a filter to return only Metrics for the CI/CD tools.
The response for the example above includes then related repository versions and metrics as nested references under their parent resources.
The following query example requests the projects matching the given filter, with multiple references specified for the counts of related finding resources for the default branch.
Note: When using multiple references of the same resource kind, the field return_as serves as the key for identifying references in the response.
The response for the above example includes the Finding counts as references on the project list response, using the values provided with return_as for the reference keys.

Pagination in Query Service endpoint

The page_size field allows you to control the number of elements returned. By default, this value is 100, with a maximum of 500. A paginated response includes a value for the field, next_page_token. You can use this value to fetch additional pages of results. For example, the following query requests for vulnerability findings.
The response to the request contains next_page_token.
Send the next request with the next_page_token to fetch the next set of results.