Mocklets
  • Getting Started
  • Working with Collections
    • Create Collection
    • Invite Members
  • Managing Mock Apis
    • Dynamic Responses
    • URL Regex Matching
    • Use API as Proxy
    • Randomised Responses
    • Response Delay
    • Using Query Params
    • API Comments
  • Manage your files
  • Open API Specifications 3.x
  • Integration with external editors
  • Response Headers
  • Monitor Request Logs
  • Secure your mock APIs
  • Important Links
    • Home
    • Dashboard
    • Privacy Policy
    • Terms of Use
Powered by GitBook
On this page

Was this helpful?

  1. Managing Mock Apis

Randomised Responses

PreviousUse API as ProxyNextResponse Delay

Last updated 5 years ago

Was this helpful?

The behavior of production APIs in real-world scenarios is all but reliable. Due to various constraints (like network congestion, bad request from client side or even sometimes server failures), your back-end APIs might behave in different ways, producing different responses.

In the Dynamic Responses section, we learned that you can add the possible outcome of an API to the Mocklets dashboard. But what if you want your API to return one of the responses randomly instead of the currently active response?

Generating random responses from the API on every request gives a true sense of working with a real-world API.

How to make an API to return random responses

It's very simple to set your API to return random responses on every request. Just enable Randomised Responses settings of your API, and your API will starting one the response set in your api on a random basis. If enabled, this setting will override the active response.

Please note If you have enabled the Use Api as Proxy, this feature will be overridden and you will receive the response sent by your proxy server.