---
editLink: false
lastUpdated: false
---

[@salesforce/b2c-tooling-sdk](../../../modules.md) / [operations/metrics](../index.md) / getMetricsByCategory

# Function: getMetricsByCategory()

> **getMetricsByCategory**(`client`, `tenantId`, `category`, `options?`): `Promise`\<\{ \}\>

Defined in: [packages/b2c-tooling-sdk/src/operations/metrics/index.ts:675](https://github.com/SalesforceCommerceCloud/b2c-developer-tooling/blob/67fb8580ac3c5b372617ee3ec3fc8f2bc9f16174/packages/b2c-tooling-sdk/src/operations/metrics/index.ts#L675)

Retrieves metrics for a category by name, dispatching to the category-specific
function. Category-specific filters (`thirdPartyServiceId`, `apiFamily`,
`apiName`, `ocapiCategory`, `ocapiApi`) are applied only for the categories
that support them and ignored otherwise.

## Parameters

### client

[`MetricsClient`](../../../clients/type-aliases/MetricsClient.md)

Metrics API client from createMetricsClient

### tenantId

`string`

Tenant ID (with or without the `f_ecom_` prefix)

### category

One of [METRIC\_CATEGORIES](../variables/METRIC_CATEGORIES.md)

`"ocapi"` | `"mrt"` | `"ecdn"` | `"overall"` | `"sales"` | `"third-party"` | `"scapi"` | `"scapi-hooks"` | `"controller"`

### options?

[`MetricsQueryOptions`](../type-aliases/MetricsQueryOptions.md)

Optional time window and category-specific filters

## Returns

`Promise`\<\{ \}\>

The metrics data response

## Throws

Error if the request fails or the category is unknown
