User Agents

Web browsers and everyday web tech, explained

Capture Browser Code and API Methods Screenshots

· 5 min read · Browsers

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

Capturing screenshots of browser code and API methods allows developers and testers to document technical behavior, share bugs with teammates, and archive the state of a web application's network requests. This process involves using the browser's built-in Developer Tools to expose the underlying HTML, CSS, and JavaScript, as well as the Network tab where API calls (XHR/Fetch) are logged. By following these steps, you can create clear, professional visual records of how a URL is functioning under the hood.

What You'll Need

  • A modern web browser (Google Chrome, Mozilla Firefox, Microsoft Edge, or Safari).
  • The specific URL you wish to analyze.
  • A screen capture tool (built-in OS tools like Snipping Tool on Windows or Cmd+Shift+4 on macOS, or a browser extension like GoFullPage).
  • Developer Tools access (usually enabled by default in all modern browsers).

Step-by-Step

  1. Open the Target URL: Launch your browser and navigate to the website or API endpoint you need to document. Ensure the page is fully loaded before proceeding.
  2. Launch Developer Tools: Right-click anywhere on the page and select Inspect, or use the keyboard shortcut F12 (Windows) or Cmd + Option + I (Mac). This opens the DevTools panel, typically on the right or bottom of the screen.
  3. Capture HTML/CSS Code:
    • Click on the Elements tab (called Inspector in Firefox).
    • Use the element selector tool (the small arrow icon in the top-left corner of DevTools) to click on a specific part of the webpage.
    • The corresponding code will be highlighted in the DOM tree. Expand any nested tags to show the full structure.
    • Adjust the panel width so the code is clearly visible without excessive wrapping.
  4. Capture API Methods and Network Requests:
    • Switch to the Network tab in the DevTools panel.
    • Refresh the page (F5 or Cmd + R) to capture all initial API calls.
    • To isolate API methods, click the Fetch/XHR filter. This removes images and stylesheets, leaving only the data requests.
    • Click on a specific request name to open its details.
    • Navigate to the Headers sub-tab to show the Request URL, Request Method (GET, POST, PUT, DELETE), and Status Code.
    • Navigate to the Response or Preview sub-tab to show the JSON data returned by the API.
  5. Prepare the View for the Screenshot:
    • If the code is too long, use the scroll bar to position the most relevant lines in the center of the view.
    • Use Ctrl + or Cmd + to zoom in on the text if the font size is too small for a clear image.
    • Ensure the DevTools window is docked in a way that does not obscure the part of the website you are referencing.
  6. Execute the Screenshot:
    • For a specific area: Use your OS screenshot tool to drag a box around the specific code block or API header.
    • For a full DevTools screenshot: In Chrome, press Ctrl + Shift + P (Windows) or Cmd + Shift + P (Mac) while DevTools is focused. Type "Screenshot" and select Capture area screenshot to precisely select the code panel.

Common Mistakes

  • Forgetting to Refresh: Opening the Network tab after the page has already loaded results in an empty list. Always refresh the page while the Network tab is open.
  • Capturing Too Much: Including your entire desktop, browser tabs, and bookmarks bar makes the screenshot look unprofessional and distracts from the technical data.
  • Overlooking Filters: Trying to find an API call in the "All" tab of the Network panel when there are hundreds of images and scripts makes the screenshot cluttered. Always use the Fetch/XHR filter.
  • Ignoring Response Data: Only capturing the request header without the response body often leaves the recipient wondering if the API call actually succeeded or what data it returned.

Tips

  • Use Dark Mode: If your team prefers it, switching DevTools to Dark Mode can make syntax highlighting in the code pop more effectively in screenshots.
  • Highlighting: Before taking the shot, click on the specific line of code or the specific API request to highlight it in blue, drawing the viewer's eye to the point of interest.
  • Annotate: After capturing the image, use a tool like Markup or Canva to add red arrows or boxes around the specific API method (e.g., "POST") or the line of code causing an error.
  • Console Logs: If the API method is triggering a JavaScript error, capture a screenshot of the Console tab alongside the Network tab for a complete picture.

Troubleshooting

  • Network Tab is Empty: Ensure you have not accidentally applied a filter in the search box (e.g., searching for a keyword that isn't in the URL). Clear the filter box and refresh.
  • Code is Truncated: If the HTML is too deep, the browser may collapse elements. Manually click the small triangles next to the HTML tags to expand the code before snapping the photo.
  • API Response is Unreadable: If the response is a giant wall of text, click the Preview tab instead of Response. The browser will format the JSON into a clickable, readable tree structure.
  • DevTools is Blocking the View: If you need to show the code and the visual result simultaneously, right-click the DevTools window and select Undock into separate window. This allows you to arrange both windows side-by-side.

Frequently Asked Questions

Can I capture a screenshot of a hidden API call?

Yes, as long as the call is made by the browser, it will appear in the Network tab. Even if the call happens in the background (AJAX), the DevTools will log it.

Is there a way to save the API response as a file instead of a screenshot?

Yes. Right-click the request in the Network tab and select Save all as HAR with content. This saves a JSON file containing all request and response data.

Why does the code look different in the Inspector than in the source file?

The Inspector shows the DOM (Document Object Model), which is the live state of the page. JavaScript may have modified the HTML after the page loaded, which is why the Inspector is more accurate for debugging.

Does capturing these screenshots expose sensitive data?

Potentially. API headers often contain Authorization tokens or Cookies. Always blur or crop out sensitive keys and passwords before sharing screenshots publicly.

Which browser is best for capturing API methods?

Chrome and Firefox are generally considered the industry standards due to their robust Network and Elements panels, though Edge (which is Chromium-based) offers nearly identical functionality.