Rust SDK
Official Rust SDK for Anakin (anakin.io)
Official Rust crate for the Anakin API. Wraps every documented endpoint with a single async call, internal polling, and a strongly typed Error enum. Built on reqwest (rustls-tls) and tokio.
| Status | Alpha (v0.1.x) |
| Language | Rust 1.70+ |
| Crate | anakin-sdk on crates.io |
| Docs | docs.rs/anakin-sdk (auto-generated) |
| Source | github.com/Anakin-Inc/anakin-rust |
| License | Apache 2.0 |
Install
Add to your Cargo.toml:
[dependencies]
anakin-sdk = "0.1"
tokio = { version = "1", features = ["full"] }The import name is anakin (crate name on crates.io is anakin-sdk).
Quickstart
use anakin::Client;
#[tokio::main]
async fn main() -> anakin::Result<()> {
let client = Client::builder()
.api_key("ak-...") // or set ANAKIN_API_KEY
.build()?;
// Scrape a single URL — returns the final result, no polling required
let doc = client.scrape("https://example.com").await?;
println!("{}", doc.markdown.unwrap_or_default());
// Discover URLs on a site
let sitemap = client.map("https://example.com").await?;
println!("{:?}", sitemap.links);
// Crawl pages and get content for each
let crawl = client.crawl("https://example.com").await?;
for page in &crawl.pages {
println!("{}: {} chars", page.url.as_deref().unwrap_or(""), page.markdown.as_deref().unwrap_or("").len());
}
Ok(())
}What's in v0.1
| Method | Returns |
|---|---|
client.scrape(url) / scrape_with(url, opts) | Result<Document> |
client.map(url) / map_with(url, opts) | Result<MapResult> |
client.crawl(url) / crawl_with(url, opts) | Result<CrawlResult> |
client.search(query) / search_with(query, opts) | Result<SearchResult> (synchronous API) |
client.agentic_search(prompt) / agentic_search_with(...) | Result<AgenticSearchResult> |
client.wire(action_id, params) | Result<WireResult> (run a Wire action) |
client.sessions().list / create / save / update / delete | Browser session CRUD |
anakin::supported_countries() | &'static [(&'static str, &'static str)] (bundled, no network call) |
Extra opts can be passed as Some(serde_json::json!({ "key": "value" })).
Configuration
use std::time::Duration;
let client = anakin::Client::builder()
.api_key("ak-...") // or ANAKIN_API_KEY env var
.base_url("https://api.anakin.io/v1")
.timeout(Duration::from_secs(60)) // per-request HTTP timeout
.max_retries(4) // retries on 429 / 5xx
.poll_interval(Duration::from_secs(1)) // initial polling delay
.poll_max_interval(Duration::from_secs(10)) // cap on exponential backoff
.poll_timeout(Duration::from_secs(300)) // total wait before JobTimeout
.build()?;You can also inject a pre-built reqwest::Client via .http_client(c) for custom proxy or TLS configuration.
Errors
All errors come back as variants of anakin::Error:
use anakin::Error;
match client.scrape("https://example.com").await {
Ok(doc) => println!("{}", doc.markdown.unwrap_or_default()),
Err(Error::InsufficientCredits { balance, required, .. }) => {
eprintln!("out of credits: balance={balance}, needed={required}");
}
Err(Error::Authentication { .. }) => {
eprintln!("invalid API key — get a fresh one at anakin.io/dashboard");
}
Err(Error::RateLimit { retry_after, .. }) => {
eprintln!("rate limited; retry after {retry_after:?}");
}
Err(Error::JobFailed { reason, .. }) => {
eprintln!("job failed: {reason}");
}
Err(e) => eprintln!("unknown error: {e}"),
}The error enum:
| Variant | When |
|---|---|
Error::Authentication | 401 — invalid or missing API key |
Error::InsufficientCredits | 402 — out of credits (balance, required) |
Error::InvalidRequest | 400 — validation failure |
Error::RateLimit | 429 — after retry budget exhausted (retry_after) |
Error::JobFailed | Polled job came back with status="failed" (reason) |
Error::JobTimeout | Polling budget exhausted before terminal status |
Error::Server | 5xx — after retries exhausted |
Error::Network | DNS / connect / read-timeout |
Error::Other | Decoding failures, missing fields |
Stability
v0.1.x is alpha. The public API may change between minor versions until v1.0. Pin a specific version in production:
anakin-sdk = "=0.1.0"Full reference docs and examples are on docs.rs.
Raise issues on GitHub.