API Mocking
Mocking Overview
Mock lifecycle, base URLs, and request handling fundamentals.
API Mocking Overview
Faker Forge API mocking lets you model API behavior without depending on live backend services.
Core Objects
- Mock: top-level API surface.
- Endpoint: method + path contract.
- Scenario: conditional response rule.
Base URL Shape
Each mock exposes a base URL where endpoint paths are resolved, for example https://fakerforge.com/api/mock/{id}/shop plus /orders/{id}. Path segments in braces match any value.
The Mock Page
Open a mock to see its endpoints on the left (searchable by method, path or name) and the selected endpoint on the right:
- Overview: the full request URL and a curl command to copy, the default scenario, path parameters, and the linked data source.
- Scenarios: each scenario's status, priority, delay, readable conditions (for example
query.status equals "paid"), response headers and formatted body. - Try it: fill in path parameters, query parameters, headers and a JSON body, then Send request. You see which scenario matched and why, plus the status, headers and resolved body (with data-source placeholders filled in). Try it is a dry run: no delay, and it doesn't use your request quota. The equivalent curl command for the live URL is shown next to it.
Mock Assistant
Ask the Mock Assistant to build and test endpoints by chatting, for example "add GET /orders/{id} that returns 404 when id is 0".
Request Handling Flow
- Incoming request targets a mock endpoint.
- Endpoint method/path is matched.
- Scenarios are tried by priority (highest first); the first whose conditions all match is selected, otherwise the default scenario answers.
- Delay and headers are applied.
- Scenario body is returned with status code.
Why This Helps
- Isolate frontend and client testing.
- Reproduce edge cases reliably.
- Simulate outages and latency.
Typical Use Cases
- Contract testing
- Frontend feature development
- QA scenario automation
- Demo environments