Skip to content

antflydb/antfly-python

Repository files navigation

Antfly Python SDK

PyPI version Python

Python SDK for Antfly - a distributed key-value store and search engine.

For the nightly version, visit the TestPyPI page.

Installation

pip install antfly-sdk

Quick Start

from antfly import AntflyClient

# Initialize client
client = AntflyClient(
    base_url="http://localhost:8080",
    username="admin",
    password="password"
)

# Create a table
client.create_table(
    name="users",
    num_shards=4,
    schema={
        "key": "user_id",
        "document_types": {
            "user": {
                "fields": {
                    "name": {"type": "string"},
                    "email": {"type": "keyword"},
                    "age": {"type": "int"},
                    "created_at": {"type": "time"}
                }
            }
        }
    }
)

# Insert data
client.batch(
    table="users",
    inserts={
        "user:1": {
            "name": "John Doe",
            "email": "[email protected]",
            "age": 30
        },
        "user:2": {
            "name": "Jane Smith",
            "email": "[email protected]",
            "age": 25
        }
    }
)

# Query data
results = client.query(
    table="users",
    full_text_search={"query": "John"},
    limit=10
)

# Get specific record
user = client.get(table="users", key="user:1")

Features

  • Simple API: Intuitive interface for all Antfly operations
  • Type Safety: Full type hints for better IDE support
  • Authentication: Built-in support for basic authentication
  • Error Handling: Comprehensive error handling with custom exceptions
  • Auto-generated Client: Based on OpenAPI specification for accuracy

Development

Setup

  1. Clone the repository
  2. Install development dependencies:
uv sync

Generate Client

The SDK uses an auto-generated client based on the Antfly OpenAPI specification:

make generate

Run Tests

make test

Build Package

make build

Documentation

make docs will generate the documentation in the docs/ folder.

Full documentation is available at https://antfly-sdk-python.readthedocs.io

License

Apache License 2.0

Warning

Some models cannot be autogenerated from the spec

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors