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:

How to Make a GET Request

Using our Postboy, follow these steps to make a GET request:

  1. Select GET from the method dropdown
  2. Enter the URL you want to request data from
  3. Add query parameters in the "Params" tab (optional)
  4. Add headers in the "Headers" tab (optional)
  5. 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

HTTP
GET https://jsonplaceholder.typicode.com/posts/1 HTTP/1.1
Host: jsonplaceholder.typicode.com

Response:

JSON
{
  "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

HTTP
GET https://jsonplaceholder.typicode.com/posts?userId=1 HTTP/1.1
Host: jsonplaceholder.typicode.com

Response (truncated):

JSON
[
  {
    "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

HTTP
GET https://api.github.com/users/octocat HTTP/1.1
Host: api.github.com
Accept: application/json
User-Agent: Postboy

Response (truncated):

JSON
{
  "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

Try It in JavaScript

Here's how you can make a GET request in JavaScript:

JavaScript Example

JavaScript
// 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();