Skip to main content

Official Python client for Torque — Truespar's in-memory search engine with a Typesense v30.1 compatible API. Zero external dependencies.

Project description

torque-http

Official Python client for Torque — Truespar's in-memory search engine with a Typesense v30.1 compatible API.

  • Zero external dependencies — uses only the Python standard library
  • HTTP API for search, collection management, and document CRUD
  • TCP binary ingest for high-throughput streaming from databases
  • TQBF file upload for bulk import
  • Multi-node failover with automatic retry
  • Typed search parameters and response models
  • Python 3.10+

Installation

pip install torque-http

Quick Start

from torque_http import TorqueHttpClient, SearchParameters

client = TorqueHttpClient("http://localhost:8108", api_key="your-key")

# Search
results = client.search("products", q="laptop", query_by="title")
for hit in results.hits:
    print(hit.document["title"])

# Typed parameters
params = SearchParameters(
    q="laptop",
    query_by="title,description",
    filter_by="price:>100",
    per_page=20,
)
results = client.search("products", params)

Multi-node with failover

client = TorqueHttpClient(
    ["http://node1:8108", "http://node2:8108"],
    api_key="your-key",
    num_retries=5,
)

Collection management

schema = {
    "name": "products",
    "fields": [
        {"name": "title", "type": "string"},
        {"name": "price", "type": "float", "sort": True},
        {"name": "brand", "type": "string", "facet": True},
    ],
}
client.create_collection(schema)

client.create_document("products", {
    "id": "1", "title": "Laptop Pro", "price": 1299.99, "brand": "Acme",
})

High-throughput TCP ingest

For streaming 100K+ documents, use the binary TCP protocol:

from torque_http import TorqueIngestClient, DocumentEncoder

schema = {"fields": [
    {"name": "title", "type": "string"},
    {"name": "price", "type": "float"},
]}
encoder = DocumentEncoder(schema)

with TorqueIngestClient() as tcp:
    tcp.connect("localhost", 8109)
    tcp.start_ingest("products")
    tcp.send_batch(documents, encoder)
    tcp.commit()

TQBF bulk file import

Pre-encode a compressed binary file for maximum throughput:

from torque_http import TorqueBinaryFileWriter, DocumentEncoder

encoder = DocumentEncoder(schema)
with TorqueBinaryFileWriter("data.tqbf", encoder) as writer:
    for doc in source:
        writer.write(doc)

client.import_binary("products", "data.tqbf")

Documentation

License

Copyright 2025-2026 Truespar. All rights reserved. See LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

torque_http-0.6.0.tar.gz (26.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

torque_http-0.6.0-py3-none-any.whl (28.3 kB view details)

Uploaded Python 3

File details

Details for the file torque_http-0.6.0.tar.gz.

File metadata

  • Download URL: torque_http-0.6.0.tar.gz
  • Upload date:
  • Size: 26.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for torque_http-0.6.0.tar.gz
Algorithm Hash digest
SHA256 f97a4b123add3a91f3e0edb0f2f1ee1bfc26f3489a1ce9264e4b7d9e30b1eee1
MD5 a4214366cfb811f78316f94cfd814856
BLAKE2b-256 b64f8cb8e113cff0daa9095375909978271b9919b415e00c737b3a9ef326595c

See more details on using hashes here.

File details

Details for the file torque_http-0.6.0-py3-none-any.whl.

File metadata

  • Download URL: torque_http-0.6.0-py3-none-any.whl
  • Upload date:
  • Size: 28.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for torque_http-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d67901d02b279e9e054edcaa16027652642264be393f6f9b58c24a5910f328a7
MD5 e3563650abcd873bb7ed9bb8a81eddd9
BLAKE2b-256 bafa064946aecf9f2450b046575eb59b5cb125610299517f9ee09e0cbcc9a72c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page