@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
Install
npm install @hoststack.dev/sdktypescript
import { 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);
}End-to-end typed — every response shape is inferred from the API
Typed error hierarchy (NotFoundError, RateLimitError, AuthenticationError, ...)
Zero runtime dependencies beyond the platform fetch
Runs in Node.js 18+, Bun, Deno, Cloudflare Workers, and the browser
Offset/limit pagination helpers + a streamLogs async iterator for live tails
Accepts numeric ids or human-friendly publicIds (svc_…, dpl_…) and resolves transparently
Available resources
client.projects
list
get
create
update
delete
client.services
list
get
create
update
delete
suspend
resume
getMetrics
updateConfig
streamLogs
client.deploys
list
get
trigger
cancel
rollback
promote
getLogs
client.databases
list
get
create
update
delete
suspend
resume
getCredentials
resetPassword
client.domains
list
add
update
remove
verify
client.envvars
list
create
update
delete
bulkSet
client.volumes
list
create
update
delete
client.environments
list
get
create
update
delete
Real-world example
typescript
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.