TypeScript SDK

The official TypeScript SDK for Tuskr provides a type-safe, ergonomic interface for interacting with the Tuskr API.

Installation

npm install @tuskr/sdk

Quick Start

import { Tuskr } from '@tuskr/sdk'
 
// Initialize the client
const client = new Tuskr({
apiKey: process.env.TUSKR_API_KEY
})
 
// Upload a file
const file = await client.upload(buffer, {
filename: 'image.png',
tag: 'avatar',
category: 'images'
})
 
console.log(file.url) // https://cdn.tuskr.dev/abc123

Configuration

The Tuskr client accepts the following configuration options:

OptionTypeDescription
apiKeystringYour Tuskr API key (required)
baseUrlstringCustom API base URL
timeoutnumberRequest timeout in ms (default: 30000)
retriesnumberNumber 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')