Clients

Weaviate on Stackoverflow badge Weaviate issues on Github badge Weaviate total Docker pulls badge

💡 You are looking at older or release candidate documentation. The current Weaviate version is v1.15.2


There are two ways how you can interact with Weaviate:

  1. By using the GraphQL or RESTful API directly.
  2. By using one of the available client libraries.

Client examples in the documentation

Weaviate examples in the documentation are always shown in a handy accordion menu.

The following example show you how you can get the Weaviate schema using different clients.

  import weaviate

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

schema = client.schema.get()
print(schema)
  const weaviate = require("weaviate-client");

const client = weaviate.client({
  scheme: 'http',
  host: 'localhost:8080',
});

client
  .schema
  .getter()
  .do()
  .then(res => {
    console.log(res);
  })
  .catch(err => {
    console.error(err)
  });
  package main

import (
  "context"
  "fmt"

  "github.com/semi-technologies/weaviate-go-client/v4/weaviate"
)

func main() {
  cfg := weaviate.Config{
    Host:   "localhost:8080",
    Scheme: "http",
  }
  client := weaviate.New(cfg)

  schema, err := client.Schema().Getter().Do(context.Background())
  if err != nil {
    panic(err)
  }
  fmt.Printf("%v", schema)
}
  package technology.semi.weaviate;

import technology.semi.weaviate.client.Config;
import technology.semi.weaviate.client.WeaviateClient;
import technology.semi.weaviate.client.base.Result;
import technology.semi.weaviate.client.v1.schema.model.Schema;

public class App {
  public static void main(String[] args) {
    Config config = new Config("http", "localhost:8080");
    WeaviateClient client = new WeaviateClient(config);

    Result<Schema> result = client.schema().getter().run();

    if (result.hasErrors()) {
      System.out.println(result.getError());
      return;
    }
    System.out.println(result.getResult());
  }
}
  $ curl http://localhost:8080/v1/schema

Native vs GraphQL queries

When querying Weaviate you can choose to write your queries in GraphQL and send the raw GraphQL query to Weaviate or you can write the query natively to the client language you are using.

For example:

import weaviate

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

result = client.query.get("Article", ["title", "url", "wordCount"]).do()

print(result)

Yields the same result as:

import weaviate

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

query = """
{
  Get {
    Article {
      title
      url
      wordCount
    }
  }
}
"""

result = client.query.raw(query)

print(result)

Installation

Clients have their own installation pages per language.

Currently Weaviate supports:

Recapitulation

Weaviate clients are an easy way to connect with your Weaviate instance or cluster through a language of choice. Some users prefer to use a client and others prefer to connect directly with the APIs directly. Both are possible.

What would you like to learn next?

More Resources

If you can’t find the answer to your question here, please look at the:

  1. Frequently Asked Questions. Or,
  2. Knowledge base of old issues. Or,
  3. For questions: Stackoverflow. Or,
  4. For issues: Github. Or,
  5. Ask your question in the Slack channel: Slack.