How to Test REST APIs Online (A Beginner Guide)

Learn what an API request is made of, how to send one and how to read the response, using the free API Tester.

Tryyourselfs Team· · 2 min read Guide

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. GET reads data, POST creates data, PUT and PATCH change data and DELETE removes 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, PUT or PATCH, often as JSON.

The parts of a response

  • Status code: 200 means success, 201 means created, 400 means the request was wrong, 401 or 403 mean you are not allowed, 404 means not found and 500 means the server failed.
  • Headers and a body, usually JSON.

Send your first request

  1. Open the API Tester.
  2. Choose GET and enter the address of a public API you want to try.
  3. Press send and read the status code and the body.
  4. Change the method to POST, add a JSON body and a header Content-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.

apirestapi testinghttp

Was this article helpful?

Put it into practice

Try it yourself