How to Test REST API Endpoints
Testing API endpoints is a critical part of backend development and integration work. Whether you are debugging a failing request, verifying a new endpoint, or integrating a third-party API, knowing how to test endpoints efficiently saves hours of frustration. This guide covers practical approaches to API testing.
Using curl from the Command Line
curl is the most universal tool for testing APIs. Here are common patterns:
# GET request
curl https://api.example.com/users
# POST with JSON body
curl -X POST https://api.example.com/users \
-H "Content-Type: application/json" \
-d '{"name": "Alice", "email": "alice@example.com"}'
# With authorization header
curl https://api.example.com/protected \
-H "Authorization: Bearer YOUR_TOKEN"Testing Authentication
Most API endpoints require authentication. Here are the common methods:
- Bearer tokens. Include
Authorization: Bearer <token>in the request header. Decode JWTs with the ToolStack JWT Decoder. - Basic Auth. Encode
username:passwordin Base64 using the Base64 Encoder. - API keys. Pass the key as a header or query parameter depending on the API specification.
How to Test an Endpoint Step by Step
- 1Read the documentation. Check the API docs for the endpoint URL, method, required headers, and expected request body format.
- 2Format the request body. Use the ToolStack JSON Formatter to ensure your JSON payload is valid before sending.
- 3Send and inspect. Use the ToolStack API Tester or curl to send the request and inspect the response status, headers, and body.
- 4Decode tokens. If the response includes a JWT, decode it with the JWT Decoder to inspect the claims and verify correctness.
Try It: Test an API Endpoint
Use our free API Tester to send HTTP requests and inspect responses without leaving your browser.
Open API Tester