Skip to main content

REST - /v1/objects

LICENSE Weaviate on Stackoverflow badge Weaviate issues on Github badge Weaviate version badge Weaviate total Docker pulls badge Go Report Card

List all data objects

Lists all data objects in reverse order of creation. The data will be returned as an array of objects

Method and URL

Without any restrictions (across classes, default limit):

GET /v1/objects

With optional query params:

GET /v1/objects?class={className}&limit={limit}&include={include}

Parameters

namelocationtype
limitURL Query Parameter (optional)integer
includeURL Query Parameter (optional)string
classURL Query Parameter (optional)string

Response fields

The response of a GET query of a data object will give you information about all objects (or a single object). Next to general information about the data objects, like schema information and property values, meta information will be shown depending on the include fields or additional properties of your request.

Response format

{
"objects": [/* list of objects, see below */],
"deprecations: null,
}

Object fields

field namedatatyperequired include or additional fielddescription
classstringnonethe class name
creationTimeUnixunix timestampnonethe time stamp of creation of the data object
iduuidnonethe uuid of the data object
lastUpdateTimeUnixunix timestampnonethe time stamp when the data object was last updated
properties > {property_name}dataTypenonethe name and value of an individual property
properties > {cref_property_name} > classification > closestLosingDistancefloatclassificationThe lowest distance of a neighbor in the losing group. Optional. If k equals the size of the winning group, there is no losing group.
properties > {cref_property_name} > classification > closestOverallDistancefloatclassificationThe lowest distance of any neighbor, regardless of whether they were in the winning or losing.
properties > {cref_property_name} > classification > closestWinningDistancefloatclassificationClosest distance of a neighbor from the winning group.
properties > {cref_property_name} > classification > losingCountintegerclassificationSize of the losing group, can be 0 if the winning group size equals k.
properties > {cref_property_name} > classification > meanLosingDistancefloatclassificationThe mean distance of the losing group. It is a normalized distance (between 0 and 1), where 0 means equal and 1 would mean a perfect opposite.
properties > {cref_property_name} > classification > meanWinningDistancefloatclassificationThe mean distance of the winning group. It is a normalized distance (between 0 and 1), where 0 means equal and 1 would mean a perfect opposite.
properties > {cref_property_name} > classification > overallCountintegerclassificationOverall neighbors checked as part of the classification. In most cases this will equal k, but could be lower than k - for example if not enough data was present.
properties > {cref_property_name} > classification > winningCountintegerclassificationSize of the winning group, a number between 1 and k.
vectorlist of floatsvectorthe long vector of the location of the object in the 300 dimensional space
classification > basedOnstringclassificationthe property name where the classification was based on
classification > classifiedFieldsstringclassificationthe classified property
classification > completedtimestampclassificationthe time of classification completion
classification > iduuidclassificationthe classification id
classification > scopelist of stringsclassificationthe initial fields to classify
featureProjection > vectorlist of floatsfeatureProjectionthe 2D or 3D vector coordinates of the feature projection

Status codes and error cases

CauseDescriptionResult
No objects presentNo ?class is provided. There are no objects present in the entire Weaviate instance.200 OK - No error
Valid class, no objects present?class is provided, class exists. There are no objects present for this class200 OK - No error
Invalid class?class is provided, class does not exist404 Not Found
ValidationOtherwise invalid user request422 Unprocessable Entity
AuthorizationNot allowed to view resource403 Forbidden
Server-Side errorCorrect user input, but request failed for another reason500 Internal Server Error - contains detailed error message

Example request

import weaviate

client = weaviate.Client("http://localhost:8080")

all_objects = client.data_object.get(class_name="MyClass")
print(all_objects)

Create a data object

Create a new data object. The provided meta-data and schema values are validated.

Performance

💡 This endpoint is meant for individual object creations.

