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.
# 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 serveOr install it globally and get the shorter mockfly command:
npm install -g mockfly-cli
mockfly pull && mockfly serveserve 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 endpointsThe 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.
mockfly login [--key <mf_…>]: Validate and save your account API key to ~/.mockfly/config.json.mockfly pull [projects...]: Download all your projects — or just the named ones (by slug or name) — to ~/.mockfly/projects.mockfly serve [--port 4000]: Serve every pulled project locally, offline.mockfly list: Show what is pulled and how stale it is.mockfly rm <project>: Remove a pulled project.mockfly whoami: Show which API key and API url are active.mockfly logout: Delete the saved API key.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.
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.
mockfly login stores your API key in plaintext at ~/.mockfly/config.json (file mode 600), like ~/.npmrc or ~/.aws/credentials. Use mockfly logout to remove it, and revoke keys from the Mockfly dashboard.~/.mockfly/projects) keeps them out of your repos; if you pull into a local dir with --dir, add it to .gitignore before committing — sharing the files shares the secrets.MOCKFLY_API_KEY: API key (overrides the saved one).MOCKFLY_API_URL: API base url (self-hosted / staging).