Generate Mock APIs

In order to generate Mock APIs, we want to ensure that:

  • Request responses can be recorded instead of hard-coding

  • Request responses can be refreshed without having to manually update contracts

Minimize Hard-Coding


Stoobly lets you easily create mock APIs by recording HTTP traffic. To record traffic, Stoobly acts as a proxy between a client and server and intercepts traffic that passes through.

In comparison, to generate HTTP request mocks without recording:

  1. Use a client driver (e.g. curl, browser) to send a HTTP request

  2. Copy and paste the HTTP response into a mock tool or library

  3. Repeat for different request variations and/or endpoints

We can see that this process quickly becomes difficult to scale. As either the number of HTTP request variations increase or as new endpoints are added, we have to keep manually adding responses to our mocks.

With recording, the process looks like:

  1. Configure a client driver (e.g. curl, browser) to proxy requests to Stoobly

  2. Send a HTTP request and let Stoobly record it for you

  3. Repeat for as many HTTP requests as you want


Stoobly comes out of the box with comprehensive request and response matching that should cover most use-cases without explicitly stating the match requirements. By default, Stoobly matches a HTTP request by looking for exact match of path, query params and body. If needed, match rules can be configured to relax or tighten matching requirements.

In comparison, to configure how HTTP requests are matched when mocking manually:

  1. Specify a exact path to match or use regex for pattern matching

  2. Repeat for every HTTP request that the mock API needs to support

An additional difficultly to highlight here is that matching bodies is often not possible. This is because the body would first have to be pared based on the specified content type.

With Stoobly mocking, the process looks like:

  1. Requests will be matched without additional configuration

  2. (Optional) Stoobly enables configuring how a request gets matched. Matching against query params, body or headers can be either relaxed or tightened.

Scale Maintenance

A mock API works great from the time it is created to when it comes time for maintenance. Stoobly enables you to replay recorded requests and either overwrite the existing request response or alternatively, create a new version of the request.

In comparison, to update a HTTP response mock manually:

  1. Determine which mocks need updating

  2. Use a client driver to resend a HTTP request

  3. Copy and paste the updated response

  4. Repeat for other mocks that need updating

While to above flow may not mirror exactly how mocks are always updated (sometimes we directly modify the mock), it serves to illustrates the difficutly in:

  1. Understanding which mocks need updating

  2. Understanding what a new correct version of the mock looks like

This problem gets even worse when we want to update a sequence of requests that have a relationship with each other (e.g. creating, reading, and deleting a resource are connected by the resource ID).

With Stoobly mocking, the process looks like:

  1. Determine which requests or scenarios need updating

  2. Replay and record the requests or scenarios

Last updated