---
url: /nestjs-odata/api/generated/functions/ODataGetByKey.md
---
# Function: ODataGetByKey()

> **ODataGetByKey**(`entitySetName`, `options?`): `MethodDecorator`

Defined in: [decorators/odata-get-by-key.decorator.ts:23](https://github.com/cberd1509/nestjs-odata/blob/a42974292d62fe5da337a603d3b22d57c08cbf68/packages/core/src/decorators/odata-get-by-key.decorator.ts#L23)

Composite method decorator for OData GET-by-key (single entity) endpoints.

Composes:

1. Get(path) — NestJS route decorator, defaults to ':key'
2. SetMetadata(ODATA_ROUTE_KEY, { entitySetName, operation: 'getByKey', isSingleEntity: true })
3. UseInterceptors(ODataResponseInterceptor) — returns entity directly (not wrapped in value array)
4. UseFilters(ODataExceptionFilter) — formats errors as OData v4 error bodies

Per D-05: Returns single entity, not wrapped in value array.
Context URL uses /$entity suffix for single-entity responses.
Zero TypeORM imports — per PKG-01 architecture constraint.

## Parameters

### entitySetName

`string`

### options?

[`ODataGetByKeyOptions`](../interfaces/ODataGetByKeyOptions.md)

## Returns

`MethodDecorator`
