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.
| Language | Package | Registry | Source |
|---|---|---|---|
| Go | github.com/antflydb/antfly/go/pkg/sdk | pkg.go.dev | GitHub |
| TypeScript | @antfly/sdk | npm | GitHub |
| Python | antfly-sdk | PyPI | GitHub |
| Rust | antfly-sdk | source | GitHub |
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/sdknpm install @antfly/sdkpip install antfly-sdk# The Rust SDK is currently source-only.
# https://github.com/antflydb/antfly/tree/main/rs/crates/sdkAuthentication
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"),
)import { AntflyClient } from '@antfly/sdk';
const client = new AntflyClient({
baseUrl: 'http://localhost:8080',
auth: {
username: 'admin',
password: 'password',
},
});from antfly import AntflyClient
client = AntflyClient(
base_url='http://localhost:8080',
username='admin',
password='password',
)use antfly_sdk::Client;
let client = Client::new_with_client(
"http://localhost:8080",
reqwest::Client::builder()
.default_headers({
let mut h = reqwest::header::HeaderMap::new();
h.insert(
reqwest::header::AUTHORIZATION,
reqwest::header::HeaderValue::from_str(
&format!("Basic {}", base64::encode("admin:password"))
).unwrap(),
);
h
})
.build()
.unwrap(),
);API Key
client, err := antfly.NewAntflyClientWithOptions(
"http://localhost:8080",
antfly.WithApiKey("key-id", "key-secret"),
)const client = new AntflyClient({
baseUrl: 'http://localhost:8080',
auth: {
type: 'apiKey',
keyId: 'key-id',
keySecret: 'key-secret',
},
});client = AntflyClient(
base_url='http://localhost:8080',
api_key=('key-id', 'key-secret'),
)use antfly_sdk::Client;
let client = Client::new_with_client(
"http://localhost:8080",
reqwest::Client::builder()
.default_headers({
let mut h = reqwest::header::HeaderMap::new();
h.insert("X-Api-Key-Id", "key-id".parse().unwrap());
h.insert("X-Api-Key-Secret", "key-secret".parse().unwrap());
h
})
.build()
.unwrap(),
);Token
client, err := antfly.NewAntflyClientWithOptions(
"http://localhost:8080",
antfly.WithToken("your-token"),
)const client = new AntflyClient({
baseUrl: 'http://localhost:8080',
auth: {
type: 'token',
token: 'your-token',
},
});client = AntflyClient(
base_url='http://localhost:8080',
token='your-token',
)use antfly_sdk::Client;
let client = Client::new_with_client(
"http://localhost:8080",
reqwest::Client::builder()
.default_headers({
let mut h = reqwest::header::HeaderMap::new();
h.insert(
reqwest::header::AUTHORIZATION,
"Bearer your-token".parse().unwrap(),
);
h
})
.build()
.unwrap(),
);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,
},
},
},
)import { AntflyClient } from '@antfly/sdk';
const client = new AntflyClient({
baseUrl: 'http://localhost:8080',
auth: { username: 'admin', password: 'password' },
});
// Batch insert documents
await client.tables.batch('products', {
inserts: {
'prod:001': { name: 'Laptop', price: 1299.99 },
'prod:002': { name: 'Mouse', price: 29.99 },
},
});from antfly import AntflyClient
client = AntflyClient(
base_url='http://localhost:8080',
username='admin',
password='password',
)
# Batch insert documents
client.batch(
table='products',
inserts={
'prod:001': {'name': 'Laptop', 'price': 1299.99},
'prod:002': {'name': 'Mouse', 'price': 29.99},
},
)use antfly_sdk::Client;
use antfly_sdk::types::BatchTableBody;
use serde_json::json;
use std::collections::HashMap;
let client = Client::new("http://localhost:8080");
// Batch insert documents
let mut inserts = HashMap::new();
inserts.insert(
"prod:001".to_string(),
json!({"name": "Laptop", "price": 1299.99}),
);
inserts.insert(
"prod:002".to_string(),
json!({"name": "Mouse", "price": 29.99}),
);
client
.batch_table(
"products",
&BatchTableBody {
inserts: Some(inserts),
..Default::default()
},
)
.await?;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)
}const results = await client.query({
table: 'products',
full_text_search: { query: 'laptop' },
limit: 10,
});
for (const hit of results.hits) {
console.log(hit.key, hit.fields);
}results = client.query(
table='products',
full_text_search={'query': 'laptop'},
limit=10,
)
for hit in results.hits:
print(hit.key, hit.fields)use antfly_sdk::Client;
use antfly_sdk::types::{GlobalQueryBody, FullTextSearch};
let client = Client::new("http://localhost:8080");
let resp = client
.global_query(&GlobalQueryBody {
table: Some("products".to_string()),
full_text_search: Some(FullTextSearch {
query: Some("laptop".to_string()),
..Default::default()
}),
limit: Some(10),
..Default::default()
})
.await?;
let results = resp.into_inner();
for response in &results.responses {
if let Some(hits) = &response.hits {
for hit in &hits.hits {
println!("{}: {:?}", hit.id, hit.source);
}
}
}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