Mock APIs
Serve local files as API responses instead of hitting the real server. Supports JSON, JS, and any static content, with instant hot reload on file changes.
Map Local lets you replace a real server's responses with files stored on your machine. When a request matches a rule configured with Map Local, HTTPeep intercepts it and returns the contents of a local file — without ever contacting the server. Changes to your local files take effect immediately without restarting the proxy or reloading your application.
How it works
When a rule's resolve outlet is set to map_local or map_local_dir, HTTPeep:
- Matches the incoming request against the rule's conditions
- Maps the request path to a corresponding file on disk
- Returns that file as the HTTP response, with the headers you configure
- Watches the file for changes and serves the updated version on the next request
No real server is contacted. Your application has no way to distinguish a Map Local response from a real one.
Supported file types
Map Local works with any file your application can consume over HTTP:
| File type | Use case |
|---|---|
.json | Mock REST API endpoints, GraphQL responses, configuration feeds |
.js | Mock JavaScript module endpoints or JSONP responses |
.html | Mock server-rendered pages |
.xml | Mock SOAP or RSS feeds |
| Any static file | Images, fonts, CSS, arbitrary binary content |
HTTPeep infers the Content-Type header from the file extension. You can override it by setting a custom header in the rule's resolve configuration.
Configuring Map Local
In the Rules panel, click New Rule or edit an existing rule.
Configure the domain, path, and any other conditions to select the traffic you want to mock.
In the Resolve section, select Map Local for a single file or Map Local Directory to map a whole directory structure.
Click the folder icon and browse to the file or directory on your machine. HTTPeep stores the absolute path in the rule.
The rule is active immediately. The next matching request returns the local file.
To map a single file:
resolve:
type: map_local
filePath: /Users/chris/mocks/users-response.json
headers:
Content-Type: application/json
x-httpeep-debug: '1'To map an entire directory (request paths are resolved relative to the directory):
resolve:
type: map_local_dir
filePath: /Users/chris/mocks/api
headers:
x-httpeep-debug: '1'Directory mapping and path resolution
When you use map_local_dir, HTTPeep maps the URL path of each request to a file in the directory. For example:
| Request URL | Served file |
|---|---|
GET /api/users | /Users/chris/mocks/api/users or /Users/chris/mocks/api/users.json |
GET /api/users/42 | /Users/chris/mocks/api/users/42.json |
GET /api/products?page=2 | /Users/chris/mocks/api/products.json (query params ignored) |
Organize your mock directory to mirror your API's URL structure. This makes it straightforward to add new mocked endpoints — just create the corresponding file.
Hot reload
HTTPeep watches your local files for changes using filesystem events. When you save an updated mock file, the change takes effect on the very next request. You do not need to:
- Restart HTTPeep
- Reload your application
- Clear any cache in the proxy
This makes it fast to iterate on mock data while your application is running.
Full rule example
The following rule mocks the entire api.example.com domain over HTTPS using a local directory, adds a custom debug header, and simulates a realistic response delay and bandwidth:
# rule.yaml - Frontend Mock API
- id: rule_mnhi5xkt
description: "Frontend Mock API"
enabled: true
builtin: false
stopAfterMatched: false
match:
domains:
- type: exact
value: api.example.com
originProtocol: https
requestActions: []
resolve:
type: map_local_dir
filePath: /Users/chris/mocks/api
headers:
x-httpeep-debug: '1'
responseActions:
- type: delay_response
id: action_1775140499860
enabled: true
delayMs: 500
- type: throttle_response
id: action_1775591855867
enabled: true
speed:
max: 384
burst: 768