A GET request is used to retrieve or read data from a server. In Postman, we can easily send a GET request to an API and view the response.
A GET request is an HTTP request used to retrieve information from a server.
For example:
GET /students
This request asks the server to return student information.
Postman provides an easy interface for sending GET requests.
The basic process is:
Open Postman and create a new HTTP request.
You will see a method dropdown, URL field, and a Send button.
These controls are used to send API requests to the server.
Click the HTTP method dropdown and select GET.
GET tells the server that we want to retrieve information.
GET
Enter the URL of the API that you want to test.
Example:
http://localhost/api/students.php
The URL identifies the API endpoint that will process the request.
Suppose our PHP API provides a student endpoint:
http://localhost/api/students.php
We can send a GET request to retrieve the student records.
After selecting GET and entering the URL, click the Send button.
Postman sends the request to the API server.
The server receives the GET request and processes it.
For a PHP API, the PHP file may connect to MySQL and retrieve records.
GET Request
↓
PHP API
↓
MySQL Database
↓
JSON Response
After processing the request, the server sends a response back to Postman.
The response may contain JSON data.
[
{
"id": 1,
"name": "Rahul"
}
]
A successful GET request commonly returns the HTTP status code:
200 OK
This means the server successfully processed the request.
Postman displays the API response in the response section.
If the API returns JSON, Postman formats the JSON so that it is easier to read.
{
"id": 1,
"name": "Amit",
"course": "ADCA"
}
A normal GET request usually does not require a request body.
The required information can be provided through the URL or query parameters.
GET http://localhost/api/students.php
Query parameters can be used to send additional information with a GET request.
Example:
http://localhost/api/students.php?course=ADCA
Here, course=ADCA is a query parameter.
A GET endpoint can also retrieve a specific record.
Example:
http://localhost/api/student.php?id=10
The API can use the ID to find the requested student.
A GET request can also contain HTTP headers.
For example:
Accept: application/json
The Accept header can indicate that the client expects JSON data.
In Postman, open the Headers section.
Add:
Key: Accept
Value: application/json
Now the request contains an Accept header.
A GET request can contain both a URL and headers.
GET
http://localhost/api/students.php
Accept: application/json
The server receives both the request URL and the headers.
After clicking Send, check the response status in Postman.
Common successful response:
200 OK
The status code helps us understand whether the request was successful.
Postman also displays the response time.
Response time tells us approximately how long the server took to respond.
For example:
200 OK
125 ms
Postman can also display the size of the response.
A response containing many records may be larger than a response containing only one record.
200 OK
125 ms
2.4 KB
A GET request may fail for several reasons.
If the requested API endpoint does not exist, the server may return:
404 Not Found
Check the URL carefully when you receive a 404 response.
A PHP API may return a server error when there is a problem in the backend.
500 Internal Server Error
For example, the PHP code may contain an error or the database connection may fail.
React Native applications commonly use GET requests to retrieve data from a REST API.
Example flow:
React Native App
↓
GET Request
↓
PHP REST API
↓
MySQL Database
↓
JSON Response
↓
React Native App
Suppose a mobile application needs to display all students.
The application can request:
GET /api/students.php
The API can return a list of students in JSON format.
Before sending a GET request, check:
1. Open Postman
2. Create a request
3. Select GET
4. Enter API URL
5. Add headers if required
6. Click Send
7. Check status code
8. Read JSON response
This is the basic workflow for testing a GET API in Postman.
Method:
GET
URL:
http://localhost/api/students.php
Header:
Accept: application/json
Click Send to test the API.
A successful API might return:
[
{
"id": 1,
"name": "Rahul",
"course": "ADCA"
},
{
"id": 2,
"name": "Priya",
"course": "Web Development"
}
]
This data can later be displayed inside a React Native application.
A GET request is one of the most important requests when working with REST APIs. It is primarily used to retrieve data from a server.
In Postman, select GET, enter the API URL, optionally add headers or query parameters, click Send, and then inspect the response.
GET
↓
API Endpoint
↓
Server
↓
Database
↓
JSON Response
Question: Which HTTP method is commonly used to retrieve data from an API?