Record a website's API calls

Capture the calls a site makes while you use it and import them as requests.

In short

Browser Sync records the API calls a website makes while you use it, and imports them into an API Tester project as requests. You review them first, and can turn a recorded session into a regression suite.

Before you start

Record and import

  1. Open an API Tester project, press the arrow beside "New request" and choose "Record a website…". The "Sync a website" dialog opens.
  2. Under "Record live", type the website's address (https://…). "Only URLs containing" (/api/ to begin with) decides which calls start ticked.
  3. Press "Start recording".
  4. Use the website in another tab. Its calls appear in the dialog as they happen.
  5. Press "Stop & review", untick anything you do not want and press "Import". "Undo import" is offered on the result.

You can also start on the website: open the extension on its tab, choose the project and press "Record". If the site calls its API on another address, tick it under "This page also called", or name one under "More options". You can import a HAR file saved from the browser's developer tools instead, without the extension.

Record from UI test runs

UI Tester tracks that run in your pipeline (kamocore ui run) can send the API calls they make here, so the API tests follow what the UI really does. Each passed run arrives as its own recording; a failed run sends nothing.

  1. In the "Sync a website" dialog, under "From UI test runs", type the origins whose calls to keep - the site's API, and the site itself when it calls its own address.
  2. Press "Get the command" and copy it. Add its --api-capture option to kamocore ui run in your pipeline.
  3. Run the pipeline with your own personal access token, with UiTester and ApiTester read and write.
  4. After each passed track the pipeline log shows how many calls were sent and the address of the recording. Open it, untick what you do not want, and import the calls or create a suite.

The sign-in's calls are never sent, and the secrets a track types never leave the pipeline. As with any recording, only calls to the origins you typed are kept, and passwords, tokens and other secret fields are left out.

Read a recorded session

A recorded session opens with its calls and a row of chips that decide how they are shown. Nothing on it changes the calls themselves.

Good to know

If something goes wrong

Related