Skip to main content

Barq SDK Python

Official Python client for Barq DB - a high-performance vector database.

Installation

pip install barq-sdk-python

Quick Start

HTTP Client

from barq import BarqClient

# Initialize client
client = BarqClient("http://localhost:8080", api_key="your-api-key")

# Check health
if client.health():
    print("Connected!")

# Create a collection
client.create_collection(
    name="documents",
    dimension=384,
    metric="L2"
)

# Insert a document
client.insert_document(
    collection="documents",
    id=1,
    vector=[0.1] * 384,
    payload={"title": "Hello World"}
)

# Search
results = client.search(
    collection="documents",
    vector=[0.1] * 384,
    top_k=5
)

for result in results:
    print(f"ID: {result['id']}, Score: {result['score']}")

client.close()

gRPC Client

from barq import GrpcClient

# Initialize gRPC client
client = GrpcClient("localhost:50051")

# Check health
if client.health():
    print("Connected via gRPC!")

# Create collection
client.create_collection(
    name="documents",
    dimension=384,
    metric="L2"
)

# Insert document
client.insert_document(
    collection="documents",
    id="doc1",
    vector=[0.1] * 384,
    payload={"title": "Hello World"}
)

# Search
results = client.search(
    collection="documents",
    vector=[0.1] * 384,
    top_k=5
)

for result in results:
    print(f"ID: {result['id']}, Score: {result['score']}")

API Reference

BarqClient (HTTP)

Method Description
health() Check server health
create_collection(name, dimension, metric, index, text_fields) Create a new collection
insert_document(collection, id, vector, payload) Insert a document
search(collection, vector, query, top_k, filter) Search for similar vectors
close() Close the client connection

GrpcClient

Method Description
health() Check server health
create_collection(name, dimension, metric) Create a new collection
insert_document(collection, id, vector, payload) Insert a document
search(collection, vector, top_k) Search for similar vectors

Requirements

  • Python >= 3.8
  • httpx >= 0.23
  • grpcio >= 1.50.0
  • protobuf >= 4.21.0

License

MIT License - see LICENSE for details.

Metadata

Release files for barq-sdk-python 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for barq-sdk-python 0.1.0
File Size Uploaded
barq_sdk_python-0.1.0.tar.gz 4.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for barq-sdk-python 0.1.0
File Interpreter ABI Platform
barq_sdk_python-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 11.0 kB

Release files / barq_sdk_python-0.1.0.tar.gz

Download URL barq_sdk_python-0.1.0.tar.gz
Size 4.8 kB
Tags Source
SHA-256 checksum
How to use checksums
ac12f14aa5d9beedcf8baae54bc7dc7a14098db5a6a48cf60d798258ed58b0b6
BLAKE2b-256 checksum
How to use checksums
7790a3e4c5b8036a11b3c8a321f76a533bf47421121b0300f427435f0d4270fd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.14

Release files / barq_sdk_python-0.1.0-py3-none-any.whl

Download URL barq_sdk_python-0.1.0-py3-none-any.whl
Size 6.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d4a59d7cb5b6e5f9eece350dd93db855201e96faefeae41d84c48c88e071cacd
BLAKE2b-256 checksum
How to use checksums
86a3406029782abf6d3826ddf4b219ea91fe82d38354c570ec1b941e3e428f85
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.14

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page