Answer from a mock server

Give a project a public address that answers like your API, from its saved examples.

In short

A mock server is a public address that answers like your API, from the examples saved on a project's requests. Use it to build or test an app before the API is ready, or to see how your app copes when the API is slow or failing. Each project has one.

Before you start

Steps

  1. Save at least one response as an example: /help/api-testing/saved-examples.
  2. Open "Build", choose "Mocks, streams & docs", choose the project and open "Mock server" - or choose "Mock server" in the project's … menu on Requests.
  3. Press "Start the mock server". You need a confirmed email address.
  4. Press "Copy address" and call it, or copy the ready curl command under it.

Result: the mock answers calls that match a saved request with an example. To see one working in two minutes, press "Mock the sandbox bookstore".

How it answers

Latency, errors and a key

A mock that remembers calls

Switch on "Remember what calls send" to let your app create, change and delete data on the mock, as it would on the real API.

Forward other calls and record the answers

Under "Forward other calls", give the address of your real API, such as https://api.example.com. A call nothing in the mock answers - no saved request matches it, or the request has no example that fits - then goes to that address, below its path, and its answer comes back.

The request log

"Request log" lists the newest calls first: method, path, status, how each was answered - Answered, No match, Simulated error, Key refused, Forwarded or Not forwarded - and when. Click a call for its headers and body, shown as text only. Credentials are masked. The log keeps the newest 200 calls for 3 days.

Good to know

If something goes wrong

Related