@hoststack/sdk

TypeScript SDK

Manage your HostStack infrastructure programmatically. Full TypeScript support with autocompletion, typed responses, and comprehensive error handling.

Quick start

Install
npm install @hoststack/sdk
typescript
import { HostStack } from '@hoststack/sdk';

const client = new HostStack({
  apiKey: process.env.HOSTSTACK_API_KEY,
});

// Deploy a service
const deploy = await client.deploys.trigger('svc_abc123');
console.log(deploy.status); // 'building'

// List all services
const services = await client.services.list();
for (const svc of services) {
  console.log(svc.name, svc.status);
}
Full TypeScript types with IntelliSense
Async/await with proper error hierarchy
Zero dependencies beyond fetch
Works in Node.js, Bun, and Deno
Pagination helpers built-in
Bearer token authentication

Available resources

client.projects

list
get
create
update
delete

client.services

list
get
create
update
delete
suspend
resume
metrics

client.deploys

list
get
trigger
cancel
rollback
getLogs

client.databases

list
get
create
delete
credentials
resetPassword

client.domains

list
add
update
remove
verify

client.envvars

list
create
update
delete
bulkSet

Real-world example

typescript
import { HostStack, NotFoundError } from '@hoststack/sdk';

const client = new HostStack({ apiKey: process.env.HOSTSTACK_API_KEY });

// Set environment variables and deploy
await client.envVars.bulkSet('svc_abc123', [
  { key: 'NODE_ENV', value: 'production', target: 'both' },
  { key: 'DATABASE_URL', value: process.env.DATABASE_URL, target: 'runtime', isSecret: true },
]);

const deploy = await client.deploys.trigger('svc_abc123', {
  clearCache: true,
});

// Stream build logs
const logs = await client.deploys.getLogs(deploy.id);
for (const line of logs) {
  console.log(`[${line.level}] ${line.message}`);
}

// Error handling
try {
  await client.services.get('svc_invalid');
} catch (error) {
  if (error instanceof NotFoundError) {
    console.log('Service not found');
  }
}

Start building

Get your API key from the dashboard, install the SDK, and automate your infrastructure in minutes.