TypeScript SDK
The official TypeScript SDK for Tuskr provides a type-safe, ergonomic interface for interacting with the Tuskr API.
Installation
npm install @tuskr/sdkQuick Start
import { Tuskr } from '@tuskr/sdk' // Initialize the clientconst client = new Tuskr({ apiKey: process.env.TUSKR_API_KEY}) // Upload a fileconst file = await client.upload(buffer, { filename: 'image.png', tag: 'avatar', category: 'images'}) console.log(file.url) // https://cdn.tuskr.dev/abc123Configuration
The Tuskr client accepts the following configuration options:
| Option | Type | Description |
|---|---|---|
| apiKey | string | Your Tuskr API key (required) |
| baseUrl | string | Custom API base URL |
| timeout | number | Request timeout in ms (default: 30000) |
| retries | number | Number of retry attempts (default: 3) |
Methods
client.upload()
Upload a file to Walrus storage.
const result = await client.upload(file, { tag: 'avatar', category: 'images', epochs: 2})client.list()
List files with optional filtering.
const { files, cursor } = await client.list({ tag: 'avatar', limit: 20, cursor: 'next_page_token'})client.get()
Get a file by ID.
const file = await client.get('file_abc123')client.delete()
Delete a file by ID.
await client.delete('file_abc123')