An API lets one program talk to another. Testing an API means sending a request by hand and looking at the answer, which is the fastest way to understand how a service works or to find out why your code gets an error.
The parts of a request
- Method: what you want to do.
GETreads data,POSTcreates data,PUTandPATCHchange data andDELETEremoves it. - URL: where the request goes, for example
https://api.example.com/users/1. - Headers: extra information, such as the type of data you send or an access token.
- Body: the data you send with
POST,PUTorPATCH, often as JSON.
The parts of a response
- Status code:
200means success,201means created,400means the request was wrong,401or403mean you are not allowed,404means not found and500means the server failed. - Headers and a body, usually JSON.
Send your first request
- Open the API Tester.
- Choose
GETand enter the address of a public API you want to try. - Press send and read the status code and the body.
- Change the method to
POST, add a JSON body and a headerContent-Type: application/json, then send again.
Read the answer
If the body is one long line, paste it into the JSON Formatter to see the structure. If a request fails with a syntax error, check your own body with the JSON Validator. Many APIs use tokens in the Authorization header: a token that is a JWT can be inspected with the JWT Decoder.
Common problems
- 401 Unauthorized: the token is missing, wrong or expired.
- 404 Not Found: a typo in the address, or the item does not exist.
- 400 Bad Request: the body has a missing or wrongly typed field. Read the error message the API returns.
- CORS errors in a browser: a browser blocks a page from calling another website's API unless that API allows it. This is a browser rule, not a bug in your request.
Be careful with secrets
Never share real passwords, private keys or live tokens with a tool you do not control, and do not paste them into screenshots or chats. Use test keys while you learn.