API Testing and Debugging with Developer Tools
Test REST APIs effectively using browser DevTools, curl, and dedicated API testing tools.
Key Takeaways
- API testing verifies that endpoints return correct data, handle errors gracefully, and perform within acceptable latency.
- The Network tab shows every HTTP request your application makes.
- curl is the most universal API testing tool โ available on every platform.
- Postman provides a GUI for building requests, organizing them into collections, and running automated tests.
- 401 Unauthorized: check authentication headers and token expiration.
Hash Generator
Generate SHA-1, SHA-256, SHA-384, SHA-512 hashes from text
API Testing Fundamentals
API testing verifies that endpoints return correct data, handle errors gracefully, and perform within acceptable latency. Unlike UI testing, API tests are fast, reliable, and provide direct feedback on backend functionality. Every developer should be comfortable testing APIs manually and automating those tests.
Browser DevTools Network Tab
The Network tab shows every HTTP request your application makes. Filter by XHR/Fetch to see API calls. Inspect request headers, body, and response data. Right-click any request to copy as curl โ this gives you a command-line equivalent with all headers and cookies. The timing breakdown shows DNS, connection, TTFB, and download times.
curl for Direct API Testing
curl is the most universal API testing tool โ available on every platform. Basic GET: curl -s https://api.example.com/users | jq. POST with JSON: curl -X POST -H "Content-Type: application/json" -d '{"name":"test"}' https://api.example.com/users. Add -v for verbose output showing headers. Add -w '\n%{http_code}' to display the status code.
Dedicated API Testing Tools
Postman provides a GUI for building requests, organizing them into collections, and running automated tests. Insomnia offers a similar experience with a cleaner interface. HTTPie is a friendlier command-line alternative to curl with colored output and intuitive syntax. For load testing, k6 and Apache Bench (ab) measure performance under concurrent requests.
Common API Issues
401 Unauthorized: check authentication headers and token expiration. 403 Forbidden: valid auth but insufficient permissions. 404 Not Found: verify the URL path and HTTP method. 422 Unprocessable: check request body format and required fields. 500 Internal Server Error: server-side issue โ check server logs. CORS errors: browser security policy blocking cross-origin requests โ the server needs to set Access-Control-Allow-Origin headers.
๊ด๋ จ ๋๊ตฌ
๊ด๋ จ ํฌ๋งท
๊ด๋ จ ๊ฐ์ด๋
JSON vs YAML vs TOML: Choosing a Configuration Format
Configuration files are the backbone of modern applications. JSON, YAML, and TOML each offer different trade-offs between readability, complexity, and tooling support that affect your development workflow.
How to Format and Validate JSON Data
Malformed JSON causes silent failures in APIs and configuration files. Learn how to format, validate, and debug JSON documents to prevent integration errors and improve readability.
Base64 Encoding: How It Works and When to Use It
Base64 converts binary data into ASCII text, making it safe for transmission through text-based systems. Learn when Base64 is the right choice and when alternatives like hex encoding or URL encoding are more appropriate.
Best Practices for Working with Unix Timestamps
Unix timestamps provide a language-agnostic way to represent points in time, but they come with pitfalls around time zones, precision, and the 2038 problem. This guide covers best practices for storing and converting timestamps.
Troubleshooting JWT Token Issues
JSON Web Tokens are widely used for authentication but can be frustrating to debug. This guide covers common JWT problems including expiration errors, signature mismatches, and payload decoding issues.