Skip to Content
APISDKs

SDKs

Official SDKs make it easy to integrate with the Avala API.

Python SDK

Installation

pip install avala

Quick Start

from avala import Client # Initialize client client = Client(api_key="your-api-key") # List datasets datasets = client.datasets.list() for ds in datasets: print(f"{ds.uid}: {ds.name}") # Get a specific dataset dataset = client.datasets.get("owner", "dataset-slug") # List dataset items items = client.datasets.list_items("owner", "dataset-slug")

Async Support

import asyncio from avala import AsyncClient async def main(): client = AsyncClient(api_key="your-api-key") datasets = await client.datasets.list() for ds in datasets: print(ds.name) asyncio.run(main())

Type Hints

The Python SDK includes full type hints for IDE support:

from avala import Client from avala.types import Dataset, Project client = Client() dataset: Dataset = client.datasets.get("owner", "slug") projects: list[Project] = client.projects.list()

TypeScript SDK

Installation

npm install @avala/sdk # or yarn add @avala/sdk # or pnpm add @avala/sdk

Quick Start

import { Avala } from '@avala/sdk' // Initialize client const client = new Avala({ apiKey: 'your-api-key' }) // List datasets const datasets = await client.datasets.list() for (const ds of datasets.results) { console.log(`${ds.uid}: ${ds.name}`) } // Get a specific dataset const dataset = await client.datasets.get('owner', 'dataset-slug') // List projects const projects = await client.projects.list({ status: 'ACTIVE' })

TypeScript Types

Full TypeScript types are included:

import type { Dataset, Project, DatasetItem } from '@avala/sdk' const dataset: Dataset = await client.datasets.get('owner', 'slug') const items: DatasetItem[] = await client.datasets.listItems('owner', 'slug')

Environment Variables

Both SDKs support environment variables:

VariableDescription
AVALA_API_KEYAPI key for authentication
AVALA_BASE_URLCustom API base URL (default: https://server.avala.ai/api/v1)
AVALA_TIMEOUTRequest timeout in seconds
export AVALA_API_KEY=your-api-key
# Client automatically uses AVALA_API_KEY client = Client()

Error Handling

from avala import Client from avala.exceptions import AvalaError, NotFoundError, RateLimitError client = Client() try: dataset = client.datasets.get("owner", "nonexistent") except NotFoundError: print("Dataset not found") except RateLimitError as e: print(f"Rate limited, retry after {e.retry_after} seconds") except AvalaError as e: print(f"API error: {e.message}")
Last updated on