mockfly logo

Offline CLI

mockfly-cli lets you serve your Mockfly mock APIs locally — fully offline. Pull your projects once while you have internet, then keep mocking on the plane, on the train, or anywhere without a connection. Responses are produced by the same engine Mockfly runs in production: conditional rules, Faker templating, URL/body/header/env placeholders, delays and XML.

Quick start

# while online
npx mockfly-cli login      # paste an API key from the Mockfly dashboard
npx mockfly-cli pull       # snapshots all your projects to ~/.mockfly/projects

# from now on, no internet needed
npx mockfly-cli serve

Or install it globally and get the shorter mockfly command:

npm install -g mockfly-cli
mockfly pull && mockfly serve

serve mounts every pulled project under its slug (same as production) and under a friendly alias derived from its name:

Mockfly serving 2 projects on http://localhost:4000

  User API                 http://localhost:4000/user-api (pulled just now)
                           http://localhost:4000/d3f1…-… — 4 endpoints
  Payments Mock            http://localhost:4000/payments-mock (pulled just now)
                           http://localhost:4000/9a2c…-… — 6 endpoints

The API key is an account-level key (mf_…). Create yours at app.mockfly.dev/api-keys— the full key is only shown once at creation time.

Commands

Snapshots live in ~/.mockfly/projects by default, out of your working directory. pull, serve, list and rm accept --dir <dir> for a project-local workspace instead (e.g. mocks you want to commit alongside a repo). login and pull also accept --key <key> and --api <url> as one-off overrides.

How it works

pull snapshots each project (endpoints, responses, rules, environment variables) into a plain JSON file. serve loads those files into memory and answers requests with a local copy of the Mockfly response engine. Nothing is written back: the files are read-only snapshots — to change your mocks, edit them in the Mockfly web app and pull again.

Security notes

Configuration