REST APIs explained for freshers

By SamkhyaAcademy Team · · 5 min read

REST APIs explained for freshers

REST APIs explained for freshers: what an API is, how requests and responses work, common methods, status codes, JSON, authentication and how to try one yourself.

You use APIs many times a day without noticing. When a weather app shows today's forecast, a shopping site checks a payment, or a map app finds the route, programs are talking to each other through APIs. If you want to become a developer or a tester, you need to understand them. This guide explains REST APIs from the beginning in simple words.

What is an API?

API stands for Application Programming Interface. It is a set of rules that lets one piece of software ask another for data or actions. Think of a restaurant: you (the client) tell the waiter (the API) what you want, the waiter takes the order to the kitchen (the server), and brings back your food (the response). You never go into the kitchen, and you do not need to know how the food is cooked.

What does REST mean?

REST is a popular style for building web APIs. In a REST API, everything is a "resource", such as a user, an order or a course. Each resource has an address, called an endpoint, and you use standard HTTP methods to work with it. REST APIs are stateless, which means each request carries all the information the server needs, and the server does not remember earlier requests.

The parts of a request

  • URL (endpoint): where to send the request, for example https://api.example.com/courses/12.
  • Method: what you want to do, such as GET or POST.
  • Headers: extra information, such as the data format or an access token.
  • Body: data you send, used with POST, PUT and PATCH.
  • Query parameters: filters added to the URL, such as ?city=Bengaluru.

The common HTTP methods

  • GET: read data, for example get the list of courses.
  • POST: create something new, for example register a student.
  • PUT: replace an existing resource completely.
  • PATCH: change part of a resource.
  • DELETE: remove a resource.

A simple example

A request such as GET /courses/12 asks for the course with ID 12. The server replies with data, most often in JSON format, which is easy for both humans and programs to read:

{ "id": 12, "title": "Full-Stack Development", "mode": "online", "duration_weeks": 16 }

To create a student, you might send a POST request to /students with a body such as:

{ "name": "Asha", "email": "asha@example.com" }

and the server would reply with the new record and the code 201.

Status codes

Every response includes a number that tells you what happened.

  • 200 OK: the request worked.
  • 201 Created: something new was created.
  • 204 No Content: success, with nothing to return.
  • 400 Bad Request: your request was wrong or incomplete.
  • 401 Unauthorized: you are not logged in or your token is missing.
  • 403 Forbidden: you are logged in but not allowed.
  • 404 Not Found: that resource does not exist.
  • 500 Server Error: the server had a problem.

Authentication in brief

Many APIs need proof of who you are. Common ways are API keys and tokens sent in a header. Never put secret keys in public code or on GitHub. Always use HTTPS so the data is encrypted while travelling.

Try one yourself

  1. Open a free practice API made for learners, which returns fake sample data.
  2. Use your browser, or a tool such as Postman, to send a GET request to a list endpoint.
  3. Read the JSON response and the status code.
  4. Send a POST request with a small JSON body and see the result.
  5. Try a wrong address and a missing field to see 404 and 400 responses.

Why this matters for your career

Developers build APIs so that web pages, mobile apps and other services can use the same back end. Testers check APIs for correct data, correct status codes, error handling, speed and security, which is often faster and more stable than testing through the screen. Knowing APIs also helps you understand how modern applications fit together.

Good API habits

  • Use clear, consistent names such as /students and /students/5.
  • Return helpful error messages.
  • Validate all input.
  • Document the API so others can use it.

Common beginner mistakes

  • Confusing PUT and PATCH: PUT replaces the whole resource, PATCH changes only some fields.
  • Ignoring status codes and only looking at the response text.
  • Forgetting the Content-Type header when sending JSON.
  • Sending secret keys from the browser where anyone can see them.
  • Not reading the API documentation before testing.

How testers check an API

A tester sends requests with valid data and checks the response code and body. Then they send invalid data, missing fields, very long values and requests without a token, and check that the API returns sensible errors and does not leak information. They may also check how long the response takes. You can practise all of this for free in Postman with a public practice API, and save your requests as a collection to show in your portfolio.

Where to go next

Once you are comfortable sending requests, build a tiny API yourself with a language you know, with endpoints to list, add, change and delete items. Then write tests for it. This small project covers routing, data, validation and testing in one place.

Ready for the next step?

Build real APIs in our Full-Stack Development program. If you would like guidance from people who work in the industry, join our free career guidance workshop or request a free career discovery session. We will look at your background and help you plan what to learn and build next.

Need career guidance from industry experts?

Join our free workshop or request a free career discovery session.

Keep reading