postman-api
v0.1.3
Published
Code-first Postman collections CLI and SDK (Bun/Node)
Readme
postman-api
TypeScript API starter using Bun + Elysia + Drizzle + OpenTelemetry and a CLI to generate and sync a code-first Postman configuration (api.postman.config.ts).
Quickstart (local dev)
- Install deps:
bun install - Copy env:
cp .env.example .envand setPOSTMAN_API_KEY - Run server:
bun run src/server.ts(orbun run start) - Generate config:
bun run src/cli.ts init - Sync to Postman:
bun run src/cli.ts sync - Auto-sync on change:
bun run src/cli.ts watch - Interactive setup (banner + prompts):
bun run src/cli.ts start
NPM Package / SDK
- Install (project):
npm i postman-apior global:npm i -g postman-api - Run interactive setup:
npx postman-api init(oupostman-api initse instalado globalmente) - Sincronizar configurado:
postman-api sync - Assistir mudanças:
postman-api watch - Logout (remover API Key):
postman-api logout(use--keychain,--envou--all) - Login (salvar no Keychain):
postman-api login(opções:--key <APIKEY>ou--from-env)
Se preferir npm start postman-api no seu projeto, adicione no seu package.json:
{
"scripts": {
"start": "postman-api start"
}
}Observações:
- Por padrão, a API Key é salva com segurança no Keychain do sistema (Windows Credential Manager / macOS Keychain / Linux Secret Service) usando
keytar. Como fallback, pode ser gravada no.env. - O arquivo padrão do config é
api.postman.config.mjs(ESM). Se você já usa Bun e prefere TypeScript, mantenhaapi.postman.config.tse usebun run src/cli.ts ...localmente.
Scripts (dev)
bun run dev— run server with watchbun run start— run serverbun run cli— run CLIbun run cli:watch— watch config and auto-syncbun run build— build ESM artifacts todist/bun run drizzle:generate— generate SQL from schemabun run drizzle:push— push migrations
Postman CLI
postmanapi init creates api.postman.config.ts which lets you define:
- collections: name, description, baseUrl
- folders and requests: method, path, headers, body, responses
- environments: named variable maps
postmanapi sync reads the config, validates it, then creates/updates Postman collections and environments in the workspace set by POSTMAN_WORKSPACE_ID (or the workspaceId in the config).
Environment variables are loaded via dotenv when using the CLI.
Telemetry
Basic OpenTelemetry tracing is initialized in src/telemetry.ts with an OTLP HTTP exporter (OTEL_EXPORTER_OTLP_ENDPOINT, default http://localhost:4318).
Database (Drizzle + Bun SQLite)
Database lives in app.db. Schema in src/db/schema.ts. Configure Drizzle with drizzle.config.ts.