If you have a whole dataset that you plan on importing with Weaviate sending multiple single requests sequentially comes at a large cost:

  1. Each sequential request would be handled by a single thread server-side while most of the server resources are idle. In addition, if you only send the second request once the first has been completed, you will wait for a lot of network overhead.
  2. It's much more efficient to parallelize imports. This will minimize the connection overhead and use multiple threads server-side for indexing.
  3. You do not have to do the parallelization yourself, you can use the /v1/batch endpoint for this. Even if you are sending batches from a single client thread, the objects within a batch will be handled by multiple server threads.
  4. Import speeds, especially for large datasets, will drastically improve when using the batching endpoint.
  5. Go to the /v1/batch endpoint.

Method and URL

POST /v1/objects

Note: The className is not specified through the URL, as it is part of the request body.

Parameters

The body of the data object for a new object takes the following fields:

nametyperequireddescription
classstringyesthe class name as defined in the schema
propertiesarrayyesan object with the property values of the new data object
properties > {property_name}dataTypeyesthe property and its value according to the set dataType
idv4 UUIDnothe given id of the data object

Example request

import weaviate

client = weaviate.Client("http://localhost:8080")

data_obj = {
"name": "Jodi Kantor",
"writesFor": [{
"beacon": "weaviate://localhost/Article/f81bfe5e-16ba-4615-a516-46c2ae2e5a80"
}]
}

data_uuid = client.data_object.create(
data_obj,
"Author",
uuid="36ddd591-2dee-4e7e-a3cc-eb86d30a4303", # optional, if not provided, one is going to be generated
)

Create an object with geoCoordinates

If you want to fill the value of a geoCoordinates property, you need to specify the latitude and longitude as decimal degrees in floats:

import weaviate

client = weaviate.Client("http://localhost:8080")

data_obj = {
"name": "Elsevier",
"headquartersGeoLocation": {
"latitude": 52.3932696,
"longitude": 4.8374263
}
}

data_uuid = client.data_object.create(
data_obj,
"Publication",
uuid="df48b9f6-ba48-470c-bf6a-57657cb07390", # optional, if not provided, one is going to be generated
)

Create a data object with a custom vector

When creating a data object, you can configure Weaviate to generate a vector with a vectorizer module, or you can provide the vector yourself. We sometimes refer to this as a "custom" vector.

You can provide a custom vector during object creation for either when:

  • you are not using a vectorizer for that class, or
  • you are using a vectorizer, but you wish to bypass it during the object creation stage. You can create a data object with a custom vector as follows:
  1. Set the "vectorizer" in the relevant class in the data schema.
    • If you are not using a vectorizer at all, configure the class accordingly. To do this, you can:
      • set the default vectorizer module to "none" (DEFAULT_VECTORIZER_MODULE="none"), or
      • set the "vectorizer" for the class to "none" ("vectorizer": "none") (note: the class vectorizer setting will override the DEFAULT_VECTORIZER_MODULE parameter).
    • If you wish to bypass the vectorizer for object creation:
      • set the vectorizer to the same vectorizer with identical settings used to generate the custom vector

        Note: There is NO validation of this vector besides checking the vector length.

  2. Then, attach the vector in a special "vector" field during object creation. For example, if adding a single object, you can:

    Note: You can set custom vectors for batch imports as well as single object creation.

import weaviate

client = weaviate.Client("http://localhost:8080")

data_obj = {
"foo": "bar"
}

data_uuid = client.data_object.create(
data_obj,
"YourClass",
uuid="36ddd591-2dee-4e7e-a3cc-eb86d30a0923", # optional, if not provided, one is going to be generated
vector = [0.3, 0.2, 0.1, .... 0.9], # supported types are `list`, `numpy.ndarray`, `torch.Tensor` and `tf.Tensor`. Make sure the length matches with your Weaviate settings.
)

Learn here how you can search through custom vectors.

Get a data object

Collect an individual data object.

Method and URL

Available since v1.14 and preferred way:

GET /v1/objects/{className}/{id}

Available for backward compatibility and deprecated:

GET /v1/objects/{id}
Class Name in Object CRUD Operations

Prior to Weaviate v1.14 it was possible to manipulate objects using only their ID without specifying the class name. This way is still supported for backward compatibility, but is considered deprecated now. Avoid using the deprecated endpoints, as they will be removed with Weaviate v2.0.0.

