# Fetch

Used to retrieve the vector by ID.

## Arguments

<ResponseField name="IDs" type="string[] | number[]" required>
  The IDs of the vectors you want to fetch.
</ResponseField>

**OR**

<ResponseField name="FetchPayload" type="object" required>
  <Expandable defaultOpen="true">
    <ResponseField name="ids" type="string[] | number[]">
      The IDs of the vectors you want to fetch.
    </ResponseField>
    <ResponseField name="prefix" type="string">
      An id prefix to match vector IDs.
      <Warning>
        For fetching larger datasets with prefix, it is recommended to use the
        paginated `range` command instead.
      </Warning>
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="Options" type="Object">
  <Expandable defaultOpen="true">
    <ResponseField name="includeMetadata" type="boolean">
      Whether to include the metadata of the vectors in the response. Setting
      this `true` would be the best practice, since it will make it easier to
      identify the vectors.
    </ResponseField>
    <ParamField body="includeVectors" type="boolean">
      Whether to include the vector themselves in the response.
    </ParamField>
    <ParamField body="includeData" type="boolean">
      Whether to include [the data field](/vector/features/metadata#data) in the
      response.
    </ParamField>
    <ResponseField name="namespace" type="string">
      Namespace to fetch from. If not set, default namespace is used.
    </ResponseField>
  </Expandable>
</ResponseField>

## Response

<ResponseField name="FetchResult[]" type="Vector[]" required>
  This field is `null` if no vector with the specified id is found.
  <Expandable defaultOpen="true">
    <ResponseField name="id" type="string | number" required>
      The ID of the resulting vector. <br />
    </ResponseField>
    <ResponseField name="vector" type="number[]">
      The vectors (if `includeVectors` is set to true)
    </ResponseField>
    <ResponseField name="sparseVector" type="SparseVector">
      The resulting sparseVector (if `includeVectors` is set to true)
    </ResponseField>
    <ResponseField name="metadata" type="Record<string, unknown>">
      The metadata of the vectors (if `includeMetadata` is set to true)
    </ResponseField>
    <ResponseField name="data" type="string">
      The data of the vector (if `includeData` is set to true)
    </ResponseField>
  </Expandable>
</ResponseField>

<RequestExample>

```typescript Basic
await index.fetch(["2", "3"]);
// [{ id: "2" }, { id: "3" }]
```

```typescript Vector Not Found
await index.fetch(["2", "3"]);
// [{ id: "2" }, null]
```

```typescript ID prefix
await index.fetch({ prefix: "test-" });
// [{ id: "test-1" }, { id: "test-2" }, { id: "test-3" }]
```

</RequestExample>
