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/antfly | pkg.go.dev | GitHub |
| TypeScript | @antfly/sdk | npm | GitHub |
| Python | antfly-sdk | PyPI | GitHub |
| Rust | antfly-client | crates.io | GitHub |
Installation
go get github.com/antflydb/antfly-go/antflynpm install @antfly/sdkpip install antfly-sdk# Cargo.toml
[dependencies]
antfly-client = "0.1"Authentication
All three authentication methods are supported across SDKs: basic auth, API key, and bearer token.
Basic Auth
import "github.com/antflydb/antfly-go/antfly"
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_client::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_client::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(),
);Bearer Token
client, err := antfly.NewAntflyClientWithOptions(
"http://localhost:8080",
antfly.WithBearerToken("your-token"),
)const client = new AntflyClient({
baseUrl: 'http://localhost:8080',
auth: {
type: 'bearer',
token: 'your-token',
},
});client = AntflyClient(
base_url='http://localhost:8080',
bearer_token='your-token',
)use antfly_client::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"
"github.com/antflydb/antfly-go/antfly"
)
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_client::Client;
use antfly_client::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_client::Client;
use antfly_client::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