The reason for the deprecation is that classes generally act like namespaces, therefore it is also feasible to have duplicate IDs across classes. However, when manipulating exactly one object by its ID (such as an update or delete), the ID may not be unique. It is thus recommended to always include the class name when manipulating objects.

Parameters

namelocationtype
{className}URL Pathstring
{id}URL Query paramuuid
includeURL Query paramstring

Example request

See here the explanation of the response fields.

import weaviate

client = weaviate.Client("http://localhost:8080")

data_object = client.data_object.get_by_id("36ddd591-2dee-4e7e-a3cc-eb86d30a4303", "MyClass")
print(data_object)

Example request for retrieving a data object with consistency_level=QUORUM

import weaviate
from weaviate.data.replication import ConsistencyLevel

client = weaviate.Client("http://localhost:8080")

data_object = (
client.data_object.get_by_id(
uuid="36ddd591-2dee-4e7e-a3cc-eb86d30a4303",
class_name="MyClass",
consistency_level=ConsistencyLevel.QUORUM,
)
)

# The parameter "consistency_level" can be one of ConsistencyLevel.ALL, ConsistencyLevel.QUORUM,
# or ConsistencyLevel.ONE. Determines how many replicas must acknowledge a request before it is
# considered successful.

print(data_object)

Check if a data object exists without retrieving it

