---
url: >-
  https://canary.warp-drive.io/api/@warp-drive/utilities/json-api/functions/findRecord.md
description: >-
  Builds a JSON:API `GET` request for one resource by type and id, with optional
  `include`.
---

# &#x20;findRecord()

```ts
function findRecord<T, M extends 
  | ObjectValue
  | undefined = 
  | ObjectValue
| undefined, E extends object = ApiError>(identifier: RemotelyAccessibleIdentifier<TypeFromInstance<T>>, options?: FindRecordOptions$2): FindRecordRequestOptions<ReactiveDataDocument<T, M, E>, T>;
function findRecord(identifier: RemotelyAccessibleIdentifier, options?: FindRecordOptions$2): FindRecordRequestOptions;
function findRecord<T, M extends 
  | ObjectValue
  | undefined = 
  | ObjectValue
  | undefined, E extends object = ApiError>(
   type: TypeFromInstance<T>, 
   id: string, 
   options?: FindRecordOptions$2
): FindRecordRequestOptions<ReactiveDataDocument<T, M, E>, T>;
function findRecord(
   type: string, 
   id: string, 
   options?: FindRecordOptions$2
): FindRecordRequestOptions;
```

## Call Signature

```ts
function findRecord<T, M extends 
  | ObjectValue
  | undefined = 
  | ObjectValue
| undefined, E extends object = ApiError>(identifier: RemotelyAccessibleIdentifier<TypeFromInstance<T>>, options?: FindRecordOptions$2): FindRecordRequestOptions<ReactiveDataDocument<T, M, E>, T>;
```

Defined in: [-private/json-api/find-record.ts:95](https://github.com/warp-drive-data/warp-drive/blob/48dc0d277b98008082669dadc6a52e5c5682ef8e/warp-drive-packages/utilities/src/-private/json-api/find-record.ts#L95)

Builds request options to fetch a single resource by a known id or identifier
configured for the url and header expectations of most JSON:API APIs.

See the [Builders](/guides/the-manual/requests/builders) guide for what request builders do and
when to use one.

:::tabs

\== Basic Usage

```ts
import { findRecord } from '@warp-drive/utilities/json-api';
import type { Person } from '#/data/types';

const result = await store.request(
  findRecord<Person>('person', '1')
);
```

\== With Options

```ts
import { findRecord } from '@warp-drive/utilities/json-api';
import type { Person } from '#/data/types';

const data = await store.request(
  findRecord<Person>(
    'person', '1',
    { include: ['pets', 'friends'] }
  )
);
```

\== With an Identifier

```ts
import { findRecord } from '@warp-drive/utilities/json-api';
import type { Person } from '#/data/types';

const data = await store.request(
  findRecord<Person>(
    { type: 'person', id: '1' },
    { include: ['pets', 'friends'] }
  )
);
```

:::

**Supplying Options to Modify the Request Behavior**

The following options are supported:

* `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`.
* `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`.
* `resourcePath` - The resource path to use for the request, defaults to pluralizing the supplied type
* `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this
  option will delegate to the store's CachePolicy, defaulting to `false` if none is configured.
* `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the
  promise with the cached value, not supplying this option will delegate to the store's CachePolicy,
  defaulting to `false` if none is configured.
* `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`)

```ts
import { findRecord } from '@warp-drive/utilities/json-api';

const data = await store.request(
  findRecord(
    'person', '1',
    { include: ['pets', 'friends'] },
    { namespace: 'api/v2' }
  )
);
```

### Type Parameters

#### T

`T`

#### M

`M` *extends*
| [`ObjectValue`](../../../core/types/json/raw/types/ObjectValue.md)
| `undefined` =
| [`ObjectValue`](../../../core/types/json/raw/types/ObjectValue.md)
| `undefined`

#### E

`E` *extends* `object` = [`ApiError`](../../../core/types/spec/error/types/ApiError.md)

