zelf-sdk

module
v0.0.0-...-e8d770c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 18, 2026 License: Apache-2.0

README

Zelf SDKs

Official clients for the Zelf API in Python, TypeScript, Go, Rust, Ruby and C#. One spec, six clients, the same resources and method names in each.

Per-language detail lives in that language's own README: Python, TypeScript, Go, Rust, Ruby, C#.

Install

Language Install Import
Python pip install zelf-sdk from zelf import ZelfAPIClient
TypeScript npm install zelf-sdk import { ZelfAPIClient } from 'zelf-sdk'
Go go get github.com/hellozelf/zelf-sdk/go import zelf "github.com/hellozelf/zelf-sdk/go"
Rust cargo add zelf-sdk use zelf::Client
Ruby gem install zelf-sdk require 'zelf'
C# dotnet add package Zelf.Sdk using Zelf

The package is zelf-sdk; the import stays zelf wherever the two differ.

Authentication

Pass the key, or set ZELF_API_KEY and pass nothing. It is sent as the x-api-key header and never as a query parameter. Point a client at another deployment with the base URL option, or set ZELF_BASE_URL.

Python

client = ZelfAPIClient(api_key="sk_zelf_...")
client = ZelfAPIClient()                       # reads ZELF_API_KEY

TypeScript

const client = new ZelfAPIClient({ apiKey: 'sk_zelf_...' })

Go

client, err := zelf.New(zelf.WithAPIKey("sk_zelf_..."))

Rust

let client = Client::new("sk_zelf_...")?;

Ruby

client = Zelf::Client.new(api_key: 'sk_zelf_...')

C#

using var client = new ZelfClient("sk_zelf_...");

Calling the API

Operation ids read as resource.method, so content.list is client.content.list() in every language.

Python

page = client.content.list(search="running shoes", brand_id="brd_1")

TypeScript

const page = await client.content.list({ search: 'running shoes' })

Go

page, err := client.Content.List(ctx, &zelf.ContentListParams{Search: zelf.Ptr("running shoes")})

Rust

let page = client.content().list(ContentListParams {
    search: Some("running shoes".into()),
    ..Default::default()
}).await?;

Ruby

page = client.content.list(search: 'running shoes')

C#

var page = await client.Content.ListAsync(new ContentListParams { Search = "running shoes" });

Python also ships an async client with the same surface:

from zelf import ZelfAPIClientAsync

async with ZelfAPIClientAsync() as client:
    page = await client.content.list(brand_id="brd_1")

Pagination

A list call returns one page. Walking the rest takes one of three bounds: everything, at most N pages, or at most N items. The item bound never fetches a page it does not need.

Python

for item in page.auto_paging(max_pages=5):
    print(item.id)

TypeScript

for await (const item of page.autoPaging({ maxPages: 5 })) { }

Go

err = page.AutoPaging(ctx, visit, zelf.MaxPages(5))

Rust

let rows = page.collect_all(Limits::pages(5)).await?;

Ruby

page.auto_paging(max_pages: 5) { |item| }

C#

await foreach (var item in page.AutoPagingAsync(PageLimits.Pages(5))) { }

The envelope is on the page itself: page.item_count, page.page, page.applied_filters, page.log_id.

Errors

Every failure is a typed error carrying the status, the API's error code and the log_id to quote in a support request.

Python

try:
    client.content.details("con_nope")
except zelf.NotFoundError as error:
    print(error.status_code, error.code, error.log_id)
404 NOT_FOUND 0ca57078-d810-4038-a1d7-02953ac7ce60

TypeScript

try {
  await client.content.details('con_nope')
} catch (error) {
  if (error instanceof NotFoundError) console.log(error.status, error.code)
}

Go

_, err := client.Content.Details(ctx, "con_nope", nil)
var apiError *zelf.APIError
if errors.As(err, &apiError) {
    fmt.Println(apiError.Status, apiError.Code, apiError.LogID)
}

Rust

match client.content().details("con_nope", Default::default()).await {
    Err(error) if error.is_not_found() => {
        println!("{:?} {:?}", error.status(), error.code());
    }
    _ => {}
}

Ruby

begin
  client.content.details('con_nope')
rescue Zelf::NotFoundError => error
  puts error.status, error.code, error.log_id
end

C#

try
{
    await client.Content.DetailsAsync("con_nope");
}
catch (ZelfNotFoundException error)
{
    Console.WriteLine($"{error.Status} {error.Code} {error.LogId}");
}

The type follows the status: bad request, authentication, permission denied, not found, conflict, rate limit, internal server and service unavailable. Network problems raise a connection or timeout error instead, so a retry decision never has to parse a message.

Retries

