Apidog provides an efficient mock engine that automatically generates realistic API responses based on your API specifications. This powerful feature eliminates the need for manual configuration, accelerating development and testing workflows.Use Cases#
Mock APIs are valuable in various development and testing scenarios:| Scenario | Description | Benefit |
|---|
| Parallel Development | Frontend development when APIs are designed but not yet implemented | Frontend teams can proceed without waiting for backend completion |
| Data Security | Avoiding production data exposure during development | Maintains data privacy and security compliance |
| Testing | Creating test datasets for external dependencies | Ensures consistent and controlled test data |
Getting Started#
1
Create an endpoint or import an API spec. The endpoint must have a specified response.
2
Navigate to the
Mock tab and click the mock URL to copy it.
3
Paste the URL in your browser to retrieve mock data. Refresh the page to generate new data.
Mock Capabilities#
Apidog's mock functionality supports various response types:Mock Server Types#
Apidog offers three mock server options to suit different development needs:Local Mock#
Local mock runs on your computer alongside the Apidog client. It operates only when the client is open.Installed automatically with Apidog client
Starts when Apidog client launches
Accessible only while client is running
Cannot be disabled or removed from environments
Best for: Local frontend debugging and individual developmentAvailability: Apidog Client only (not available in Apidog Web)Find the Local mock server URL in the environment management popup under "Local mock environment."
Cloud Mock#
Cloud mock provides the same functionality as local mock but runs on Apidog's servers. It remains accessible regardless of whether your local machine is running.Available 24/7 from any location
Supports encrypted access
Can be toggled on/off as needed
Best for: Sandbox environments for public APIs and team collaborationLearn more about configuring and using Cloud mock. Runner Mock#
Runner mock operates on your team's self-hosted runner infrastructure. After deploying a runner on your server, all team members can access mock data through it.Self-hosted on your infrastructure
Available independently of local machines
Shared across all team members
Best for: Large-scale automated testing and sandbox environments for internal/private APIsAccessing Mock Servers#
You can access mock data through two primary methods:URL Access#
Every HTTP endpoint in Apidog includes a Mock module:In DESIGN mode: Found in the API tab
In DEBUG mode: Found in the Mock tab
From this module, you can copy the mock URL and use it in any application or tool to request mock data.If an endpoint defines multiple responses or mock expectations, each will have its own unique mock URL.
You can click Request to test the mock URL directly within Apidog.The Click to copy button copies only the URL. You must manually add the HTTP method and request body when using the URL elsewhere.
Accessing Mock Within Apidog#
Each Apidog project includes Local mock and Cloud mock environments in the environment switcher (top right corner).When you select a mock environment, all requests in Apidog are automatically routed to that mock server.Only endpoints with paths starting with / will be sent to the mock environment. Endpoints with complete URLs (not starting with /) will not use the mock environment.
Mock request URL usage instructions#
When using the Mock feature, make sure the request Method is the same as the one defined in the API. Suppose:The corresponding Mock request URLs are as follows:Local Mock address#
Cloud Mock address#
Simply define an API or data structure, and Apidog will automatically generate Mock data with no additional configuration required. You can access the addresses above to get the returned result.Local Mock#
http://127.0.0.1:4523/m1/{projectID}-{versionNo}-{serverNo}/{endpointPath}
http://127.0.0.1:4523/m1/18600-0-0/users/123
http://127.0.0.1:4523/m2/{projectID}-{versionNo}-{serverNo}/{endpointId}
http://127.0.0.1:4523/m2/18600-0-0/84924
Cloud Mock#
https://mock.apidog.com/m1/{projectID}-{versionNo}-{serverNo}/{endpointPath}
https://mock.apidog.com/m1/18600-0-0/users/123
https://mock.apidog.com/m2/{projectID}-{versionNo}-{serverNo}/{endpointId}
https://mock.apidog.com/m2/18600-0-0/84924
The Cloud Mock URL provided by Apidog changes from time to time and is for testing only. Do “not” use it in production environments. If needed, you can use the Self-Hosted Runner Mock feature. Parameter Description#
Project ID: Open the project in Apidog and go to the “Project Settings” page to view it.
API ID: You can view it at the “API name”.
Version number: Enter 0 by default, which indicates the main version (multi-version functionality has not yet been released).
Service number: Enter default for the default service. When the API does not exist under the default service, the system will automatically search other services for an API with the same path.
Usage Tips#
1.
The local Mock service listens on 127.0.0.1 by default. If you need access from other devices, replace the IP with your machine’s LAN address. If it cannot be accessed, check whether your firewall or port 4523 is blocked.
2.
If multiple APIs in the project have the same Method + Path, use the following methods to avoid conflicts:Path mode: Add the ?apidogApiId={endpointId} query parameter.
ID mode: No additional action is required. Use the API ID directly.
3.
If the API path does not start with /, you can only use API ID mode.
4.
Starting Apidog starts the Mock service by default. No manual startup is required.
5.
The base URL of the Mock service is fixed and cannot be modified.
Legacy Local Mock#
http://127.0.0.1:4523/mock/{projectID}/{endpointPath}
http://127.0.0.1:4523/mock/18600/users/123
http://127.0.0.1:4523/mock2/{projectID}/{endpointId}
http://127.0.0.1:4523/mock2/18600/84924
Legacy addresses are still supported, but they will be gradually deprecated. We recommend switching to the new format as soon as possible.
How do I get an API Mock URL?#
Go to the “Endpoint” tab and expand the “Mock” section to view the current API’s Mock address.