In proxy mode, Mockhop sends requests it can't answer to a real API and records what comes back. You then turn the recordings you need into endpoints.
1. Turn on proxy mode for the project
In the project's settings, under Proxy settings, turn on Enable proxy mode ("Forward unmatched requests to target URL and record them") and enter the Target URL, for example https://api.example.com.
2. Send requests through Mockhop
Call your mock URL with a path that has no endpoint yet:
$ curl -s $URL/payments/v1/rates
Because no endpoint matches, Mockhop forwards the request to https://api.example.com/v1/rates: the target URL plus the path after your base path. Mockhop then:
- returns the real response to your client
- stores the request and response as a recording
Mockhop also forwards a request when an endpoint matches but none of its responses does.
3. Turn a recording into an endpoint
- Open Proxy recordings and choose the project.
- Select View details to see the recorded headers and bodies.
- Select Convert to mock. Mockhop creates an endpoint from the recorded request and response.
From then on, your mock answers that request itself, because a matching endpoint comes before the proxy.
Proxy for a single endpoint
An endpoint can also forward its own calls: turn on Enable proxy in the endpoint and enter the full upstream URL as Target URL. Mockhop sends the request to that URL as it is and records it like a project proxy call.
Good to know
- Cloud vs. self-hosted: in the cloud version, the target must be a public address; private and internal networks are blocked. A self-hosted installation can also reach APIs in your internal network.
- Sensitive headers: headers such as
Authorization, cookies and tokens are masked in recordings and logs, and left out when you convert a recording into a mock. - Request counting: proxied requests count toward your monthly requests.
- Retention: recordings are kept for 90 days.
- Plans: proxy mode and proxy recording are part of the Pro, Team and Business plans.
- Use test data: only record APIs you're allowed to use, and prefer test accounts to production credentials.
See also: Record and replay API traffic.