Turn a mobile app's API traffic into a collection
The mobile team says "the app calls /v2/feed with some headers". Which headers? What body? In which order on startup? The fastest way to find out, and to get requests you can replay and test, is to record the app's traffic and import it. Browser DevTools can't see a phone, but a debugging proxy can, and most of them export HAR, which Requestarium imports.
1. Record
Any proxy that can decrypt HTTPS and export HAR works. The usual steps are the same:
- Start the proxy on your computer.
- Point the phone's Wi-Fi proxy (or the simulator's network) at it.
- Install and trust the proxy's root certificate on the device.
- Use the app: log in, open the screens, do the action you want to capture.
- Export the session, or just your app's host, as a HAR file. In Charles it's in File ▸ Export Session; Proxyman, mitmproxy and HTTP Toolkit have a HAR export too.
Certificate pinning. If the app pins its server certificate, the proxy sees nothing, or the app fails to connect. Use a debug build with pinning disabled for your proxy's certificate; on Android, debug builds can trust user certificates through the network security config.
Simulators and emulators are the easiest: the iOS Simulator uses the Mac's proxy settings, and the Android emulator can be pointed at a proxy in its settings.
2. Import
Import → Import file… and pick the .har, or from a terminal:
requestarium import ./app-startup.har --dry-run
requestarium import ./app-startup.har --name "Mobile app (recorded)"The import cleans as it goes: images, fonts and other static files are dropped, a call made ten times appears once (unless you keep repeated calls), and requests are grouped in folders per host and path. Responses aren't imported; you get the requests. See turn a HAR file into an API collection for the details.
3. Credentials
Cookie and Authorization headers are left out by default, so your test account's session doesn't end up in a shared workspace. Mobile apps often use other headers for auth too: X-Auth-Token, X-Device-Id, X-Session. The import doesn't know those are secret. Look through the headers and replace such values with variables:
Authorization: Bearer {{mobileToken}}
X-Device-Id: {{deviceId}}and keep the values in an environment's secret variables.
4. Make it useful
What you get is a faithful copy of what the app sent. Turn it into something the team can use:
- Base URL: replace the host with
{{baseUrl}}, so the same requests run against staging and local. - App headers:
User-Agent,X-App-Version,X-Platformare what the backend uses to tell clients apart. Keep them, as variables, to test how the API answers different app versions. - Order: the startup sequence (config, auth refresh, feed, notifications) is worth keeping as a folder in that order. It's the real load the app puts on the API on every launch.
- Tests: add a check to each request. Now a backend change that would break the shipped app shows up as a failing test, before the app store reviews come in.