GET Request Documentation
Learn how to make GET requests using our Postboy
What is a GET Request?
The HTTP GET method is one of the most common HTTP methods. It requests data from a specified resource and should only retrieve data without causing any side effects on the server.
Key characteristics of GET requests:
- Can be cached
- Remain in browser history
- Can be bookmarked
- Should not be used for sensitive data
- Have length restrictions
- Are only used to request data (not modify)
How to Make a GET Request
Using our Postboy, follow these steps to make a GET request:
- Select
GETfrom the method dropdown - Enter the URL you want to request data from
- Add query parameters in the "Params" tab (optional)
- Add headers in the "Headers" tab (optional)
- Click the "Send" button
The response will appear in the response section below.
Query Parameters
Query parameters are a key part of GET requests, letting you pass data to the server through the URL. They appear after a question mark (?) in the URL, with multiple parameters separated by ampersands (&).
For example: https://api.example.com/users?page=1&limit=10
In our Postboy, you can add query parameters using the "Params" tab instead of manually typing them in the URL. The application will automatically format and append them to your URL.
Example GET Requests
Example 1: Basic GET Request
GET https://jsonplaceholder.typicode.com/posts/1 HTTP/1.1
Host: jsonplaceholder.typicode.com
Response:
{
"userId": 1,
"id": 1,
"title": "sunt aut facere repellat provident occaecati excepturi optio reprehenderit",
"body": "quia et suscipit\nsuscipit recusandae consequuntur expedita et cum\nreprehenderit molestiae ut ut quas totam\nnostrum rerum est autem sunt rem eveniet architecto"
}
Example 2: GET Request with Query Parameters
GET https://jsonplaceholder.typicode.com/posts?userId=1 HTTP/1.1
Host: jsonplaceholder.typicode.com
Response (truncated):
[
{
"userId": 1,
"id": 1,
"title": "sunt aut facere repellat provident occaecati excepturi optio reprehenderit",
"body": "quia et suscipit\nsuscipit recusandae consequuntur expedita et cum\nreprehenderit molestiae ut ut quas totam\nnostrum rerum est autem sunt rem eveniet architecto"
},
{
"userId": 1,
"id": 2,
"title": "qui est esse",
"body": "est rerum tempore vitae\nsequi sint nihil reprehenderit dolor beatae ea dolores neque\nfugiat blanditiis voluptate porro vel nihil molestiae ut reiciendis\nqui aperiam non debitis possimus qui neque nisi nulla"
}
// More results...
]
Example 3: GET Request with Headers
GET https://api.github.com/users/octocat HTTP/1.1
Host: api.github.com
Accept: application/json
User-Agent: Postboy
Response (truncated):
{
"login": "octocat",
"id": 583231,
"node_id": "MDQ6VXNlcjU4MzIzMQ==",
"avatar_url": "https://avatars.githubusercontent.com/u/583231?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/octocat",
"html_url": "https://github.com/octocat",
"type": "User",
"site_admin": false,
// More fields...
}
Common HTTP Status Codes for GET Requests
- 200 OK - The request succeeded
- 304 Not Modified - The resource hasn't been modified since last requested
- 400 Bad Request - The server couldn't understand the request
- 401 Unauthorized - Authentication is required and has failed or not been provided
- 403 Forbidden - The client does not have access rights to the content
- 404 Not Found - The server can't find the requested resource
- 500 Internal Server Error - The server encountered an unexpected condition
Try It in JavaScript
Here's how you can make a GET request in JavaScript:
JavaScript Example
// Using fetch API
fetch('https://jsonplaceholder.typicode.com/posts/1')
.then(response => {
if (!response.ok) {
throw new Error('Network response was not ok');
}
return response.json();
})
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
// Using async/await
async function fetchData() {
try {
const response = await fetch('https://jsonplaceholder.typicode.com/posts/1');
if (!response.ok) {
throw new Error('Network response was not ok');
}
const data = await response.json();
console.log(data);
} catch (error) {
console.error('Error:', error);
}
}
fetchData();