API Directory โ€บ Guides โ€บ How to Test an API (Browser, curl & Postman)

How to Test an API (Browser, curl & Postman)

Before writing app code, test the API. Here are three easy ways โ€” from pasting a URL to using a proper API client.

‘Testing an API’ means two different things: exploring a third-party API to see how it behaves, and automated testing of code that depends on an API. Both matter.

Exploring by hand

BrowserFastest for a GET with no auth — paste the URL. Install a JSON formatter extension.
curlScriptable, shows exactly what is sent. -i shows response headers, -v shows the whole exchange.
Postman / Hoppscotch / InsomniaGUI clients: save requests, set environment variables, run collections, inspect history.
HTTPieA friendlier curl: http GET api.example.com/data Authorization:"Bearer $KEY".
‘Try it’ console in the docsPre-fills auth and shows the generated request.
# inspect headers and status
curl -i "https://api.example.com/v1/data?q=lagos"

# see the full request + TLS handshake
curl -v https://api.example.com/v1/data -H "Authorization: Bearer $KEY"

# pretty-print JSON
curl -s https://api.example.com/v1/data | jq .

What to actually check while exploring

Automated tests for code that calls an API

Simulating failures

Use httpbin or Postman Echo to force specific behaviour: /status/500, /delay/10, redirects, and various content types. Point your client at those to prove your retry, timeout and error handling work before you meet the real thing.

FAQ

What is the easiest way to test a GET API?

Paste the URL into your browser (with a JSON formatter extension) or run curl -s URL | jq. For anything with auth or a body, use Postman, Hoppscotch or HTTPie.

Should my tests call the real API?

Unit tests: no — mock the HTTP calls. Keep a few scheduled smoke/contract tests against the real API or its sandbox to catch upstream changes.

How do I test how my code handles a rate limit or outage?

Point it at httpbin (/status/429, /status/503, /delay/n) or a mock server configured to return those, and assert your retry/backoff logic runs.

What is a contract test?

A test that checks the real API still returns the shape your code expects (field names, types, required fields). Run it on a schedule so a provider change surfaces before your users hit it.

Keep going

Try it on a real API

Browse all 196 free APIs โ†’

๐Ÿ”Œ Explore free public APIs

Hundreds of free APIs, searchable by category, with auth & CORS at a glance.

Browse the directory โ†’