Classes

Client

Synchronous client for interacting with the TopK API. Methods Constructor
Client(
   api_key: str,
   region: str,
   host: str = "topk.io",
   https: bool = True,
   retry_config: Optional[RetryConfig] = None
)

collection()

collection(self, collection: str) -> CollectionClient
Get a client for managing data operations on a specific collection such as querying, upserting, and deleting documents. Parameters
ParameterType
collectionstr
Returns CollectionClient

collections()

collections(self) -> CollectionsClient
Get a client for managing collections. Returns CollectionsClient

AsyncClient

Asynchronous client for interacting with the TopK API. Methods Constructor
AsyncClient(
   api_key: str,
   region: str,
   host: str = "topk.io",
   https: bool = True,
   retry_config: Optional[RetryConfig] = None
)

collection()

collection(self, collection: str) -> AsyncCollectionClient
Get an async client for a specific collection. Parameters
ParameterType
collectionstr
Returns AsyncCollectionClient

collections()

collections(self) -> AsyncCollectionsClient
Get an async client for managing collections. Returns AsyncCollectionsClient

CollectionClient

Synchronous client for collection operations. Methods

get()

get(
   self,
   ids: Sequence[str],
   fields: Optional[Sequence[str]] = None,
   lsn: Optional[str] = None,
   consistency: Optional[ConsistencyLevel] = None
)
Get documents by their IDs. Parameters
ParameterType
idsSequence[str]
fieldsOptional[Sequence[str]]
lsnOptional[str]
consistencyOptional[ConsistencyLevel]
Returns dict[str, dict[str, Any]]

count()

count(self, lsn: Optional[str] = None, consistency: Optional[ConsistencyLevel] = None) -> int
Get the count of documents in the collection. Parameters
ParameterType
lsnOptional[str]
consistencyOptional[ConsistencyLevel]
Returns int

query()

query(
   self,
   query: query.Query,
   lsn: Optional[str] = None,
   consistency: Optional[ConsistencyLevel] = None
)
Execute a query against the collection. Parameters
ParameterType
queryquery.Query
lsnOptional[str]
consistencyOptional[ConsistencyLevel]
Returns list[dict[str, Any]]

upsert()

upsert(self, documents: Sequence[Mapping[str, Any]]) -> str
Insert or update documents in the collection. Parameters
ParameterType
documentsSequence[Mapping[str, Any]]
Returns str

delete()

delete(self, ids: Sequence[str]) -> str
Delete documents by their IDs. Parameters
ParameterType
idsSequence[str]
Returns str

AsyncCollectionClient

Asynchronous client for collection operations. Methods

get()

get(
   self,
   ids: Sequence[str],
   fields: Optional[Sequence[str]] = None,
   lsn: Optional[str] = None,
   consistency: Optional[ConsistencyLevel] = None
)
Get documents by their IDs asynchronously. Parameters
ParameterType
idsSequence[str]
fieldsOptional[Sequence[str]]
lsnOptional[str]
consistencyOptional[ConsistencyLevel]
Returns Awaitable[dict[str, dict[str, Any]]]

count()

count(
   self,
   lsn: Optional[str] = None,
   consistency: Optional[ConsistencyLevel] = None
)
Get the count of documents in the collection asynchronously. Parameters
ParameterType
lsnOptional[str]
consistencyOptional[ConsistencyLevel]
Returns Awaitable[int]

query()

query(
   self,
   query: query.Query,
   lsn: Optional[str] = None,
   consistency: Optional[ConsistencyLevel] = None
)
Execute a query against the collection asynchronously. Parameters
ParameterType
queryquery.Query
lsnOptional[str]
consistencyOptional[ConsistencyLevel]
Returns Awaitable[list[dict[str, Any]]]

upsert()

upsert(self, documents: Sequence[Mapping[str, Any]]) -> Awaitable[str]
Insert or update documents in the collection asynchronously. Parameters
ParameterType
documentsSequence[Mapping[str, Any]]
Returns Awaitable[str]

delete()

delete(self, ids: Sequence[str]) -> Awaitable[str]
Delete documents by their IDs asynchronously. Parameters
ParameterType
idsSequence[str]
Returns Awaitable[str]

Collection

Represents a collection in the TopK system. Properties
PropertyType
namestr
org_idstr
project_idstr
regionstr
schemadict[str, schema.FieldSpec]

CollectionsClient

Synchronous client for managing collections. Methods

get()

get(self, collection_name: str) -> Collection
Get information about a specific collection. Parameters
ParameterType
collection_namestr
Returns Collection

list()

list(self) -> list[Collection]
List all collections. Returns list[Collection]

create()

create(self, collection_name: str, schema: Mapping[str, schema.FieldSpec]) -> Collection
Create a new collection with the specified schema. Parameters
ParameterType
collection_namestr
schemaMapping[str, schema.FieldSpec]
Returns Collection

delete()

delete(self, collection_name: str) -> None
Delete a collection. Parameters
ParameterType
collection_namestr
Returns None

AsyncCollectionsClient

Asynchronous client for managing collections. Methods

get()

get(self, collection_name: str) -> Awaitable[Collection]
Get information about a specific collection asynchronously. Parameters
ParameterType
collection_namestr
Returns Awaitable[Collection]

list()

list(self) -> Awaitable[list[Collection]]
List all collections asynchronously. Returns Awaitable[list[Collection]]

create()

create(self, collection_name: str, schema: Mapping[str, schema.FieldSpec]) -> Awaitable[Collection]
Create a new collection with the specified schema asynchronously. Parameters
ParameterType
collection_namestr
schemaMapping[str, schema.FieldSpec]
Returns Awaitable[Collection]

delete()

delete(self, collection_name: str) -> Awaitable[None]
Delete a collection asynchronously. Parameters
ParameterType
collection_namestr
Returns Awaitable[None]

ConsistencyLevel

Enumeration of consistency levels for operations. Values
ValueDescription
Indexedindexed
Strongstrong

RetryConfig

Configuration for retry behavior. Properties
PropertyType
max_retriesOptional[int]
timeoutOptional[int]
backoffOptional[BackoffConfig]

BackoffConfig

Configuration for backoff behavior in retries. Properties
PropertyType
baseOptional[int]
init_backoffOptional[int]
max_backoffOptional[int]