Scenario Engine
The Scenario Engine lets you simulate real-world API conditions on a per-route basis. Configure latency, error injection, and rate limiting to test how your frontend handles adverse conditions.
Latency Simulation
Add configurable delay to responses with min/max milliseconds to simulate slow networks.
Error Injection
Return errors at a configurable rate (0-100%) with custom status codes and messages.
Rate Limiting
Limit the number of requests allowed per time window to simulate API throttling.
Latency Simulation
When latency is configured for a route, each request is delayed by a random duration between the min and max values. This is useful for testing loading states and timeouts.
minMinimum delay in millisecondsmaxMaximum delay in milliseconds// With latency configured (min: 500ms, max: 2000ms),
// each request is delayed by a random amount in that range.
// Request behaves normally but takes 500-2000ms to respond:
fetch('https://api.restfaker.dev/api/schema/posts', {
headers: {
'apiToken': 'your_api_token_here',
'Content-Type': 'application/json'
}
})
.then(response => response.json())
.then(data => console.log(data)); // Response arrives after delayError Injection
When error injection is configured, a percentage of requests will return the specified error status code and message instead of the normal response.
ratePercentage of requests that return errors (0-100)statusCodeHTTP status code to return (e.g., 500, 503, 429)messageCustom error message included in the response body// With error injection configured (rate: 50%, statusCode: 500,
// message: "Internal Server Error"), ~50% of requests will fail:
// Successful response (50% of requests):
{
"data": [...],
"meta": { "total": 50, "page": 1, "perPage": 10, "pages": 5 }
}
// Error response (50% of requests):
// HTTP 500
{
"error": "Internal Server Error"
}Rate Limiting
When rate limiting is configured, requests that exceed the allowed threshold within the time window are rejected with a 429 status code.
maxRequestsMaximum number of requests allowed per windowwindowMsTime window duration in milliseconds// With rate limiting configured (maxRequests: 10, windowMs: 60000),
// after 10 requests within 60 seconds you'll receive:
// HTTP 429
{
"error": "Too Many Requests",
"message": "Rate limit exceeded. Try again later."
}Configuring Scenarios
Scenarios are configured per-route in your project dashboard. You can enable multiple scenario types on the same route. For example, you can combine latency simulation with error injection to test how your app handles slow, unreliable APIs.