How can I use Appium to capture network traffic during mobile app automation?

I’m building a mobile automation framework using WebdriverIO with Appium, and I need to capture API calls made when users tap different sections of the app. These API requests are crucial for analytics and product planning.

Currently, manual QA uses Charles Proxy to inspect traffic. I’m exploring automated options.

Has anyone successfully implemented a solution for Appium capture network traffic during mobile UI automation? Any tools or setup suggestions would be really helpful.

We had a similar requirement and ended up integrating mitmproxy with Appium. Basically, we routed all device traffic through a mitmproxy running on the test machine.

It acts as a programmable man-in-the-middle proxy, letting us capture and even assert API requests during the test.

We configured the device to trust the proxy certificate and set the proxy at the system level for Android and iOS simulators. It took a little setup but gave us full visibility without touching app code. Totally worth it.

In our WebDriverIO + Appium setup, we couldn’t directly hook into the network layer like in a browser, so we used BrowserMob Proxy with the Appium server.

We launched the proxy as a separate process, captured traffic into HAR files, and parsed them post-test. It works well with Android emulators especially.

One caveat: iOS is trickier due to certificate issues, so we focused Android-first. If you’re used to Charles manually, this feels very similar, just programmatically controlled.