npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@studio-foundation/api

v0.3.0-beta.6

Published

HTTP API for Studio v7

Readme

@studio-foundation/api

HTTP REST API for Studio. Same engine as the CLI, machine-to-machine interface. Like GitHub is to git.

Role

api wraps the engine in a Fastify server. It handles fire-and-forget pipeline launches, real-time SSE streaming, webhook dispatch, and integration lifecycle (Linear, etc.). The CLI (studio api start) is the primary way to run it, but it can also be imported programmatically.

Linear webhook → POST /api/runs → launcher → engine → pipeline run → webhook dispatch
Slack bot      → POST /api/runs ↗
CI/CD          → POST /api/runs ↗
Dashboard      → GET  /api/runs/:id/stream (SSE)

Starting the server

# Via CLI (recommended)
studio api start

# Standalone (PM2/systemd)
STUDIO_CWD=/path/to/project node node_modules/.bin/studio-api

# Programmatic
import { createApi } from '@studio-foundation/api';
const { server, cleanup } = await createApi({ cwd: '/path/to/project' });
await server.listen({ port: 3700 });

Configuration

The server reads .studio/config.yaml from the project directory (or the first .studio/ found walking up from STUDIO_CWD):

api:
  key: my-secret-key   # Optional — enables Bearer auth. Omit for open local use.
  port: 3700           # Default: 3700

db:
  type: postgres       # 'sqlite' | 'postgres' | 'inmemory'. Default: 'sqlite'
  url: ${DATABASE_URL} # Required if type is postgres

providers:
  anthropic:
    apiKey: ${ANTHROPIC_API_KEY}

Authentication: If api.key is set, all routes require Authorization: Bearer <key>. Without a key, the API is open (local use only).

Endpoints

Runs

POST   /api/runs                → Launch a pipeline (fire-and-forget). Returns run ID immediately.
GET    /api/runs                → List runs (?status=&limit=)
GET    /api/runs/:id            → Run detail
GET    /api/runs/:id/logs       → Raw JSONL logs
GET    /api/runs/:id/stream     → SSE — live events (?events=csv filter)
DELETE /api/runs/:id            → Cancel a running pipeline

Project

GET    /api/projects            → Current project (name, id, pipelines_dir)
GET    /api/projects/:id/pipelines → Pipelines for a project

CRUD (Pipelines, Agents, Contracts, Skills)

GET    /api/pipelines           → List pipeline names
GET    /api/pipelines/:name     → Parsed pipeline (YAML → JSON)
PUT    /api/pipelines/:name     → Create or update a pipeline (body: YAML or JSON)
DELETE /api/pipelines/:name     → Delete a pipeline

GET    /api/agents              → List agent names
GET    /api/agents/:name        → Parsed agent
PUT    /api/agents/:name        → Create or update an agent
DELETE /api/agents/:name        → Delete an agent

GET    /api/contracts           → List contract names
GET    /api/contracts/:name     → Parsed contract
PUT    /api/contracts/:name     → Create or update a contract
DELETE /api/contracts/:name     → Delete a contract

GET    /api/skills              → List skill names
GET    /api/skills/:name        → Skill content (.skill.md)
PUT    /api/skills/:name        → Create or update a skill (body: markdown)
DELETE /api/skills/:name        → Delete a skill

Tools, Config, Validation

GET    /api/tools               → Available tools (YAML plugins + builtins)

GET    /api/config              → Current config (API keys masked)
PUT    /api/config              → Update config

POST   /api/validate            → Validate a JSON output against a contract

Webhooks

POST   /api/webhooks            → Register a webhook (url + events filter)
GET    /api/webhooks            → List webhooks
DELETE /api/webhooks/:id        → Delete a webhook

Swagger UI

GET    /api/docs                → Swagger UI (dev only — disabled in NODE_ENV=production)
GET    /api/docs/json           → OpenAPI spec (for client generation)

SSE streaming

Connect to /api/runs/:id/stream to receive live events:

const es = new EventSource('/api/runs/run-123/stream');
es.addEventListener('stage_complete', (e) => console.log(JSON.parse(e.data)));
es.addEventListener('pipeline_complete', (e) => { es.close(); });

// Filter to specific event types:
// GET /api/runs/:id/stream?events=stage_complete,tool_call_complete

Integrations

The API manages integration lifecycle (webhook routing, failure handling). Integrations are configured via .studio/config.yaml and declared via .integration.yaml files in .studio/integrations/.

Linear integration — drag an issue to "In Progress" → Studio receives the webhook → auto-launches the matching pipeline → posts results as a comment → moves the issue to "Done" on success.

Sub-pipeline spawning

The API uses HttpApiSpawner — a self-referential RunSpawner that calls back into the same API to spawn child runs. This is how studio_run tool calls work when the engine is running behind the API.

Bootstrap internals

bootstrap(cwd) is the composition root:

  1. Finds .studio/ by walking up from cwd
  2. Loads config.yaml (with ${ENV_VAR} substitution)
  3. Creates RunStore based on db.type (SQLiteRunStore | PgRunStore | InMemoryRunStore)
  4. Creates ProviderRegistry, ToolRegistry (loads .tool.yaml plugins)
  5. Loads Claude Code plugins (MCPClient per server)
  6. Creates HttpApiSpawner, PipelineEngine, InProcessLauncher
  7. Creates WebhookStore, IntegrationStore, IntegrationRuntime
  8. Returns BootstrapResult passed to buildServer()

Rules

  • api depends on engine + runner. It is a composition root, same as cli.
  • Routes must have complete Swagger schemas — tags, summary, params, response codes. Without this, routes don't appear in Swagger UI.
  • The engine is the same. The API doesn't bypass or wrap the engine — it delegates to InProcessLauncher, which calls PipelineEngine.run() directly.
  • studio api start calls bootstrap() then buildServer(). The two steps are separate so programmatic users can customize between them.