A failed GET is retried twice by default, honouring Retry-After and otherwise backing off exponentially with jitter, capped at 8 seconds.

Writes are never retried. The API publishes no Idempotency-Key, so a retried detection.create would start a second billable run. Opt in per client if your call site can tolerate it:

Python

client = ZelfAPIClient(max_retries=5, retry_writes=True)

TypeScript

new ZelfAPIClient({ maxRetries: 5, retryWrites: true })

Go

zelf.New(zelf.WithMaxRetries(5), zelf.WithRetryWrites(true))

Rust

Client::builder().api_key("sk_zelf_...").max_retries(5).retry_writes(true).build()?;

Ruby

Zelf::Client.new(max_retries: 5, retry_writes: true)

C#

new ZelfClient(new ZelfClientOptions { MaxRetries = 5, RetryWrites = true });

Webhooks

verify checks the signature and returns the decoded payload. parse returns a typed event instead.

Python

from zelf import webhooks

event = webhooks.parse(request.body, request.headers, secret)
if event.event_type is webhooks.EventType.CONTENT_SNAPSHOT:
    for row in event.items:
        print(row["id"])

TypeScript

const event = webhooks.parse(body, headers, secret)

Go

event, err := webhooks.Parse(body, headers, []string{secret})

Rust

let event = webhooks::parse(body, &headers, secret)?;

Ruby

event = Zelf::Webhooks.parse(body, headers, secret)

C#

var webhookEvent = Webhooks.Parse(body, headers, secret);

Verification uses each language's constant-time comparison, enforces a 300 second timestamp window against replays, and accepts a list of secrets so a rotation does not drop deliveries.

A Handler verifies once and routes to the listener for the event type:

Python

handler = (
    webhooks.WebhookHandler(secret)
    .on(webhooks.EventType.CONTENT_SNAPSHOT, on_snapshot)
    .on_any(on_everything_else)
)
event = handler.handle(request.body, request.headers)

TypeScript

const handler = new webhooks.WebhookHandler(secret)
  .on(webhooks.EventType.ContentSnapshot, onSnapshot)
  .onAny(onEverythingElse)

Go

handler := webhooks.NewHandler([]string{secret}, webhooks.Options{}).
    On(onSnapshot, webhooks.EventContentSnapshot).
    OnAny(onEverythingElse)

For a manifest delivery, rows downloads the NDJSON files and verifies the published SHA-256 over each body before yielding anything.

Reports

A finished AI analysis, advanced AI analysis or creator vetting run points at a JSON report through result.download_url. Decode it as AiAnalysisReport, AdvancedAiAnalysisReport or CreatorVettingReport. Reports decode softly: a missing field or a null reads as null (or the zero value in Go and Rust), and a decimal in a whole number field never fails the decode.

Python

report = zelf.AdvancedAiAnalysisReport.model_validate_json(body)

TypeScript

const report = (await response.json()) as AdvancedAiAnalysisReport

Go

var report zelf.AdvancedAiAnalysisReport
err := json.Unmarshal(body, &report)

Rust

let report: zelf::AdvancedAiAnalysisReport = serde_json::from_slice(&body)?;

Ruby

report = Zelf::Models::AdvancedAiAnalysisReport.new(JSON.parse(body))

Java

AdvancedAiAnalysisReport report = ZelfReports.decode(body, AdvancedAiAnalysisReport.class);

C#

var report = ZelfReports.Decode<AdvancedAiAnalysisReport>(body);

Sandbox

A stub of the API, with canned data, for testing against. The key is public.

curl -H "x-api-key: sk_zelf_sandbox_demo" \
  "https://sandbox-api.hellozelf.com/api/v1/content/?page_size=3"
client = ZelfAPIClient(
    api_key="sk_zelf_sandbox_demo",
    base_url="https://sandbox-api.hellozelf.com",
)

Every client reads ZELF_BASE_URL, so pointing a test suite at it needs no code change:

export ZELF_BASE_URL=https://sandbox-api.hellozelf.com
export ZELF_API_KEY=sk_zelf_sandbox_demo

It returns the same response shapes and pagination as production, over canned data. Send x-sandbox-force-error: RATE_LIMIT_EXCEEDED to drive a retry path.

The sandbox is not a stand-in for production behaviour. It validates nothing, and it never reads a path parameter, so INVALID_ID and the other error cases cannot be reached there. Test error handling and validation against production.

Contributing

These clients are generated. See docs/contributing.md before changing anything under a language directory.

License

Apache-2.0. See LICENSE.

Directories

Path Synopsis
codegen
templates/go/webhooks
Package webhooks verifies the signature Zelf puts on every webhook delivery.
Package webhooks verifies the signature Zelf puts on every webhook delivery.
go module

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL