Skip to content

TypeScript SDK Reference

The Daytona TypeScript SDK provides a powerful interface for programmatically interacting with Daytona Sandboxes.

Installation

Install the Daytona TypeScript SDK using npm:

Terminal window
npm install @daytonaio/sdk

Or using yarn:

Terminal window
yarn add @daytonaio/sdk

Getting Started

Here’s a simple example to help you get started with the Daytona TypeScript SDK:

import { Daytona } from '@daytonaio/sdk';
async function main() {
// Initialize the SDK (uses environment variables by default)
const daytona = new Daytona();
// Create a new sandbox
const sandbox = await daytona.create({
language: 'typescript',
envVars: { NODE_ENV: 'development' }
});
// Execute a command
const response = await sandbox.process.executeCommand('echo "Hello, World!"');
console.log(response.result);
}
main().catch(console.error);

Configuration

The SDK can be configured using environment variables or by passing options to the constructor:

import { Daytona, SandboxTargetRegion } from '@daytonaio/sdk';
// Using environment variables (DAYTONA_API_KEY, DAYTONA_SERVER_URL, DAYTONA_TARGET)
const daytona = new Daytona();
// Using explicit configuration
const daytona = new Daytona({
apiKey: 'your-api-key',
serverUrl: 'https://app.daytona.io/api',
target: SandboxTargetRegion.US
});