Record API calls

Hi !

I’d like to record API calls that are done during a navigation path. The goal is to be able to reuse it as an automated test in some tool by adding some assertions for every step recorded.

I see that Postman has something like this (https://learning.postman.com/docs/sending-requests/capturing-request-data/interceptor/) but installing it requires some work.

Do you know if there are other ways ?

Thank you !

2 Likes

What kind of API are you wanting to record “and playback”? I know Fridays are never a good day to hear bad news, but, depending on the API nature, it can be a bad idea indeed. I’ve used a traffic playback device or two, these work well for things like USB peripherals and some network traffic interactions, but ultimately get complicated fast. People forget that’s why Postman is a commercial product. Capture and playback is also great for security checks, but that’s a tool used in a very different fashion to what you want to achieve.

I’m still assuming you are talking about playback tools, if so please do provide a bit more context around your business value and platform limitations.

1 Like

There are a lot of tools out there to record APIs, but what is the end-goal here?
Are you trying to edit the calls or playback?

Any tool and any recording will most likely use a proxy in your browser to capture traffic, maybe add an certificate.

I personally find Postman quite useful for it (even the free version), if you need any help with that, then let us know!

If you just want to see the traffic, you can use build in developer tools in your browser. By going to the Network tab and then filter on “Fetch/XHR” (remember to tag on Preserve log)

2 Likes

Since you mention Postman, Postman has a feature where it “translates” your REST API request to “source code”. Then you can reuse the “code” in any manner that you want.

Do you know playwright?

I think what you’re referring to is called network replaying.
It’s useful when doing manual testing of a certain bug and you’re trying to understand what network requests that are being launched from your browser to your backend or 3rd party services.

If that’s the cases, then here we go again with self promotion: yes it’s me telling you about my product again.

I am building a tool to play back your sessions, not sure if you want to playback the whole session but with my tool you can do video, network requests and chrome console logs.
It’s free - and it’s called Dashcam. Here’ an example of what a recording looks like: Dashcam

Mods, if this is not allowed let me know, but I truly think this answers the OP’s question about capturing Network/API requests after they happened

1 Like

Thank you for your replies and I’m sorry that my question was too vague and unclear.

My goal it’s not really to reproduce bugs (even if Dashcam that I discovered can be very helpful !) but to record some steps and be able to rerun these steps in order to verify that the answer is ok.
For instance : answer to a survey on a form composed by 15 questions and check that all the answers are correctly saved. So you do 15 POST and verify that the answer is ok, then you can do some GET in order to check that the answers are consistent with what has been typed.

I think, you perhaps want to ask yourself, what exactly is it you are testing, which component. and focus in on the failure modes for that component and test those instead of trying to system-test. From here it looks like you need a mock, or a shim, not a network playback/sniffing tool.

I would suggest trying the chrome plugin created by Blazemeter which records jmeter scripts. This will quickly give you an idea of what API calls are being made in the background. You also have the option to export as a jmeter or selenium script. Alternatively, open devtools in any browser and follow along as you click through the workflow (network and/or console tabs).

1 Like

Yes exactly I found that these plugins are ok to record the calls.
Their goal is to do a load test in Jmeter but probably exporting in Selenium instead can help to add the assertion part.

I’ll also try to import the calls that I need as cURL in Postman like they explain here : Postman

1 Like

Solving the make 15 api calls and make assertions along the way, can be done with any tool that allows you to make HTTP requests (including postman) but will take some work to organize it (especially if there is authentication involved).

Having a tool that can record the steps and replay them is a bit of a bigger ask, but anything you record would still need to be modified more than likely for auth.

My tool of choice for tasks like this is Playwright, and it would be to build out the api calls that are made in code from inspecting the network requests in Chrome dev tools when filling out a form/survey.

This is a guide I’ve been working though to build out API Tests using the tool which could be helpful The Definitive Guide to API Test Automation With Playwright: Introduction

2 Likes