@hoststack.dev/sdk
Infrastructure-as-TypeScript
The official HostStack SDK turns the platform into something you can script. Wire deploys into your CI, spin up preview environments from a chatbot, or drive the whole dashboard from a Node process — with proper types, proper errors, and zero surprises.
Quick start
npm install @hoststack.dev/sdkimport { HostStack } from '@hoststack.dev/sdk';
const client = new HostStack({
apiKey: process.env.HOSTSTACK_API_KEY!,
});
const teamId = 'team_abc123'; // or numeric id from `hoststack whoami`
// Deploy a service
const { deploy } = await client.deploys.trigger(teamId, 'svc_abc123');
console.log(deploy.status); // 'pending' | 'building' | 'live' | ...
// List all services
const { services } = await client.services.list(teamId);
for (const svc of services) {
console.log(svc.name, svc.status);
}Available resources
client.projects
client.services
client.deploys
client.databases
client.domains
client.registeredDomains
client.wildcardCerts
client.envVars
client.environments
client.cron
client.volumes
client.machines
client.notifications
client.errors
client.analytics
client.humanCheck
client.uptime
client.support
client.devTasks
client.dependencyUpdates
client.teams
client.dns
client.serviceResourceLinks
Real-world example
import { HostStack, NotFoundError } from '@hoststack.dev/sdk';
const client = new HostStack({ apiKey: process.env.HOSTSTACK_API_KEY! });
const teamId = 'team_abc123';
// Set environment variables and deploy
await client.envVars.bulkSet(teamId, 'svc_abc123', {
vars: [
{ 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(teamId, 'svc_abc123');
// Read build logs
const { logs } = await client.deploys.getLogs(teamId, 'svc_abc123', deploy.publicId);
for (const line of logs) {
console.log(`[${line.level}] ${line.message}`);
}
// Error handling
try {
await client.services.get(teamId, 'svc_invalid');
} catch (error) {
if (error instanceof NotFoundError) {
console.log('Service not found');
}
}From npm install to first deploy in a minute
Generate an API key, drop it into your process env, and automate everything you used to click through by hand.