Lesson 1 of 158 – Introduction to REST API
1%

Introduction to REST API

REST API is one of the most important technologies used to connect mobile applications with servers and databases.

When you build a React Native application, the app usually needs data from a server. REST API provides a standard way for the mobile app to send requests to the server and receive data in response.

Note: In this course, we will learn REST API with PHP and MySQL and then connect the API with React Native applications.

1. What is an API?

API stands for Application Programming Interface.

An API allows two different software applications to communicate with each other.

For example, a React Native mobile application can communicate with a PHP server through an API.

React Native App → API → PHP Server → MySQL

2. What is REST?

REST stands for Representational State Transfer.

REST is an architectural style used to design web services that communicate using HTTP.

REST commonly uses HTTP methods such as GET, POST, PUT, PATCH and DELETE.

3. What is a REST API?

A REST API is an API designed according to REST principles.

It allows applications to communicate with a server using HTTP requests and responses.

For example:

GET https://example.com/api/students

The server can return student information in JSON format.

4. Why is REST API Important for Mobile Apps?

A mobile application normally does not store all its data directly inside the application.

Instead, the application communicates with a remote server.

REST API provides the communication layer between the mobile application and the server.


React Native
     ↓
  REST API
     ↓
PHP Server
     ↓
 MySQL

5. React Native and REST API

React Native can communicate with REST APIs using technologies such as Fetch API and Axios.

For example, a React Native application can request a list of students from a server.


React Native
     ↓
GET Request
     ↓
REST API
     ↓
MySQL
     ↓
JSON Response
     ↓
React Native

6. Client and Server

REST API communication normally involves a client and a server.

The client sends a request and the server processes the request and returns a response.

In a mobile application, the React Native app acts as the client.

7. React Native as a Client

The React Native application is usually the client in a mobile application architecture.

It can request data from the server.


Mobile App
    ↓
Request
    ↓
REST API

The client can also send data to the server.

8. Server

The server receives requests from the mobile application.

The server can validate the request, communicate with the database, perform business logic and return a response.

In our course, we will use PHP for creating the server-side REST API.

9. Database

A database stores application data.

We will use MySQL as the database in this course.

For example, a student management application may have a students table.


students
----------------
id
name
email
mobile
course

10. Complete Communication Flow

A typical mobile application works through a communication flow.


React Native App
       ↓
   HTTP Request
       ↓
    REST API
       ↓
   PHP Server
       ↓
     MySQL
       ↓
   PHP Server
       ↓
    JSON Response
       ↓
React Native App

11. HTTP Request

An HTTP request is sent by the client to the server.

A request can contain information such as:

  • HTTP method
  • URL
  • Headers
  • Query parameters
  • Request body

12. HTTP Response

After processing a request, the server sends an HTTP response.

A response commonly contains:

  • Status code
  • Response headers
  • Response data

REST APIs commonly return data in JSON format.

13. JSON in REST API

JSON stands for JavaScript Object Notation.

It is commonly used to exchange data between a mobile application and a server.

{
    "id": 1,
    "name": "Rahul",
    "course": "React Native"
}

14. REST API URL

A REST API provides URLs called endpoints.

Example:

https://example.com/api/students

Here, /api/students represents an API endpoint for student resources.

15. API Endpoint

An endpoint is a specific URL through which an application accesses a particular resource.

Examples:


GET    /api/students
GET    /api/students/10
POST   /api/students
PUT    /api/students/10
DELETE /api/students/10

16. GET Request

GET is generally used to retrieve data from the server.

Example:

GET /api/students

The server can return a list of students.

17. POST Request

POST is generally used to send new data to the server.

Example:

POST /api/students

The mobile application can send student information in the request body.

18. PUT Request

PUT is generally used to update an existing resource.

Example:

PUT /api/students/10

This can update the student whose ID is 10.

19. DELETE Request

DELETE is generally used to remove a resource.

Example:

DELETE /api/students/10

This request can delete the student with ID 10.

20. CRUD Operations

CRUD stands for:

  • Create – Add new data
  • Read – Retrieve data
  • Update – Modify data
  • Delete – Remove data

REST APIs commonly provide endpoints for all these operations.

21. REST API Example

Suppose we are developing a student management mobile application.

We may create the following endpoints:


GET    /api/students
GET    /api/students/5
POST   /api/students
PUT    /api/students/5
DELETE /api/students/5

22. REST API and PHP

PHP can be used to create REST API endpoints.

The PHP API can receive an HTTP request, process it and communicate with MySQL.


React Native
      ↓
PHP REST API
      ↓
MySQL

23. REST API and MySQL

MySQL can store the data used by a REST API.

For example, a student API can read student records from MySQL and return them as JSON.


MySQL Record
     ↓
PHP API
     ↓
JSON
     ↓
React Native

24. REST API Advantages

  • Works over HTTP
  • Easy to use with mobile applications
  • Supports different programming languages
  • Can return JSON data
  • Works well with React Native
  • Can connect applications with databases
  • Supports CRUD operations

25. REST API is Language Independent

A REST API can be used by applications written in different programming languages.

For example, the server can be written in PHP while the client can be written using React Native.


PHP Server
     ↑
 REST API
     ↓
React Native

26. REST API and Mobile Application Architecture

A mobile application can be divided into different layers.


React Native UI
      ↓
API Service
      ↓
REST API
      ↓
PHP Business Logic
      ↓
MySQL Database

This separation makes the application easier to develop and maintain.

27. Example: Student Application

Consider a student management mobile application.

The application may allow users to:

  • Register
  • Login
  • View students
  • Add students
  • Update students
  • Delete students
  • Search students

These features can be implemented using REST API endpoints.

28. What We Will Learn in This Course

In this REST API course, we will gradually learn:

  • REST API fundamentals
  • HTTP methods
  • JSON
  • Postman
  • PHP REST APIs
  • MySQL integration
  • CRUD APIs
  • Authentication
  • JWT
  • Fetch and Axios
  • React Native API integration
  • TypeScript API types
  • Complete mobile application projects

29. REST API Learning Flow

The recommended learning flow is:


REST Fundamentals
       ↓
HTTP & JSON
       ↓
Postman
       ↓
PHP + MySQL API
       ↓
CRUD API
       ↓
Authentication & JWT
       ↓
React Native Fetch
       ↓
Axios
       ↓
TypeScript
       ↓
Complete Mobile App

30. Final Goal

The main goal of this course is to learn how to create a complete backend REST API and connect it with a React Native mobile application.

By the end of the course, you will be able to create APIs using PHP + MySQL and consume those APIs from React Native + TypeScript.


React Native + TypeScript
            ↓
       Fetch / Axios
            ↓
        REST API
            ↓
       PHP Backend
            ↓
        MySQL

📌 Key Points

  • API allows applications to communicate with each other.
  • REST is an architectural style for designing web services.
  • REST APIs commonly use HTTP methods.
  • React Native can communicate with REST APIs.
  • PHP can be used to create REST APIs.
  • MySQL can store API data.
  • JSON is commonly used for API data exchange.
  • GET, POST, PUT and DELETE are important HTTP methods.
  • REST APIs are useful for mobile application development.
  • This course will connect PHP + MySQL APIs with React Native.

🧠 Quick Quiz

Question: What does REST API provide to a React Native application?