You can use Hoverfly to Capture a simulation. This means creating the simulation by saving the request and response pairs to a file.
The Capture method you use will depend on the location of the service; either available on the internet or behind a firewall without network access between the service and Hoverfly Cloud.
Start by clicking the Capture button.
The simplest way to create a simulation is by capturing real API traffic. The prerequisite is that the API you are going to capture must be available on public internet; use the Hoverfly Cloud Agent if the API is behind a firewall.
Enter the base URL of the target API, for example “http://time.jsontest.com”.
Click OK and the simulation will start on the dashboard in Capture mode.
Once you start making requests to the API, Hoverfly Cloud will capture the traffic behind the scene.
You can copy the
curl or Hoverfly Cloud agent commands by clicking on the “Show usage” button.
See here for more details on making request to the capture service.
Click on the simulation link and you can review what requests and responses have been captured.
You can edit and export the captured simulation for future use.
If the API you would like to capture is behind a firewall, you can use Hoverfly Cloud agent to do the capturing.
Start Hoverfly Cloud agent dashboard:
hoverfly-cloud-agent dashboard --api-token $HFC_TOKEN
The dashboard should be available on http://localhost:8900.
Click on capture, and specify the base URL.
You will get a localhost URL which you should make your requests to instead of the actual URL.
Once you are done, click “Stop” and it will prompt you to enter the name for the simulation.
Click “OK” will publish your simulation to your Hoverfly Cloud account.
It is also possible to create simulation of non-existent API. You can access the Simulation Editor in Simulation page by clicking “Create”.
Click on “Add request response pair” to add your first definition of the API.
Add and edit the request you want to match and the corresponding response.
You can click on “duplicate” to reuse existing pair.
Once you are happy about your simulation, you can click “Save”.
Click “From Swagger” to create a simulation from a Swagger document.
Enter a simulation name.
Click “Choose file” and select a Swagger file from disk.
Click Confirm button to finish.
If you are already using open source Hoverfly, you can upload your existing Hoverfly simulation file in the Simulation page: