Skip to main content

torque-http

The Python client for Torque, an in-memory search engine with a Typesense-compatible API.

  • Standard library only, no dependencies
  • HTTP API: search, collections, documents, keys, aliases
  • TCP ingest (TorqueIngestClient) for streaming documents
  • Binary import files (TorqueBinaryFileWriter) for bulk loads
  • Several nodes, with failover and retries
  • 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)

Several nodes

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

Collections and documents

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",
})

TCP ingest

For large loads, stream over the TCP ingest 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()

Binary import file

Write the documents to a compressed file, then upload it in one request:

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

MIT OR Apache-2.0, at your option. See LICENSE. Copyright 2025-2026 The Intelligence Company AB (publ).

Metadata

Release files for torque-http 0.7.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 torque-http 0.7.0
File Size Uploaded Provenance Actions
torque_http-0.7.0.tar.gz 27.2 kB Without provenance Details for torque_http-0.7.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for torque-http 0.7.0
File Interpreter ABI Platform Actions
torque_http-0.7.0-py3-none-any.whl Python 3 none any Details for torque_http-0.7.0-py3-none-any.whl

Total release size: 55.8 kB

Release files / torque_http-0.7.0.tar.gz

Download URL torque_http-0.7.0.tar.gz
Size 27.2 kB
Tags Source
SHA-256 checksum
How to use checksums
79350d500a3cee79bbe738df35fd16f0b962a22ac04b6afce618fbe8ec1dadb6
BLAKE2b-256 checksum
How to use checksums
ff791118920cf8e8f32b786a710d693961f18aa5faf0e30d18ef7b2d74444612
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.3

Release files / torque_http-0.7.0-py3-none-any.whl

Download URL torque_http-0.7.0-py3-none-any.whl
Size 28.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a15ee586c663ca9561fda3ee56122bb5b089f5bcba5c3bbf1d14d141c04cf2a8
BLAKE2b-256 checksum
How to use checksums
0f1579cf072688aff6f935592fbf42fad7331de8853d7b93c13cc2e2c5686e67
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.3

Security for torque-http 0.7.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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