---
title: "Read objects"
description: "How to read objects by ID in Weaviate with code examples in Python, TypeScript, Go, Java, and C#."
url: https://docs.weaviate.io/weaviate/manage-objects/read
---

# Read objects

Instead of querying your database, you can use an ID to retrieve individual objects.

**Additional information**

> [!WARNING]
>
> **Collection (class) Name in Object CRUD Operations**
>
> Collections act like namespaces, so two different collections could have duplicate IDs between them.
>
> Prior to Weaviate `v1.14` you can manipulate objects without specifying the collection name. This method is deprecated. It will be removed in Weaviate `v2.0.0`.
>
> Starting in `v1.20`, you can have [multi-tenant](https://docs.weaviate.io/weaviate/concepts/data#multi-tenancy) datasets. When `multi-tenancy` is enabled, the tenant name is required.
>
> Always include the collection name, and, when enabled, the tenant name.

## Get an object by id

Use an ID to retrieve an object. If the id doesn't exist, Weaviate returns a 404 error.

**Python**

```py
jeopardy = client.collections.use("JeopardyQuestion")

data_object = jeopardy.query.fetch_object_by_id("00ff6900-e64f-5d94-90db-c8cfa3fc851b")

print(data_object.properties)
```

**JavaScript/TypeScript**

```ts
const jeopardy = client.collections.use('JeopardyQuestion')

const response = await jeopardy.query.fetchObjectById('ed89d9e7-4c9d-4a6a-8d20-095cb0026f54')

console.log(response?.properties)
```

**Go (v5)**

```go
objects, err := client.Data().ObjectsGetter().
  WithClassName("JeopardyQuestion").
  WithID("00ff6900-e64f-5d94-90db-c8cfa3fc851b").
  Do(ctx)
if err != nil {
  // handle error
  panic(err)
}

for i, obj := range objects {
  fmt.Printf("object[%v]: %+v\n", i, *obj)
}
```

**Go (v6)**

```go
questions := client.Collections.Use("JeopardyQuestion")
// There is no fetch-by-id call. Filter on the object id instead.
response, err := questions.Query.OverAll(ctx, query.OverAll{
  Filter: &filter.Cond{
    Target:   filter.UUID,
    Operator: filter.Equal,
    Value:    "a1b2c3d4-e5f6-4a5b-8c9d-1a2b3c4d5e6f",
  },
})
if err != nil {
  // handle error
  panic(err)
}
for _, obj := range response.Objects {
  fmt.Printf("%s: %v\n", obj.UUID, obj.Properties)
}
```

**Java**

```java
CollectionHandle<Map<String, Object>> jeopardy = client.collections.use("JeopardyQuestion");

var dataObjectOpt = jeopardy.query.fetchObjectById("00ff6900-e64f-5d94-90db-c8cfa3fc851b");

dataObjectOpt.ifPresent(dataObject -> System.out.println(dataObject.properties()));
```

**C#**

```csharp
var jeopardy = client.Collections.Use("JeopardyQuestion");

var dataObject = await jeopardy.Query.FetchObjectByID(
    Guid.Parse("00ff6900-e64f-5d94-90db-c8cfa3fc851b")
);

if (dataObject != null)
{
    Console.WriteLine(JsonSerializer.Serialize(dataObject.Properties));
}
```

> [!NOTE]
>
> **Returned properties**
>
> By default, all properties and object UUIDs are returned. Blob and reference properties are excluded [unless specified otherwise](https://docs.weaviate.io/weaviate/search/basics#retrieve-object-properties). *This does not apply to the Go client library.*

## Retrieve the object's vector

Object vectors can be retrieved by specifying its return.

**Python**

```py
jeopardy = client.collections.use("JeopardyQuestion")

data_object = jeopardy.query.fetch_object_by_id(
    "00ff6900-e64f-5d94-90db-c8cfa3fc851b",
    include_vector=True
)

print(data_object.vector["default"])
```

**JavaScript/TypeScript**

```ts
const jeopardy = client.collections.use('JeopardyQuestion')

const response = await jeopardy.query.fetchObjectById('ed89d9e7-4c9d-4a6a-8d20-095cb0026f54',{
  includeVector: true
})

console.log(response?.properties)
```

**Go (v5)**

```go
objects, err := client.Data().ObjectsGetter().
  WithClassName("JeopardyQuestion").
  WithID("00ff6900-e64f-5d94-90db-c8cfa3fc851b").
  WithVector().
  Do(ctx)
if err != nil {
  // handle error
  panic(err)
}

for i, obj := range objects {
  fmt.Printf("object[%v]: %+v\n", i, *obj)
}
```

**Go (v6)**

```go
questions := client.Collections.Use("JeopardyQuestion")
// There is no fetch-by-id call. Filter on the object id instead.
response, err := questions.Query.OverAll(ctx, query.OverAll{
  Filter: &filter.Cond{
    Target:   filter.UUID,
    Operator: filter.Equal,
    Value:    "a1b2c3d4-e5f6-4a5b-8c9d-1a2b3c4d5e6f",
  },
  ReturnVectors: []string{"default"},
})
if err != nil {
  // handle error
  panic(err)
}
for _, obj := range response.Objects {
  fmt.Printf("%s: %v\n", obj.UUID, obj.Vectors["default"].Single)
}
```

**Java**

```java
CollectionHandle<Map<String, Object>> jeopardy = client.collections.use("JeopardyQuestion");

var dataObjectOpt = jeopardy.query.fetchObjectById("00ff6900-e64f-5d94-90db-c8cfa3fc851b",
    q -> q.includeVector()
);

dataObjectOpt.ifPresent(dataObject -> System.out
    .println(Arrays.toString(dataObject.vectors().getSingle("default"))));
```

**C#**

```csharp
var jeopardy = client.Collections.Use("JeopardyQuestion");

var dataObject = await jeopardy.Query.FetchObjectByID(
    Guid.Parse("00ff6900-e64f-5d94-90db-c8cfa3fc851b"),
    includeVectors: true
);

if (dataObject?.Vectors.ContainsKey("default") ?? false)
{
    var vector = dataObject.Vectors["default"];
    Console.WriteLine(vector);
}
```

## Retrieve named vectors

Where [named vectors](https://docs.weaviate.io/weaviate/config-refs/collections#named-vectors) are used, you can retrieve one or more of them by specifying their names.

**Python**

```py
reviews = client.collections.use("WineReviewNV")  # Collection with named vectors
vector_names = ["title", "review_body"]

data_object = reviews.query.fetch_object_by_id(
    uuid=obj_uuid,  # Object UUID
    include_vector=vector_names  # Specify names of the vectors to include
)

# The vectors are returned in the `vector` property as a dictionary
for n in vector_names:
    print(f"Vector '{n}': {data_object.vector[n][:5]}...")
```

**JavaScript/TypeScript**

```ts
const reviews = client.collections.use('WineReviewNV') // Collection with named vectors
const objectUuid = '' // Object UUID

const response = await reviews.query.fetchObjectById(objectUuid,{
  includeVector: ['title', 'review_body']
})

console.log(response?.vectors.title)       // print the title vector
console.log(response?.vectors.review_body) // print the review_body vector
```

**Java**

```java
CollectionHandle<Map<String, Object>> reviews = client.collections.use("WineReviewNV"); // Collection with named

var dataObjectOpt = reviews.query.fetchObjectById(objUuid, // Object UUID
    q -> q.includeVector(vectorNames) // Specify to include vectors
);

// The vectors are returned in the `vectors` property as a dictionary
dataObjectOpt.ifPresent(dataObject -> {
  for (String n : vectorNames) {
    float[] vector = dataObject.vectors().getSingle(n);
    if (vector != null) {
      System.out.printf("Vector '%s': %s...\n", n, Arrays.toString(Arrays.copyOf(vector, 5)));
    }
  }
});
```

**C#**

```csharp
var reviews = client.Collections.Use("WineReviewNV"); // Collection with named
var dataObject = await reviews.Query.FetchObjectByID(
    objUuid.Value, // Object UUID
    includeVectors: true // Specify to include vectors
);

// The vectors are returned in the `Vectors` property as a dictionary
if (dataObject != null)
{
    foreach (var name in vectorNames)
    {
        if (dataObject.Vectors.TryGetValue(name, out var vector))
        {
            Console.WriteLine(vector);
        }
    }
}
```

## Check object existence

To efficiently check if an object with a given [id](https://docs.weaviate.io/weaviate/api/graphql/additional-properties#id) exists without retrieving it, make a `HEAD` request to the [`/v1/objects/` REST endpoint](https://docs.weaviate.io/weaviate/api/rest#tag/objects/head/objects/{className}/{id}), or use the following client code:

**Python**

```py
# generate uuid based on the key properties used during data insert
object_uuid = generate_uuid5({"name": "Author to fetch"})

authors = client.collections.use("Author")
author_exists = authors.data.exists(object_uuid)

print("Author exist: ", author_exists)
```

**JavaScript/TypeScript**

```js
import { generateUuid5 } from '@weaviate/node';

// generate uuid based on the key properties used during data insert
const object_uuid = generateUuid5(
  JSON.stringify({ name: "Author to fetch"})
)

const authors = await client.collections.use('Author')
const authorExists = await authors.data.exists(object_uuid)

console.log('Author exists: ' + authorExists)
```

**Go (v5)**

```go
package main

import (
  "context"
  "fmt"

  "github.com/weaviate/weaviate-go-client/v5/weaviate"
  "github.com/weaviate/weaviate-go-client/v5/weaviate/data/replication"  // for consistency levels
)

func main() {
  cfg := weaviate.Config{
    Host:   "localhost:8080",
    Scheme: "http",
  }
  client, err := weaviate.NewClient(cfg)
  if err != nil {
    panic(err)
  }

  exists, err := client.Data().Checker().
    WithClassName("MyClass").
    WithID("36ddd591-2dee-4e7e-a3cc-eb86d30a0923").
    WithConsistencyLevel(replication.ConsistencyLevel.ONE).  // default QUORUM
    Do(context.Background())

  if err != nil {
    panic(err)
  }
  fmt.Printf("%v", exists)
}

// The parameter passed to "WithConsistencyLevel" can be one of:
// * replication.ConsistencyLevel.ALL,
// * replication.ConsistencyLevel.QUORUM, or
// * replication.ConsistencyLevel.ONE.
//
// It determines how many replicas must acknowledge a request
// before it is considered successful.
```

**Java**

```java
CollectionHandle<Map<String, Object>> jeopardy = client.collections.use("JeopardyQuestion");
boolean exists = jeopardy.data.exists("00ff6900-e64f-5d94-90db-c8cfa3fc851b");
System.out.println(exists);
```

**C#**

```csharp
var jeopardy = client.Collections.Use("JeopardyQuestion");

// The C# client checks for existence by attempting to fetch an object and checking for null.
var dataObject = await jeopardy.Query.FetchObjectByID(
    Guid.Parse("00ff6900-e64f-5d94-90db-c8cfa3fc851b")
);
bool exists = dataObject != null;

Console.WriteLine(exists);
```

## Related pages

- [Connect to Weaviate](https://docs.weaviate.io/weaviate/connections)

- [How-to: Search](https://docs.weaviate.io/weaviate/search)

- [How-to: Read all objects](https://docs.weaviate.io/weaviate/manage-objects/read-all-objects)

- [References: REST - /v1/objects](https://docs.weaviate.io/weaviate/api/rest#tag/objects)
