User Agents

Web browsers and everyday web tech, explained

How to Test API Endpoints in Chrome

· 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

Testing API endpoints in Chrome allows developers to verify server responses, debug issues, and validate data formats directly from the browser. This process is essential during development and troubleshooting to ensure endpoints behave as expected under various conditions. Chrome’s built-in developer tools, particularly the Network tab and Console, provide a robust environment for inspecting, sending, and analyzing API requests without needing third-party software. With proper setup and understanding, you can efficiently monitor HTTP status codes, headers, payloads, and timing to confirm API functionality.

What You'll Need

  • Google Chrome browser (version 80 or later recommended)
  • A web page that makes API calls or a local development server
  • Access to the API endpoints you want to test (public or authenticated)
  • Basic understanding of HTTP methods (GET, POST, PUT, DELETE)
  • Developer tools access (F12 or right-click > Inspect)

Step-by-Step

  1. Open Google Chrome and navigate to a web page that interacts with the API, such as a frontend application calling backend services. If no page exists, create a minimal HTML file with JavaScript that makes fetch() or XMLHttpRequest calls.
  2. Right-click anywhere on the page and select Inspect to open Developer Tools. Alternatively, press F12 or Ctrl+Shift+I (Cmd+Option+I on Mac).
  3. Click the Network tab in Developer Tools. This tab captures all network activity, including API calls made by the page.
  4. Check the Preserve log checkbox at the top of the Network tab to retain entries across page navigations or refreshes.
  5. Trigger the API call by interacting with the page—clicking a button, submitting a form, or loading data. If using a script, ensure it executes (e.g., via Console or auto-run).
  6. Locate the API request in the Network tab’s list. Look for entries labeled with the correct method (GET, POST, etc.) and the expected endpoint URL.
  7. Click the request to view detailed information in the right panel. Examine the Headers tab to verify request URL, method, headers (like Content-Type, Authorization), and query parameters.
  8. Switch to the Response tab to see the server’s returned data. For JSON APIs, this displays structured or raw data. Check if the format matches expectations.
  9. Review the Status code in the overview list or Headers tab. A 200-series code indicates success; 4xx or 5xx signals client or server errors.
  10. To manually test different payloads, go to the Console tab and use JavaScript commands. For example, type fetch('/api/users', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({name: 'John'}) }) and press Enter.
  11. Observe the result in the Console. If the request succeeds, it returns a Promise; use .then(response => response.json()).then(console.log) to view the response body.
  12. For authenticated APIs, ensure cookies or authorization headers are present. You can inspect them in the Request Headers section or manually include tokens in fetch() calls.
  13. Use the Preview tab in Network to view formatted JSON, images, or HTML responses for easier reading.
  14. Clear the log with the Clear button (round icon with slash) and repeat steps to test different scenarios or endpoints.

Common Mistakes

  • Forgetting to enable Preserve log, causing requests to disappear after navigation.
  • Not checking CORS (Cross-Origin Resource Sharing) errors, which block requests from mismatched origins.
  • Misreading status codes—e.g., assuming a 200 response means business logic succeeded when it may return an error in the body.
  • Overlooking request headers like Authorization or Content-Type, leading to 401 or 400 errors.
  • Testing on cached responses without disabling cache (use Disable cache in Network tab during inspection).

Tips

  • Use Filter in the Network tab to search for specific endpoints by name or path.
  • Copy request as cURL: Right-click a request and select Copy > Copy as cURL to reuse in terminal or Postman.
  • Simulate slow networks using the Throttling dropdown to test performance under poor conditions.
  • Export network logs via right-click > Save as HAR for sharing or offline analysis.
  • Use breakpoints in JavaScript to pause before API calls and inspect variables or modify payloads.

Troubleshooting

If API calls do not appear in the Network tab, ensure they are actually being made—check your JavaScript for errors in the Console. A blank list often means the script failed before sending the request. If requests show but return errors, expand the entry and check the Headers and Response tabs. For CORS issues, the browser blocks requests from unauthorized domains; this cannot be bypassed in production but can be temporarily disabled in Chrome for local testing using command-line flags (not recommended for regular browsing). If responses seem incorrect, verify the request payload and URL parameters. Use the Console to manually send a corrected fetch() call. If authentication fails, confirm tokens are valid and properly formatted in headers. For 404 errors, double-check the endpoint URL and routing configuration. If the server times out, inspect the Timing tab to identify slow phases like DNS lookup or SSL handshake.

Frequently Asked Questions

Can I test POST requests in Chrome?

Yes. Use the Console to run fetch() with method: 'POST' and include headers and body. Monitor the Network tab to confirm the request was sent and view the response.

Why don’t I see my API request in the Network tab?

The request may not have been sent due to JavaScript errors, or caching may have suppressed it. Ensure scripts run correctly and disable cache in Developer Tools.

How do I view JSON responses clearly?

Click the request in the Network tab and go to the Preview tab, which formats JSON for easy reading. The Response tab shows raw text.

Can Chrome test APIs without a frontend page?

Yes. Create a local HTML file with JavaScript to call APIs, or use the Console directly to send fetch() requests.

Is it safe to test APIs in Chrome with real data?

Only if you control the environment. Avoid sending sensitive data in production unless properly secured. Use test or staging endpoints when possible.

Does Chrome Developer Tools work offline?

Yes, for inspecting cached requests or running Console commands, but actual API calls require network connectivity unless mocked.