Skip to main content

CatalogApi.queryEntities()

Home > @backstage/catalog-client > CatalogApi > queryEntities

Gets paginated entities from the catalog.

Signature:

queryEntities(request?: QueryEntitiesRequest, options?: CatalogRequestOptions): Promise<QueryEntitiesResponse>;

Parameters

ParameterTypeDescription
requestQueryEntitiesRequest(Optional) Request parameters
optionsCatalogRequestOptions(Optional) Additional options

Returns:

Promise<QueryEntitiesResponse>

Remarks

Example

const response = await catalogClient.queryEntities({
filter: [{ kind: 'group' }],
limit: 20,
fullTextFilter: {
term: 'A',
},
orderFields: { field: 'metadata.name', order: 'asc' },
});

this will match all entities of type group having a name starting with 'A', ordered by name ascending.

The response will contain a maximum of 20 entities. In case more than 20 entities exist, the response will contain a nextCursor property that can be used to fetch the next batch of entities.

const secondBatchResponse = await catalogClient
.queryEntities({ cursor: response.nextCursor });

secondBatchResponse will contain the next batch of (maximum) 20 entities, together with a prevCursor property, useful to fetch the previous batch.