Skip to main content
RESTful Principles
CHAPTER 01 Beginner

Introduction to REST APIs

Updated: May 13, 2026
5 min read

# CHAPTER 1

Introduction to REST APIs

1. Introduction

Welcome to the very first chapter of the RESTful Principles tutorial! If you have ever wondered how different software applications "talk" to each other across the internet, you are in the right place. In modern web development, APIs act as the bridges that connect mobile apps, web applications, and backend servers. In this chapter, we will demystify what an API is, understand the core concepts of REST, and explore why it has become the gold standard for web communication.

2. Learning Objectives

By the end of this chapter, you will be able to:
  • Define what an API is in simple terms.
  • Understand the meaning of REST (Representational State Transfer).
  • Differentiate between REST and SOAP architectures.
  • Explain why REST is the most popular architectural style for web APIs.
  • Identify real-world examples of APIs you use every day.

3. Beginner-Friendly Explanation

Imagine you are at a restaurant. You sit at the table with a menu of choices, and the kitchen is the system that prepares your food. However, you can't just walk into the kitchen and cook your own meal. You need a link to communicate your order to the kitchen and bring the food back to your table. That link is the waiter.

In the software world, an API (Application Programming Interface) is the waiter. It takes a request from the client (you), tells the system (the kitchen) what to do, and returns the response (your food) back to you.

REST (Representational State Transfer) is a set of rules or guidelines on how that waiter should behave. It isn't a strict language or a tool; it's an *architectural style*. When an API follows these REST principles, we call it a RESTful API.

4. Real-World Examples

  • Weather Apps: When you check the weather on your phone, the app doesn't have a built-in thermometer. It sends an API request to a weather service (like OpenWeatherMap), which returns the current temperature data to display on your screen.
  • Social Media Login: When a website allows you to "Log in with Google," it uses Google's API to verify your identity without Google ever sharing your password with that website.
  • Online Shopping: When you pay with Stripe or PayPal on an e-commerce site, the store uses an API to securely send your payment details to the payment processor.

5. Detailed Code Examples

While we will dive deeper into code in later chapters, here is a conceptual look at how simple a REST API request can be using the widely-used cURL tool in the terminal.
bash
12
# Fetching user data from a mock API
curl https://jsonplaceholder.typicode.com/users/1

6. Request/Response Examples

When the above request is sent, the server processes it and sends back a response.

Request:

http
123
GET /users/1 HTTP/1.1
Host: jsonplaceholder.typicode.com
Accept: application/json

Response:

http
123456789
HTTP/1.1 200 OK
Content-Type: application/json

{
  "id": 1,
  "name": "Leanne Graham",
  "username": "Bret",
  "email": "Sincere@april.biz"
}

7. HTTP Examples

REST relies heavily on standard HTTP methods. A typical REST request utilizes methods like GET to read data, POST to create data, PUT to update data, and DELETE to remove data.

*Example: Creating a new user via POST.*

http
12345678
POST /users HTTP/1.1
Host: api.example.com
Content-Type: application/json

{
  "name": "John Doe",
  "email": "john@example.com"
}

8. JSON Examples

REST APIs format data in a way that is easy for both humans to read and machines to parse. The most standard format is JSON (JavaScript Object Notation).
json
12345
{
  "api_status": "active",
  "version": "v1",
  "supported_formats": ["json", "xml"]
}

9. Best Practices

  • Use standard JSON: Always default to JSON for sending and receiving data, as it is lightweight and universally supported.
  • Keep it simple: Do not overcomplicate your API design. A beginner should be able to look at your API URL and guess what it does.
  • Use nouns, not verbs: A REST API URL should represent a "thing" (e.g., /users), not an action (e.g., /getUsers).

10. Common Mistakes

  • Confusing an API with a Database: An API is the messenger; it is not the database itself. The API talks to the database on your behalf.
  • Thinking REST is a protocol: REST is an architectural style, whereas HTTP is the actual protocol used to transmit the messages.

11. Mini Exercises

  1. 1. Open your terminal or command prompt.
  1. 2. Run this command: curl https://catfact.ninja/fact
  1. 3. Observe the JSON response returned by the server. You just interacted with a REST API!

12. Coding Challenges

Challenge 1: Using any browser, navigate to https://pokeapi.co/api/v2/pokemon/pikachu. Look at the raw output. Can you identify the "weight" and "height" properties in the JSON text?

13. MCQs with Answers

Question 1

What does API stand for?

Question 2

What does REST stand for?

Question 3

Which data format is most commonly used in modern REST APIs?

14. Interview Questions

  • Q: Explain what a REST API is to a non-technical person.
  • Q: What are the primary differences between REST and SOAP?
  • Q: Why has REST become more popular than SOAP for modern web development?

15. FAQs

Q: Do I need to know a specific programming language to understand REST? A: No! REST is language-agnostic. You can build and consume REST APIs using PHP, Python, JavaScript, Java, or almost any other language.

Q: Is REST the only way to build APIs? A: No. There are other architectures like SOAP, GraphQL, and gRPC. However, REST is the most widely adopted standard across the web.

16. Summary

In this chapter, we learned that an API is a communication bridge between different software systems. We discovered that REST is a popular architectural style that dictates how these APIs should be built, prioritizing simplicity, standard HTTP methods, and commonly the JSON data format. We also looked at real-world examples and executed a basic API request.

17. Next Chapter Recommendation

Now that you know what an API is, we will dive deeper into how clients and servers interact. Proceed to Chapter 2: Understanding APIs and Web Services to explore client-server architecture and the specific differences between standard web services and modern APIs.

Finish this Chapter

Save your progress on your learning path and prepare for coding interview challenges.

Discussion

Join the discussion

Log in or create a free account to participate.

Sort: ·