### Parameters

#### identifier

`RemotelyAccessibleIdentifier`<[`TypeFromInstance`](../../../core/types/record/types/TypeFromInstance.md)<`T`>>

#### options?

`FindRecordOptions$2`

### Returns

`FindRecordRequestOptions`<`ReactiveDataDocument`<`T`, `M`, `E`>, `T`>

## Call Signature

```ts
function findRecord(identifier: RemotelyAccessibleIdentifier, options?: FindRecordOptions$2): FindRecordRequestOptions;
```

Defined in: [-private/json-api/find-record.ts:99](https://github.com/warp-drive-data/warp-drive/blob/48dc0d277b98008082669dadc6a52e5c5682ef8e/warp-drive-packages/utilities/src/-private/json-api/find-record.ts#L99)

Builds request options to fetch a single resource by a known id or identifier
configured for the url and header expectations of most JSON:API APIs.

See the [Builders](/guides/the-manual/requests/builders) guide for what request builders do and
when to use one.

:::tabs

\== Basic Usage

```ts
import { findRecord } from '@warp-drive/utilities/json-api';
import type { Person } from '#/data/types';

const result = await store.request(
  findRecord<Person>('person', '1')
);
```

\== With Options

```ts
import { findRecord } from '@warp-drive/utilities/json-api';
import type { Person } from '#/data/types';

const data = await store.request(
  findRecord<Person>(
    'person', '1',
    { include: ['pets', 'friends'] }
  )
);
```

\== With an Identifier

```ts
import { findRecord } from '@warp-drive/utilities/json-api';
import type { Person } from '#/data/types';

const data = await store.request(
  findRecord<Person>(
    { type: 'person', id: '1' },
    { include: ['pets', 'friends'] }
  )
);
```

:::

**Supplying Options to Modify the Request Behavior**

The following options are supported:

* `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`.
* `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`.
* `resourcePath` - The resource path to use for the request, defaults to pluralizing the supplied type
* `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this
  option will delegate to the store's CachePolicy, defaulting to `false` if none is configured.
* `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the
  promise with the cached value, not supplying this option will delegate to the store's CachePolicy,
  defaulting to `false` if none is configured.
* `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`)

```ts
import { findRecord } from '@warp-drive/utilities/json-api';

const data = await store.request(
  findRecord(
    'person', '1',
    { include: ['pets', 'friends'] },
    { namespace: 'api/v2' }
  )
);
```

### Parameters

#### identifier

`RemotelyAccessibleIdentifier`

#### options?

`FindRecordOptions$2`

### Returns

`FindRecordRequestOptions`

## Call Signature

```ts
function findRecord<T, M extends 
  | ObjectValue
  | undefined = 
  | ObjectValue
  | undefined, E extends object = ApiError>(
   type: TypeFromInstance<T>, 
   id: string, 
   options?: FindRecordOptions$2
): FindRecordRequestOptions<ReactiveDataDocument<T, M, E>, T>;
```

Defined in: [-private/json-api/find-record.ts:103](https://github.com/warp-drive-data/warp-drive/blob/48dc0d277b98008082669dadc6a52e5c5682ef8e/warp-drive-packages/utilities/src/-private/json-api/find-record.ts#L103)

Builds request options to fetch a single resource by a known id or identifier
configured for the url and header expectations of most JSON:API APIs.

See the [Builders](/guides/the-manual/requests/builders) guide for what request builders do and
when to use one.

:::tabs

\== Basic Usage

```ts
import { findRecord } from '@warp-drive/utilities/json-api';
import type { Person } from '#/data/types';

const result = await store.request(
  findRecord<Person>('person', '1')
);
```

\== With Options

```ts
import { findRecord } from '@warp-drive/utilities/json-api';
import type { Person } from '#/data/types';

const data = await store.request(
  findRecord<Person>(
    'person', '1',
    { include: ['pets', 'friends'] }
  )
);
```

\== With an Identifier

```ts
import { findRecord } from '@warp-drive/utilities/json-api';
import type { Person } from '#/data/types';

const data = await store.request(
  findRecord<Person>(
    { type: 'person', id: '1' },
    { include: ['pets', 'friends'] }
  )
);
```

:::

**Supplying Options to Modify the Request Behavior**

The following options are supported:

* `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`.
* `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`.
* `resourcePath` - The resource path to use for the request, defaults to pluralizing the supplied type
* `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this
  option will delegate to the store's CachePolicy, defaulting to `false` if none is configured.
* `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the
  promise with the cached value, not supplying this option will delegate to the store's CachePolicy,
  defaulting to `false` if none is configured.
* `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`)

