npm.io
0.1.4 • Published 1 month agoCLI

mock-api-studio-cli

Licence
SEE LICENSE IN LICENSE
Version
0.1.4
Deps
9
Size
63 kB
Vulns
0
Weekly
0

Mock API Studio

Start a local mock API server from your Mock API Studio cloud project definitions.

Install

Run without installing globally:

npx mock-api-studio-cli --help

Or install the package globally:

npm install --global mock-api-studio-cli
mock-api-studio-cli --help

The legacy mock-api-studio executable remains available as a compatibility alias.

Quickstart

Run the interactive project picker:

npx mock-api-studio-cli

The first run asks for an API token, saves it locally, lists your projects, and starts the selected mock server.

Start a project directly by slug:

npx mock-api-studio-cli my-project

Use an explicit port when you want to override the project default:

npx mock-api-studio-cli my-project --port 4500

The interactive picker first lets you choose between your personal workspace and any active Team workspaces you joined. To start a Team project directly, pass its workspace ID:

npx mock-api-studio-cli start team-project --workspace 11111111-1111-4111-8111-111111111111

Team viewers can discover, sync, and run projects locally, but cannot change cloud project configuration. Suspended or revoked workspace access is reported before a project is started.

Commands

start <slug>

Starts a project without opening the interactive picker.

npx mock-api-studio-cli start my-project

Use --workspace <id> when the slug belongs to a joined Team workspace.

whoami

Shows the account associated with the saved token.

npx mock-api-studio-cli whoami
logout

Removes the locally saved token.

npx mock-api-studio-cli logout

Local Config

The interactive CLI stores the token in:

~/.mock-api-studio/config.json

Token resolution order:

  1. --token
  2. local config
  3. MOCK_API_TOKEN

The CLI connects to https://api.mockapistudio.dev by default. For local backend development, override it with MOCK_API_BASE_URL as shown in .env.example.

Mock Server

The synced mock server exposes:

  • configured resource routes such as /users
  • only the enabled operations for each resource
  • GET /openapi.json
  • GET /docs
  • runtime control routes under /_mock

Troubleshooting

  • Port is already in use Use --port <number> with a free port, or change the project local mock port in the dashboard.
  • Invalid or expired API token Run npx mock-api-studio-cli logout, then run npx mock-api-studio-cli again and paste a fresh token.
  • Project has no mock resources Add mock resources in the dashboard, then rerun the CLI.

License

Mock API Studio CLI is commercial software. Use requires an authorized Mock API Studio account and is governed by the included license and the Terms of Service.

Keywords