Mocking Legacy & Third-Party APIs
The Problem: Your startup is building a new integration with a legacy banking API (or a rate-limited third-party service like Stripe). The sandbox environment is incredibly slow, frequently goes down, and has strict rate limits that block your CI pipeline.
The Mock-First Solution: Capture the real responses once, and serve them locally at 0ms latency for the entire team using Mockzilla.
1. The Capture Phase
Instead of reading a 400-page manual for the legacy API, make a real request using your browser with the Mockzilla Chrome Extension active.
- Open the Legacy Dashboard: Go to the third-party sandbox.
- Trigger the Request: Click around to trigger the API calls (e.g., "Fetch Account Details").
- Capture & Sync: Open the Mockzilla Chrome Extension, find that request, and sync it to your Mockzilla server (see Browser Extension Sync).
Mockzilla creates an extension folder and a mock with the method, path, status code, and response body the real API returned. Response headers are not stored.
2. The Refinement Phase: Snapshot to Living Mock
The captured data is static. To make it useful for testing multiple scenarios, transform it into a Dynamic Mock.
- Go to the Mockzilla Dashboard.
- Edit the newly captured mock. Change the endpoint to
/v1/accounts/*and set Match Type to Wildcard, so one mock serves every account ID. - Under Wildcard Variants, click Add fallback, select Dynamic Response, and write a schema based on the captured payload. Mockzilla doesn't convert a payload into a schema for you; write it by hand or ask an AI agent:
{
"type": "object",
"properties": {
"account_id": { "type": "string", "const": "{{$.params.[0]}}" },
"status": { "type": "string", "enum": ["ACTIVE", "FROZEN", "PENDING"] },
"balance": { "type": "number", "minimum": 0, "maximum": 10000, "multipleOf": 0.01 },
"currency": { "type": "string", "const": "USD" }
},
"required": ["account_id", "status", "balance"]
}
account_id echoes the ID from the URL, so /v1/accounts/acc-7 returns "account_id": "acc-7". The other fields are generated fresh on each request.
3. The Result: A Local Playground for the Team
Now, point your app to http://localhost:36666/api/mock/legacy-api/....
- Speed: 3-second legacy calls now take 5ms locally.
- Reliability: CI/CD pipelines never fail because the sandbox is down.
- Cost: Avoid hitting rate limits or usage charges for third-party sandboxes.
- Team Portability: Use Export on the dashboard to save your folders and mocks as JSON, then commit that file to Git. Teammates use Import on their own Mockzilla server to get the same mocks.
🤖 Do it with AI
"Take this legacy JSON snapshot and create a Mockzilla endpoint. Convert it into a dynamic schema using Faker for the account IDs and balances, ensuring the currency remains USD."
