SDKs overview
Weaviate provides a suite of Software Development Kits (SDKs) designed to facilitate interaction with its vector database. These SDKs abstract the underlying Weaviate REST API, allowing developers to perform operations such as creating schemas, importing data, executing vector search queries, and managing data objects directly from their chosen programming environments. The client libraries aim to streamline development workflows by handling HTTP requests, response parsing, and error handling, enabling developers to focus on application logic rather than low-level API interactions.
The official SDKs are maintained by the Weaviate team and support a range of programming languages, with Python, TypeScript, and Go being highlighted for their comprehensive features and community adoption. In addition to official support, community-contributed libraries extend Weaviate's reach to other languages and frameworks, reflecting the open-source nature of the project.
Official SDKs by language
Weaviate offers official client libraries for several popular programming languages. These SDKs provide language-specific interfaces for Weaviate's functionalities, including data modeling, CRUD operations, and vector search. The table below lists the officially supported SDKs, their package names, installation commands, and maturity levels.
| Language | Package/Module Name | Installation Command | Maturity |
|---|---|---|---|
| Python | weaviate-client |
pip install weaviate-client |
Stable |
| TypeScript/JavaScript | @weaviate/client |
npm install @weaviate/client or yarn add @weaviate/client |
Stable |
| Go | github.com/weaviate/weaviate-go-client |
go get github.com/weaviate/weaviate-go-client |
Stable |
| Java | Maven: io.weaviate:client, Gradle: io.weaviate:client |
(See Weaviate Java client documentation for specifics) | Stable |
| Ruby | weaviate-client |
gem install weaviate-client |
Beta |
| Rust | weaviate-client |
cargo add weaviate-client |
Beta |
| C# | Weaviate.Client |
dotnet add package Weaviate.Client |
Beta |
For detailed documentation on each client library, including advanced features and examples, developers can refer to the Weaviate client libraries documentation.
Installation
Installing Weaviate SDKs typically involves using the package manager specific to the programming language. Before installing an SDK, ensure that you have a running Weaviate instance, either locally or in the cloud, as the SDKs require a Weaviate endpoint to connect to. Instructions for setting up a Weaviate instance can be found in the Weaviate quickstart guide.
Python
To install the Python client:
pip install weaviate-client
TypeScript/JavaScript
To install the TypeScript/JavaScript client:
npm install @weaviate/client
# or
yarn add @weaviate/client
Go
To install the Go client:
go get github.com/weaviate/weaviate-go-client
Java
For Java, you typically add the dependency to your pom.xml (Maven) or build.gradle (Gradle) file. Refer to the Weaviate Java client reference for the latest dependency snippets.
Ruby
To install the Ruby client:
gem install weaviate-client
Rust
To install the Rust client:
cargo add weaviate-client
C#
To install the C# client:
dotnet add package Weaviate.Client
Quickstart example
This Python example demonstrates how to connect to a Weaviate instance, create a simple schema, add data, and perform a vector search. This snippet assumes a Weaviate instance is running and accessible at http://localhost:8080.
import weaviate
import json
# 1. Connect to Weaviate
client = weaviate.Client(
url="http://localhost:8080", # Replace with your Weaviate URL
)
# 2. Define a schema class
class_obj = {
"class": "Article",
"description": "A collection of articles",
"vectorizer": "text2vec-openai", # Or your preferred vectorizer
"properties": [
{
"name": "title",
"dataType": ["text"],
"description": "The title of the article",
},
{
"name": "content",
"dataType": ["text"],
"description": "The content of the article",
},
],
}
# Create the schema class if it doesn't exist
if not client.schema.exists("Article"):
client.schema.create_class(class_obj)
print("Schema 'Article' created.")
else:
print("Schema 'Article' already exists.")
# 3. Add data objects
data_objects = [
{
"title": "The Future of AI",
"content": "Artificial intelligence is rapidly evolving...",
},
{
"title": "Understanding Vector Databases",
"content": "Vector databases store data as high-dimensional vectors...",
},
{
"title": "Cloud Computing Trends",
"content": "The shift to cloud-native architectures continues...",
},
]
for obj in data_objects:
client.data_object.create(
data_object=obj,
class_name="Article",
)
print(f"Added {len(data_objects)} data objects.")
# 4. Perform a vector search (semantic search)
query = "What are the latest developments in machine learning?"
response = (
client.query
.get("Article", ["title", "content"])
.with_near_text({"concepts": [query]})
.with_limit(2)
.do()
)
print("\nSearch Results:")
for item in response["data"]["Get"]["Article"]:
print(f" Title: {item['title']}")
print(f" Content: {item['content'][:70]}...")
# Cleanup (optional): Delete the schema class
# client.schema.delete_class("Article")
# print("Schema 'Article' deleted.")
This example illustrates the fundamental steps of schema definition, data ingestion, and semantic search using the Weaviate Python client. Similar workflows are available across other official SDKs, adapted to their respective language conventions. For more advanced queries and data management, consult the Weaviate Python client documentation.
Community libraries
Beyond the official SDKs, the Weaviate ecosystem benefits from community-driven libraries and integrations. These often include connectors to specific frameworks, ORMs, or tools that extend Weaviate's functionality or integrate it into broader data pipelines. While not officially supported by Weaviate, these contributions can offer specialized capabilities or alternative approaches to interacting with the database. Developers should review the individual project's documentation and community support when considering these libraries.
Examples of community contributions might include integrations with specific data science frameworks like TensorFlow or PyTorch, or wrappers for languages not yet covered by official SDKs. For a comprehensive list of community projects and integrations, developers can explore the Weaviate GitHub repository and community forums, which often highlight these contributions.
It is important to note that the stability, maintenance, and feature parity of community libraries can vary. Developers are advised to check the project's activity, issue tracker, and contribution guidelines before relying on them for production applications. The Weaviate team often monitors and sometimes adopts popular community contributions into the official ecosystem over time.