Go SDK
Official Go SDK for Anakin (anakin.io)
Official Go module for the Anakin API. Wraps every documented endpoint with a single blocking call, internal polling, and a typed error hierarchy. Zero runtime dependencies — pure stdlib HTTP.
| Status | Alpha (v0.1.x) |
| Language | Go 1.21+ |
| Module | github.com/Anakin-Inc/anakin-go on pkg.go.dev |
| Source | github.com/Anakin-Inc/anakin-go |
| License | Apache 2.0 |
Install
go get github.com/Anakin-Inc/anakin-goRequires Go 1.21+.
Quickstart
package main
import (
"context"
"fmt"
"github.com/Anakin-Inc/anakin-go"
)
func main() {
client, err := anakin.New(anakin.WithAPIKey("ak-...")) // or set ANAKIN_API_KEY
if err != nil {
panic(err)
}
// Scrape a single URL — returns the final result, no polling required
doc, err := client.Scrape(context.Background(), "https://example.com")
if err != nil {
panic(err)
}
fmt.Println(doc.Markdown)
// Discover URLs on a site
sitemap, err := client.Map(context.Background(), "https://example.com")
if err != nil {
panic(err)
}
fmt.Println(sitemap.Links)
}What's in v0.1
| Method | Returns |
|---|---|
client.Scrape(ctx, url, opts...) | *Document |
client.Map(ctx, url, opts...) | *MapResult |
client.Crawl(ctx, url, opts...) | *CrawlResult |
client.Search(ctx, prompt, opts...) | *SearchResult (synchronous API) |
client.AgenticSearch(ctx, prompt, opts...) | *AgenticSearchResult |
client.Wire(ctx, actionID, params) | *WireResult (run a Wire action) |
client.Sessions().List / Create / Save / Update / Delete | Browser session CRUD |
anakin.SupportedCountries() | []Country (static, bundled, no network call) |
Configuration
client, err := anakin.New(
anakin.WithAPIKey("ak-..."), // or ANAKIN_API_KEY env var
anakin.WithBaseURL("https://api.anakin.io/v1"),
anakin.WithTimeout(60 * time.Second), // per-request HTTP timeout
anakin.WithMaxRetries(4), // retries on 429 / 5xx
anakin.WithPollInterval(1 * time.Second), // initial polling delay
anakin.WithPollMaxInterval(10 * time.Second), // cap on exponential backoff
anakin.WithPollTimeout(5 * time.Minute), // total wait before JobTimeoutError
)Errors
Every error returned by the SDK is a typed concrete value. Match with errors.As:
import "errors"
doc, err := client.Scrape(ctx, "https://example.com")
var creditsErr *anakin.InsufficientCreditsError
var authErr *anakin.AuthenticationError
var rlErr *anakin.RateLimitError
var jobErr *anakin.JobFailedError
switch {
case errors.As(err, &creditsErr):
fmt.Printf("out of credits: balance=%d, needed=%d\n", creditsErr.Balance, creditsErr.Required)
case errors.As(err, &authErr):
fmt.Println("invalid API key — get a fresh one at anakin.io/dashboard")
case errors.As(err, &rlErr):
fmt.Printf("rate limited; retry after %s\n", rlErr.RetryAfter)
case errors.As(err, &jobErr):
fmt.Printf("job failed: %s\n", jobErr.Reason)
case err != nil:
fmt.Printf("unknown error: %v\n", err)
}The error hierarchy:
| Type | When |
|---|---|
*AuthenticationError | 401 — invalid or missing API key |
*InsufficientCreditsError | 402 — out of credits (.Balance, .Required) |
*InvalidRequestError | 400 — validation failure |
*RateLimitError | 429 — after retry budget exhausted (.RetryAfter) |
*JobFailedError | Polled job came back with status="failed" (.Reason) |
*JobTimeoutError | Polling budget exhausted before terminal status |
*ServerError | 5xx — after retries exhausted |
*NetworkError | DNS / connect / read-timeout (.Cause) |
*APIError | Base type; everything above embeds it |
Stability
v0.1.x is alpha. The public API may change between minor versions until v1.0. Pin a specific version in production:
go get github.com/Anakin-Inc/anakin-go@v0.1.0Full reference docs and examples are on pkg.go.dev.
Raise issues on GitHub.