
Pure Python REST client, using httpx (sync and async), for the SeekStorm vector & lexical search server.
seekstorm_client_pure_py is open source licensed under the Apache License 2.0
Website | Benchmark | Demo | Repository for SeekStorm Python client | Repository for SeekStorm library, server, Rust client | Roadmap | Blog | X
pip install seekstorm-client-pure-pyfrom seekstorm_client import (
SeekStorm,
CreateIndexRequest,
IndexConfig,
SearchRequestObject,
)
BASE_URL = "http://127.0.0.1:80"
DEMO_API_KEY = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="
client = SeekStorm(base_url=BASE_URL, apikey_base64=DEMO_API_KEY)
schema = [
{"field": "title", "field_type": "Text", "store": True, "index_lexical": True},
{"field": "body", "field_type": "Text", "store": True, "index_lexical": True, "longest": True},
{"field": "url", "field_type": "Text", "store": True, "index_lexical": False},
]
create_request = CreateIndexRequest(
index_config=IndexConfig(
name="demo_index",
lexical_similarity="Bm25f",
tokenizer="UnicodeAlphanumeric",
stemmer="None",
document_compression="Snappy",
ngram_indexing=0,
),
schema=schema,
)
index_id = client.create_index(create_request).index_id
client.index_document(index_id, {"title": "title1", "body": "hello seekstorm", "url": "https://example.org"})
client.commit_index(index_id)
query = SearchRequestObject(query_string="+hello +seekstorm", offset=0, length=10)
result = client.query_index(index_id, query)
print(result.count_total)
client.delete_index(index_id)
client.close()import asyncio
from seekstorm_client import AsyncSeekStorm, CreateIndexRequest, IndexConfig, SearchRequestObject
async def main() -> None:
client = AsyncSeekStorm(base_url="http://127.0.0.1:80", apikey_base64="AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=")
request = CreateIndexRequest(
index_config=IndexConfig(
name="demo_async_index",
),
schema=[
{"field": "title", "field_type": "Text", "store": True, "index_lexical": True},
{"field": "body", "field_type": "Text", "store": True, "index_lexical": True},
],
)
index_id = (await client.create_index(request)).index_id
await client.index_document(index_id, {"title": "async", "body": "hello"})
await client.commit_index(index_id)
result = await client.query_index(index_id, SearchRequestObject(query_string="+hello"))
print(result.count_total)
await client.delete_index(index_id)
await client.close()
asyncio.run(main())The SearchResultObject returned from query_index() contains two separate fields:
-
results: A list ofSearchResultitems (always returned), each containing:doc_id: Document identifierscore: Relevance score for the document
-
documents: A list of fullDocumentobjects (only returned ifreturn_documentsis specified in the search request)
To retrieve full documents during a search, specify the return_documents parameter with a DocumentOption:
from seekstorm_client import SearchRequestObject, DocumentOption
# Search without documents (lightweight)
query = SearchRequestObject(query_string="+hello")
result = client.query_index(index_id, query)
print(f"Found {len(result.results)} results") # results contains only doc_id and score
# Search with full documents
query = SearchRequestObject(
query_string="+hello",
return_documents=DocumentOption(fields=["title", "body"])
)
result = client.query_index(index_id, query)
print(f"Found {len(result.results)} results")
print(f"Retrieved {len(result.documents)} documents") # now documents are populated
for doc in result.documents:
print(doc) # full document payloadsThe client exposes typed dataclasses for common request/response objects.
Request dataclasses:
ApikeyQuotaObjectCreateIndexRequestDocumentOptionDeleteApikeyRequestGetDocumentRequestGetIteratorRequestIndexConfigSearchRequestObjectUpdateDocumentRequestUpdateDocumentsRequest
Response dataclasses:
LiveResponseApiKeyResponseRemainingApiKeysResponseApikeyInfoResponseCreateIndexResponseRemainingIndicesResponseIndexedDocumentCountResponseIndexResponseObjectIteratorResultItemIteratorResultDocumentResponsePdfResponseSearchResultObjectSearchResult(TypedDict containing doc_id and score)
Error type:
SeekStormApiError(containsstatus_codeandbody)
The client supports API key lifecycle endpoints, including create_apikey.
REST routes:
POST /api/v1/apikey->create_apikey(...)GET /api/v1/apikey->get_apikey_info(...)DELETE /api/v1/apikey->delete_apikey(...)
Sync example:
from seekstorm_client import SeekStorm, ApikeyQuotaObject
client = SeekStorm(base_url="http://127.0.0.1:80")
master_key = "/iWStCpyfpd/BVlHOFtwnMgrFrmof4jGq/OQDWXQzcM="
quota = ApikeyQuotaObject(
indices_max=10,
indices_size_max=100_000_000_000,
documents_max=100_000_000,
operations_max=1_000_000_000,
rate_limit=None,
demo=True,
)
created = client.create_apikey(master_key, quota)
print(created.api_key_base64)
info = client.get_apikey_info(apikey_base64=created.api_key_base64)
print(len(info.indices))
remaining = client.delete_apikey(created.api_key_base64, master_key)
print(remaining.remaining_api_keys)
client.close()SeekStorm(base_url: str, apikey_base64: str | None = None, timeout: float = 30.0)All endpoint methods accept an optional base_url: str | None = None parameter to override the client default host for that single request.
API key endpoints:
live() -> LiveResponsecreate_apikey(master_apikey: str, api_key_quota_object: ApikeyQuotaObject) -> ApiKeyResponsedelete_apikey(apikey_base64: str, master_apikey_base64: str) -> RemainingApiKeysResponseget_apikey_info(apikey_base64: str | None = None) -> ApikeyInfoResponse
Index endpoints:
create_index(request: CreateIndexRequest, apikey_base64: str | None = None) -> CreateIndexResponsedelete_index(index_id: int, apikey_base64: str | None = None) -> RemainingIndicesResponseclear_index(index_id: int, apikey_base64: str | None = None) -> IndexedDocumentCountResponsecommit_index(index_id: int, apikey_base64: str | None = None) -> IndexedDocumentCountResponseget_index_info(index_id: int, apikey_base64: str | None = None) -> IndexResponseObject
Document endpoints:
index_document(index_id: int, document: dict, apikey_base64: str | None = None) -> IndexedDocumentCountResponseindex_documents(index_id: int, documents: Sequence[dict], apikey_base64: str | None = None) -> IndexedDocumentCountResponseindex_pdf(index_id: int, file_path: str | Path, file_date: int, document: bytes, apikey_base64: str | None = None) -> IndexedDocumentCountResponseget_pdf(index_id: int, doc_id: int, apikey_base64: str | None = None) -> PdfResponseget_document(index_id: int, doc_id: int, request: GetDocumentRequest, apikey_base64: str | None = None) -> DocumentResponseupdate_document(index_id: int, request: UpdateDocumentRequest, apikey_base64: str | None = None) -> IndexedDocumentCountResponseupdate_documents(index_id: int, request: UpdateDocumentsRequest, apikey_base64: str | None = None) -> IndexedDocumentCountResponsedelete_document_by_docid(index_id: int, doc_id: int, apikey_base64: str | None = None) -> IndexedDocumentCountResponsedelete_documents_by_docid(index_id: int, doc_id_vec: Sequence[int], apikey_base64: str | None = None) -> IndexedDocumentCountResponsedelete_documents_by_query(index_id: int, query: SearchRequestObject, apikey_base64: str | None = None) -> IndexedDocumentCountResponsedocument_iterator(index_id: int, request: GetIteratorRequest, apikey_base64: str | None = None) -> IteratorResultquery_index(index_id: int, request: SearchRequestObject, apikey_base64: str | None = None) -> SearchResultObject
AsyncSeekStorm exposes the same endpoint methods as SeekStorm, but all methods are async and must be awaited.
Make sure the SeekStorm server is running before running tests.
Optional environment variables:
SEEKSTORM_BASE_URL(default:http://127.0.0.1:80)SEEKSTORM_API_KEY(default: demo key)SEEKSTORM_MASTER_API_KEY(default in tests is set to the known local dev master key)
Run sync tests:
python -m unittest -v test_client.pyRun async tests:
python -m unittest -v test_async_client.pyRun both suites in one command:
python -m unittest -v test_client.py test_async_client.py