SDKs#

Antfly provides type-safe client libraries for Go, TypeScript, Python, and Rust. All SDKs are auto-generated from the OpenAPI specification and kept in sync with every release.

LanguagePackageRegistrySource
Gogithub.com/antflydb/antfly/go/pkg/sdkpkg.go.devGitHub
TypeScript@antfly/sdknpmGitHub
Pythonantfly-sdkPyPIGitHub
Rustantfly-sdksourceGitHub

Embedded Lite Binding#

Antfly Lite embeds Antfly directly in an application process with a live .aflite database file. The first Lite binding above Zig and C is Go:

go get github.com/antflydb/antfly/go/pkg/antflylite

The Lite binding is separate from the network SDK. Use github.com/antflydb/antfly/go/pkg/sdk for a running Antfly service and github.com/antflydb/antfly/go/pkg/antflylite for embedded local databases.

See the Antfly Lite guide for CLI and Go embedded examples, and the Antfly Lite migration guide for backup, restore, and promotion workflows.

Installation#

go get github.com/antflydb/antfly/go/pkg/sdk

Authentication#

All three authentication methods are supported across SDKs: basic auth, API key, and token.

Basic Auth#

antfly "github.com/antflydb/antfly/go/pkg/sdk"

client, err := antfly.NewAntflyClientWithOptions(
	"http://localhost:8080",
	antfly.WithBasicAuth("admin", "password"),
)

API Key#

client, err := antfly.NewAntflyClientWithOptions(
	"http://localhost:8080",
	antfly.WithApiKey("key-id", "key-secret"),
)

Token#

client, err := antfly.NewAntflyClientWithOptions(
	"http://localhost:8080",
	antfly.WithToken("your-token"),
)

Quick Start#

Insert Documents#

import (
	"context"
	antfly "github.com/antflydb/antfly/go/pkg/sdk"
)

client, err := antfly.NewAntflyClientWithOptions(
	"http://localhost:8080",
	antfly.WithBasicAuth("admin", "password"),
)
if err != nil {
	log.Fatal(err)
}

// Batch insert documents
resp, err := client.BatchTableWithResponse(
	context.Background(),
	"products",
	antfly.BatchTableJSONRequestBody{
		Inserts: &map[string]interface{}{
			"prod:001": map[string]interface{}{
				"name":  "Laptop",
				"price": 1299.99,
			},
			"prod:002": map[string]interface{}{
				"name":  "Mouse",
				"price": 29.99,
			},
		},
	},
)

Query#

resp, err := client.QueryWithResponse(
	context.Background(),
	antfly.QueryJSONRequestBody{
		Table: strPtr("products"),
		FullTextSearch: &antfly.FullTextSearch{
			Query: strPtr("laptop"),
		},
		Limit: intPtr(10),
	},
)
if err != nil {
	log.Fatal(err)
}

for _, hit := range resp.JSON200.Hits {
	fmt.Printf("%s: %v\n", hit.Key, hit.Fields)
}

React Components#

For building search UIs, Antfly provides @antfly/components — a React component library with search boxes, facets, result lists, RAG answer boxes, and more. See the React Antfly documentation for details.

npm install @antfly/components @antfly/sdk