This endpoint can be used to check if a data object exists without retrieving it. Internally it skips reading the object from disk (other than checking if it is present), thus not using resources on marshalling, parsing, etc. Additionally the resulting HTTP request has no body, the existence of an object is indicated solely by the status code (204 when the object exists, 404 when it doesn't).

Method and URL

Available since v1.14 and preferred way:

HEAD /v1/objects/{className}/{id}

Available for backward compatibility and deprecated:

HEAD /v1/objects/{id}
Class Name in Object CRUD Operations

Prior to Weaviate v1.14 it was possible to manipulate objects using only their ID without specifying the class name. This way is still supported for backward compatibility, but is considered deprecated now. Avoid using the deprecated endpoints, as they will be removed with Weaviate v2.0.0.

The reason for the deprecation is that classes generally act like namespaces, therefore it is also feasible to have duplicate IDs across classes. However, when manipulating exactly one object by its ID (such as an update or delete), the ID may not be unique. It is thus recommended to always include the class name when manipulating objects.

Parameters

namelocationtype
{className}URL Pathstring
{id}URLuuid

Example request

import weaviate

client = weaviate.Client("http://localhost:8080")

exists = client.data_object.exists("36ddd591-2dee-4e7e-a3cc-eb86d30a4303", "MyClass")
print(exists)

Update a data object

Update an individual data object based on its uuid.

Method and URL

In the RESTful API, both PUT and PATCH methods are accepted. PUT replaces all property values of the data object, while PATCH only overwrites the given properties.

Available since v1.14 and preferred way:

PUT /v1/objects/{className}/{id}
PATCH /v1/objects/{className}/{id}

Available for backward compatibility and deprecated:

PUT /v1/objects/{id}
PATCH /v1/objects/{id}
Class Name in Object CRUD Operations

Prior to Weaviate v1.14 it was possible to manipulate objects using only their ID without specifying the class name. This way is still supported for backward compatibility, but is considered deprecated now. Avoid using the deprecated endpoints, as they will be removed with Weaviate v2.0.0.

The reason for the deprecation is that classes generally act like namespaces, therefore it is also feasible to have duplicate IDs across classes. However, when manipulating exactly one object by its ID (such as an update or delete), the ID may not be unique. It is thus recommended to always include the class name when manipulating objects.

Parameters

namelocationtype
{className}URL Pathstring
{id}URLuuid

The body of the data object for a replacing (some) properties of a object takes the following fields:

nametyperequireddescription
classstringyesthe class name as defined in the schema
propertiesarrayyesan object with the property values of the new data object
properties > {property_name}dataTypeyesthe property and its value according to the set dataType

Example request

import weaviate

client = weaviate.Client("http://localhost:8080")

updated_schema = {
"name": "J. Kantor"
}

# Update only the properties in variable "updated_schema"
client.data_object.update(
updated_schema,
"Author",
"36ddd591-2dee-4e7e-a3cc-eb86d30a4303"
)

# Replaces the whole data object with the "updated_schema"
client.data_object.replace(
updated_schema,
"Author",
"36ddd591-2dee-4e7e-a3cc-eb86d30a4303"
)

If the update was successful, no content will be returned.

Delete a data object

Delete an individual data object from Weaviate.

Method and URL

Available since v1.14 and preferred way:

DELETE /v1/objects/{className}/{id}

Available for backward compatibility and deprecated:

DELETE /v1/objects/{id}
Class Name in Object CRUD Operations

Prior to Weaviate v1.14 it was possible to manipulate objects using only their ID without specifying the class name. This way is still supported for backward compatibility, but is considered deprecated now. Avoid using the deprecated endpoints, as they will be removed with Weaviate v2.0.0.

The reason for the deprecation is that classes generally act like namespaces, therefore it is also feasible to have duplicate IDs across classes. However, when manipulating exactly one object by its ID (such as an update or delete), the ID may not be unique. It is thus recommended to always include the class name when manipulating objects.

Parameters

namelocationtype
{className}URL Pathstring
{id}URLuuid

Example request

import weaviate

client = weaviate.Client("http://localhost:8080")

client.data_object.delete("36ddd591-2dee-4e7e-a3cc-eb86d30a4303", "MyClass")

If the deletion was successful, no content will be returned.

Validate a data object

You can validate a data object's schema and meta data.

Method and URL

POST /v1/objects/validate

Note: As with creating an object, the className is not specified through the URL, as it is part of the request body.

Parameters

The body of the data object for a new data object is an object taking the following field:

nametyperequireddescription
classstringyesthe class name as defined in the schema
propertiesarrayyesan object with the property values of the new data object
properties > {property_name}dataTypeyesthe property and its value according to the set dataType
idv4 uuidno*The id of the data object. *An ID is required by the clients.

Example request

import weaviate

client = weaviate.Client("http://localhost:8080")

schema = {"name": "New York Times"}

valid_thing = client.data_object.validate(
schema,
"Publication",
"f81bfe5e-16ba-4615-a516-46c2ae2e5a80"
)
print(valid_thing)

If the schema of the object is valid, this request should return True/true in case of the clients and nothing with a plain RESTful request.

Cross-references

Add a cross reference

Method and URL

Available since v1.14 and preferred way:

POST /v1/objects/{className}/{id}/references/{property_name}

Available for backward compatibility and deprecated:

POST /v1/objects/{id}/references/{property_name}
Class Name in Object CRUD Operations

Prior to Weaviate v1.14 it was possible to manipulate objects using only their ID without specifying the class name. This way is still supported for backward compatibility, but is considered deprecated now. Avoid using the deprecated endpoints, as they will be removed with Weaviate v2.0.0.

The reason for the deprecation is that classes generally act like namespaces, therefore it is also feasible to have duplicate IDs across classes. However, when manipulating exactly one object by its ID (such as an update or delete), the ID may not be unique. It is thus recommended to always include the class name when manipulating objects.

Parameters

namelocationtype
{className}URL Pathstring
{id}URLuuid
{property_name}URLyes

The body of the data object for a new data object is an object taking the following field:

nametyperequireddescription
beaconWeaviate Beaconyesthe beacon URL of the reference, in the format of weaviate://localhost/<ClassName>/&lt;id&gt;

Note: In the beacon format, you need to always use localhost as the host, rather than the actual hostname. localhost refers to the fact that the beacon's target is on the same Weaviate instance, as opposed to a foreign instance.

Note: For backward compatibility, you can omit the class name in the beacon format and specify it as weaviate://localhost/<id>. This is, however, considered deprecated and will be removed with a future release, as duplicate IDs across classes could mean that this beacon is not uniquely identifiable.

Example request

import weaviate
# weaviate.__version__ >= 3.7.0

client = weaviate.Client("http://localhost:8080")

client.data_object.reference.add(
"36ddd591-2dee-4e7e-a3cc-eb86d30a4303",
"wroteArticles",
"6bb06a43-e7f0-393e-9ecf-3c0f4e129064",
from_class_name="SourceClass",
to_class_name="TargetClass",
)

If the addition was successful, no content will be returned.

Update a cross reference

A PUT request updates all references of a property of a data object.

Method and URL

Available since v1.14 and preferred way:

PUT /v1/objects/{className}/{id}/references/{property_name}

Available for backward compatibility and deprecated:

PUT /v1/objects/{id}/references/{property_name}
Class Name in Object CRUD Operations

Prior to Weaviate v1.14 it was possible to manipulate objects using only their ID without specifying the class name. This way is still supported for backward compatibility, but is considered deprecated now. Avoid using the deprecated endpoints, as they will be removed with Weaviate v2.0.0.

The reason for the deprecation is that classes generally act like namespaces, therefore it is also feasible to have duplicate IDs across classes. However, when manipulating exactly one object by its ID (such as an update or delete), the ID may not be unique. It is thus recommended to always include the class name when manipulating objects.

Parameters

namelocationtype
{className}URL Pathstring
{id}URLuuid
{property_name}URLyes

The body of the data object for a new data object is a list of beacons:

nametyperequireddescription
beaconWeaviate Beaconyesthe beacon URL of the reference, in the format of weaviate://localhost/<ClassName>/&lt;id&gt;

Note: In the beacon format, you need to always use localhost as the host, rather than the actual hostname. localhost refers to the fact that the beacon's target is on the same Weaviate instance, as opposed to a foreign instance.

Note: For backward compatibility, you can omit the class name in the beacon format and specify it as weaviate://localhost/<id>. This is, however, considered deprecated and will be removed with a future release, as duplicate IDs across classes could mean that this beacon is not uniquely identifiable.

Example request

import weaviate

client = weaviate.Client("http://localhost:8080")

client.data_object.reference.update(
"36ddd591-2dee-4e7e-a3cc-eb86d30a4303",
"wroteArticles",
["6bb06a43-e7f0-393e-9ecf-3c0f4e129064", "b72912b9-e5d7-304e-a654-66dc63c55b32"]
from_class_name="SourceClass",
to_class_name="TargetClass"
)

If the addition was successful, no content will be returned.

Delete a cross reference

Delete the single reference that is given in the body from the list of references that this property of a data object has.

Method and URL

Available since v1.14 and preferred way:

DELETE /v1/objects/{className}/{id}/references/{property_name}

Available for backward compatibility and deprecated:

DELETE /v1/objects/{id}/references/{property_name}
Class Name in Object CRUD Operations

Prior to Weaviate v1.14 it was possible to manipulate objects using only their ID without specifying the class name. This way is still supported for backward compatibility, but is considered deprecated now. Avoid using the deprecated endpoints, as they will be removed with Weaviate v2.0.0.

The reason for the deprecation is that classes generally act like namespaces, therefore it is also feasible to have duplicate IDs across classes. However, when manipulating exactly one object by its ID (such as an update or delete), the ID may not be unique. It is thus recommended to always include the class name when manipulating objects.

Parameters

namelocationtype
{id}URLuuid
{property_name}URLyes

The body of the data object for a new data object is a list of beacons:

nametyperequireddescription
beaconWeaviate Beaconyesthe beacon URL of the reference, in the format of weaviate://localhost/<ClassName>/&lt;id&gt;

Note: In the beacon format, you need to always use localhost as the host, rather than the actual hostname. localhost refers to the fact that the beacon's target is on the same Weaviate instance, as opposed to a foreign instance.

Note: For backward compatibility, beacons generally support an older, deprecated format without the class name, as well. This means you might find beacons with the old, deprecated format, as well as beacons with the new format in the same Weaviate instance. When deleting a reference, the beacon specified has to match the beacon to be deleted exactly. In other words, if a beacon is present using the old format (without class id) you also need to specify it the same way.

Example request

import weaviate

client = weaviate.Client("http://localhost:8080")

client.data_object.reference.delete(
"36ddd591-2dee-4e7e-a3cc-eb86d30a4303",
"wroteArticles",
"6bb06a43-e7f0-393e-9ecf-3c0f4e129064"
from_class_name="SourceClass",
to_class_name="TargetClass"
)

If the addition was successful, no content will be returned.