```ts
import { findRecord } from '@warp-drive/utilities/json-api';

const data = await store.request(
  findRecord(
    'person', '1',
    { include: ['pets', 'friends'] },
    { namespace: 'api/v2' }
  )
);
```

### Type Parameters

#### T

`T`

#### M

`M` *extends*
| [`ObjectValue`](../../../core/types/json/raw/types/ObjectValue.md)
| `undefined` =
| [`ObjectValue`](../../../core/types/json/raw/types/ObjectValue.md)
| `undefined`

#### E

`E` *extends* `object` = [`ApiError`](../../../core/types/spec/error/types/ApiError.md)

### Parameters

#### type

[`TypeFromInstance`](../../../core/types/record/types/TypeFromInstance.md)<`T`>

#### id

`string`

#### options?

`FindRecordOptions$2`

### Returns

`FindRecordRequestOptions`<`ReactiveDataDocument`<`T`, `M`, `E`>, `T`>

## Call Signature

```ts
function findRecord(
   type: string, 
   id: string, 
   options?: FindRecordOptions$2
): FindRecordRequestOptions;
```

Defined in: [-private/json-api/find-record.ts:108](https://github.com/warp-drive-data/warp-drive/blob/48dc0d277b98008082669dadc6a52e5c5682ef8e/warp-drive-packages/utilities/src/-private/json-api/find-record.ts#L108)

Builds request options to fetch a single resource by a known id or identifier
configured for the url and header expectations of most JSON:API APIs.

See the [Builders](/guides/the-manual/requests/builders) guide for what request builders do and
when to use one.

:::tabs

\== Basic Usage

```ts
import { findRecord } from '@warp-drive/utilities/json-api';
import type { Person } from '#/data/types';

const result = await store.request(
  findRecord<Person>('person', '1')
);
```

\== With Options

```ts
import { findRecord } from '@warp-drive/utilities/json-api';
import type { Person } from '#/data/types';

const data = await store.request(
  findRecord<Person>(
    'person', '1',
    { include: ['pets', 'friends'] }
  )
);
```

\== With an Identifier

```ts
import { findRecord } from '@warp-drive/utilities/json-api';
import type { Person } from '#/data/types';

const data = await store.request(
  findRecord<Person>(
    { type: 'person', id: '1' },
    { include: ['pets', 'friends'] }
  )
);
```

:::

**Supplying Options to Modify the Request Behavior**

The following options are supported:

* `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`.
* `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`.
* `resourcePath` - The resource path to use for the request, defaults to pluralizing the supplied type
* `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this
  option will delegate to the store's CachePolicy, defaulting to `false` if none is configured.
* `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the
  promise with the cached value, not supplying this option will delegate to the store's CachePolicy,
  defaulting to `false` if none is configured.
* `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`)

```ts
import { findRecord } from '@warp-drive/utilities/json-api';

const data = await store.request(
  findRecord(
    'person', '1',
    { include: ['pets', 'friends'] },
    { namespace: 'api/v2' }
  )
);
```

### Parameters

#### type

`string`

#### id

`string`

#### options?

`FindRecordOptions$2`

### Returns

`FindRecordRequestOptions`
