> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cyborg.co/llms.txt
> Use this file to discover all available pages before exploring further.

# Get

Retrieves items from the index by ID, with the fields you choose.

```python theme={null}
index.get(ids, include=["vector", "contents", "metadata"])
```

### Parameters

| Parameter | Type | Default | Description |
| - | - | - | - |
| `ids` | `List[str]` | - | IDs of the items to retrieve. |
| `include` | `List[str]` | `["vector", "contents", "metadata"]` | *(Optional)* Fields to return besides `id`. |

### Returns

`List[Dict]`, one dict per ID found. IDs that don't exist are left out of the result without an error, and an empty `ids` list returns `[]`. When `include` doesn't contain `"vector"`, an existing item that has none of the requested fields is also left out.

```python theme={null}
{
    "id": str,             # Always returned
    "vector": List[float], # When "vector" is in include
    "contents": str,       # When "contents" is in include; "" if the item has no contents
    "metadata": Dict,      # When "metadata" is in include
}
```

`contents` is always a `str`. Contents upserted as `bytes` come back as their base64 text; decode them with `base64.b64decode()`.

### Exceptions

<AccordionGroup>
  <Accordion title="cyborgdb.AuthenticationError">
    The `index_key` or `api_key` is invalid (HTTP `401`).
  </Accordion>

  <Accordion title="cyborgdb.ServiceError / cyborgdb.TransportError">
    The service returns `5xx` or can't be reached.
  </Accordion>
</AccordionGroup>

See [Errors](../errors) for the full hierarchy.

### Example Usage

```python theme={null}
results = index.get(["doc1", "doc2", "missing-id"], include=["contents", "metadata"])

for item in results:
    print(item["id"], repr(item["contents"]), item["metadata"])
# Output:
# doc1 'First document' {}
# doc2 '' {'category': 'news'}
```

#### Decode bytes contents

```python theme={null}
import base64

index.upsert([{"id": "img1", "vector": [0.1, 0.2, 0.3, 0.4], "contents": b"\x89PNG..."}])

item = index.get(["img1"], include=["contents"])[0]
raw = base64.b64decode(item["contents"])
print(raw[:4])
# Output: b'\x89PNG'
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.