Posts

reqres.in API Documentation

Base URL: https://reqres.in

Get List of Users

  • Method: GET
  • Endpoint: /api/users
  • Status Code: 200 OK

Request:

  • Request URL: https://reqres.in/api/users?page=2

Response:

{
  "page": 2,
  "per_page": 6,
  "total": 12,
  "total_pages": 2,
  "data": [
    {
      "id": 7,
      "email": "michael.lawson@reqres.in",
      "first_name": "Michael",
      "last_name": "Lawson",
      "avatar": "https://reqres.in/img/faces/7-image.jpg"
    },
    {
      "id": 8,
      "email": "lindsay.ferguson@reqres.in",
      "first_name": "Lindsay",
      "last_name": "Ferguson",
      "avatar": "https://reqres.in/img/faces/8-image.jpg"
    }
  ]
}

Test Cases:

Status Code Validation:
Ensure that the response status code is 200 OK.

pm.test("Status Code is 200", function () {
    pm.response.to.have.status(200);
});


Validate Response Structure:
Verify that the response contains the correct fields (page, per_page, total, data, etc.).

pm.test("Response contains necessary fields", function () {
    const Data = pm.response.();
    pm.expect(Data).to.have.property("page");
    pm.expect(Data).to.have.property("per_page");
    pm.expect(Data).to.have.property("data");
});

Create User

  • Method: POST
  • Endpoint: /api/users
  • Status Code: 201 Created

Request:

  • Request URL: https://reqres.in/api/users
  • Body:

{
  "name": "John Doe",
  "job": "Software Engineer"
}

Response:

{
  "name": "John Doe",
  "job": "Software Engineer",
  "id": "101",
  "createdAt": "2024-10-13T09:28:22.556Z"
}


Test Cases:

Status Code Validation:
Ensure that the response status code is 201 Created.

pm.test("Status Code is 201", function () {
    pm.response.to.have.status(201);
});


Response Field Validation:
Validate that the name and job fields match the request.

pm.test("Response matches input data", function () {
    const Data = pm.response.();
    pm.expect(Data.name).to.eql("John Doe");
    pm.expect(Data.job).to.eql("Software Engineer");
});

3. Update User

  • Method: PUT

  • Endpoint: /api/users/:id

  • Status Code: 200 OK

Request:

  • Request URL: https://reqres.in/api/users/2

  • Body:

{
  "name": "John Doe",
  "job": "Senior Engineer"
}

Response:

{
  "name": "John Doe",
  "job": "Senior Engineer",
  "updatedAt": "2024-10-13T09:30:18.654Z"
}

Test Cases:

Status Code Validation:
Ensure that the response status code is 200 OK.

pm.test("Status Code is 200", function () {
    pm.response.to.have.status(200);
});


Updated Data Validation:
Verify that the job field reflects the updated value.

pm.test("Job updated correctly", function () {
    const Data = pm.response.();
    pm.expect(Data.job).to.eql("Senior Engineer");
});

4. Delete User

  • Method: DELETE

  • Endpoint: /api/users/:id

  • Status Code: 204 No Content

Request:

  • Request URL: https://reqres.in/api/users/2

Test Cases:

Status Code Validation:
Ensure that the response status code is 204 No Content.

pm.test("Status Code is 204", function () {
    pm.response.to.have.status(204);
});

5. Get Delayed Response

  • Method: GET

  • Endpoint: /api/users?delay=3

  • Status Code: 200 OK

Request:

  • Request URL: https://reqres.in/api/users?delay=3

Response:

{
  "page": 1,
  "per_page": 6,
  "total": 12,
  "total_pages": 2,
  "data": [
    {
      "id": 1,
      "email": "george.bluth@reqres.in",
      "first_name": "George",
      "last_name": "Bluth",
      "avatar": "https://reqres.in/img/faces/1-image.jpg"
    }
  ]
}

Test Cases:

Status Code Validation:
Ensure that the response status code is 200 OK.

pm.test("Status Code is 200", function () {
    pm.response.to.have.status(200);
});


Response Time Validation:
Ensure that the response time is within acceptable limits.

pm.test("Response time is less than 5000ms", function () {
    pm.expect(pm.response.responseTime).to.be.below(5000);
});


Post a Comment

Cookie Consent
We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.
Oops!
It seems there is something wrong with your internet connection. Please connect to the internet and start browsing again.
AdBlock Detected!
We have detected that you are using adblocking plugin in your browser.
The revenue we earn by the advertisements is used to manage this website, we request you to whitelist our website in your adblocking plugin.
Site is Blocked
Sorry! This site is not available in your country.