Hi! this is the documentation created by myself for the API Reqres.in. Here you'll find the documentation for each endpoint as well as the test cases and the code for the automation test using Postman.
Base Url: https://reqres.in
This point retrieves a paged list of users. You can specify the page number in the request to get a specific user page.
- Page: (optional): An integer that specifies the page of results to obtain.
- Code:
200 ok
- Content: A JSON object that contains the following information:
page:
(int) The number of the current page.per_page:
(int) The number of users per page.total:
(int) The total of users avaible.total_pages:
(int) the total pages available in the api.data:
(array) An array of users, where each user contains:id:
(int) The unique ID of the user.email:
(string) The user's email.first_name:
(string) First name of the user.last_name:
(string) Last name of the user.avatar:
(string) The URL of the user's avatar.
support:
(object) An object that contains the URL for contribute with the reqres.in proyect:url:
(string) url for the support page for the reqres proyect.text:
(string) a basic description for why support the proyect.
{
"page": 2,
"per_page": 2,
"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"
},
// ... more users
],
"support": {
"url": "https://reqres.in/#support-heading",
"text": "To keep ReqRes free, contributions towards server costs are appreciated!"
}
}
- curl:
curl -X GET "https://reqres.in/api/users?page=2"
- javascript (Fetch):
async function fetchUsers(page) {
try {
const response = await fetch(`https://reqres.in/api/users?page=${page}`);
const data = await response.json();
console.log(data);
} catch (error) {
console.error('Error:', error);
}
}
fetchUsers(2); // Calls the funtion with the page number you want.
- Python (Requests):
import requests
response = requests.get("https://reqres.in/api/users?page=2")
data = response.json()
print(data)
-
Code:
200 ok
-
Content:
{ "page": 8, "per_page": 6, "total": 12, "total_pages": 2, "data": [], "support": { "url": "https://reqres.in/#support-heading", "text": "To keep ReqRes free, contributions towards server costs are appreciated!" } }
-
Description: This "Error" is actually an expected behavior, API will only return the data shown above.
Retrieve detailed information of a single user by using their unique ID.
id
(int): The unique ID of the user.
Code:
200 ok statusContent:
(Obj) A JSON object that contains the following information:data:
A Object that contains the following information:id:
(int) The unique ID number for the user.email:
(string) User's email address.first_name:
(string) User's first name.last_name:
(string) User's last name.avatar:
(string) Url to the User's avatar image.support:
(object) An object that contains the URL for contribute with the reqres.in proyect:url:
(string) url for the support page for the reqres proyect.text:
(string) a basic description for why support the proyect.
{
"data": {
"id": 2,
"email": "janet.weaver@reqres.in",
"first_name": "Janet",
"last_name": "Weaver",
"avatar": "https://reqres.in/img/faces/2-image.jpg"
},
"support": {
"url": "https://reqres.in/#support-heading",
"text": "To keep ReqRes free, contributions towards server costs are appreciated!"
}
}
- curl:
curl -X GET "https://reqres.in/api/users/2"
- javascript (Fetch):
async function fetchSingleUser(userId) {
try {
const response = await fetch(`https://reqres.in/api/users/${userId}`);
const data = await response.json();
console.log(data);
} catch (error) {
console.error('Error:', error);
}
}
fetchSingleUser(2); // Calls the function with the number of the user you want.
- Python (Requests):
import requests
response = requests.get("https://reqres.in/api/users/2")
data = response.json()
print(data)
-
Code:
404 not found
-
Content:
{}
-
Description: This error is returned when a non-existing user is selected, and empty object will be returned with a 404 status.
When a request is done to a inexisting user ID, the API returns an empty objet with a 404 error message.
id
(integer): a user ID that does not exist in the database.
- code:
404 not found
- content:
{}
- Curl:
curl -X GET "https://reqres.in/api/users/23" -H "accept: application/json"
- Javascript:
async function getUser() {
try {
const response = await fetch("https://reqres.in/api/users/23");
if (!response.ok) {
throw new Error('User not found');
}
const data = await response.json();
console.log(data);
} catch (error) {
console.error('Error:', error);
}
}
getUser();
- Python:
import requests
response = requests.get("https://reqres.in/api/users/23")
if response.status_code == 404:
print("User not found")
else:
user = response.json()
print(user)
- Code: 404
- Content:
{}
This status code is expected when the ID is invalid, and the API will return an empty object.
This endpoints returns a list of different colors with their ID, name, Hexadecimal code and the panton code (world standar for the color code).
page
(optional): by default each page has 6 different colors, in total there are 2 pages.
Code:
200 OKContent:
A JSON object that contains the following information:page:
(int) The current page number.per_page:
(int) The number of items per page.total:
(int) The total number of items.total_pages
: (int) The total number of pages.data:
(array) An array of objects where each object contains information about a resource:id:
(int) The unique ID number for the resource.name:
(string) The name of the resource.year:
(int) The year of the resource.color:
(string) The color associated with the resource.pantone_value:
(string) The pantone value of the resource.
{
"page": 1,
"per_page": 6,
"total": 12,
"total_pages": 2,
"data": [
{
"id": 1,
"name": "cerulean",
"year": 2000,
"color": "#98B2D1",
"pantone_value": "15-4020"
},
// ... other resource objects
],
"support": {
"url": "https://reqres.in/#support-heading",
"text": "To keep ReqRes free, contributions towards server costs are appreciated!"
}
}
- Curl:
curl -X GET "https://reqres.in/api/unknown" -H "accept: application/json"
- Javascript:
async function getResourceList() {
try {
const response = await fetch("https://reqres.in/api/unknown?page=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);
}
}
getResourceList();
- python:
import requests
response = requests.get("https://reqres.in/api/unknown?page=1")
if response.status_code == 200:
data = response.json()
print(data)
else:
print("Error fetching the resources")
- Code:
200 ok
- Content:
{
"page": 987,
"per_page": 6,
"total": 12,
"total_pages": 2,
"data": [],
"support": {
"url": "https://reqres.in/#support-heading",
"text": "To keep ReqRes free, contributions towards server costs are appreciated!"
}
}
- Description: This "Error" is actually an expected behavior, API will only return the data shown above when and non-existing page number is selected.
/api/unknown/{id}
GET
Retrieves information about a specific resource by its ID.
id
unique ID of the resource.
- Code:
200 OK
- Content: A JSON object that includes details about the resource and support information.
data
: (object) Contains details about the resource:id
: (int) The unique identifier for the resource.name
: (string) The name of the resource.year
: (int) The year associated with the resource.color
: (string) The color representation of the resource.pantone_value
: (string) The pantone value linked to the resource.
support
: (object) Contains support information for the reqres project:url
: (string) The URL to the support page for the reqres project.text
: (string) A short description of why to support the project.
{
"data": {
"id": 2,
"name": "fuchsia rose",
"year": 2001,
"color": "#C74375",
"pantone_value": "17-2031"
},
"support": {
"url": "https://reqres.in/#support-heading",
"text": "To keep ReqRes free, contributions towards server costs are appreciated!"
}
}
- Curl:
curl -X GET "https://reqres.in/api/unknown/2" -H "accept: application/json"
- Javascript:
async function getSingleResource() {
try {
const response = await fetch("https://reqres.in/api/unknown/2");
if (!response.ok) {
throw new Error('Network response was not ok: ' + response.statusText);
}
const data = await response.json();
console.log(data);
} catch (error) {
console.error('Error:', error);
}
}
getSingleResource();
- Python:
import requests
response = requests.get("https://reqres.in/api/unknown/2")
if response.status_code == 200:
data = response.json()
print(data)
else:
print('Error:', response.status_code, response.text)
- Code:
404 Not Found
- Content:
{}
- Description: The API will return a 404 error when a non-existing ID is requested, also it will return an empty object.
/api/unknown/:id
GET
This endpoint retrieves information about a specific resource by its unique ID. If the resource with the specified ID does not exist, the endpoint responds with an error.
id
: (int) The unique identifier for the resource.
- Code:
404 Not Found
- Content:
{} (an empty JSON object)
- Description: This error response indicates that the requested resource could not be found. This usually occurs when the resource with the specified ID does not exist in the database.
When a non-existent resource ID is requested, the server responds with a 404 Not Found
status code and an empty JSON object as shown below:
{}
-
Curl:
curl -X GET "https://reqres.in/api/unknown/23" -H "accept: application/json"
-
Javascript:
async function getNonExistentResource() { try { const response = await fetch("https://reqres.in/api/unknown/23"); if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`); } const data = await response.json(); console.log(data); } catch (error) { console.error('Error:', error.message); } } getNonExistentResource();
-
Python:
import requests response = requests.get("https://reqres.in/api/unknown/23") if response.status_code == 404: print("Resource not found.") else: data = response.json() print(data)
/api/users
POST
Creates a new user with the provided information.
name
(string): The name of the user.job
(string): The user's job title.
Example:
{
"name": "morpheus",
"job": "leader"
}
- Code:
201 Created
- Content: A JSON object containing the newly created user's information, including a unique ID and creation timestamp.
{
"name": "morpheus",
"job": "leader",
"id": "619",
"createdAt": "2024-03-14T01:41:19.491Z"
}
- Curl:
curl -X POST "https://reqres.in/api/users" -H "Content-Type: application/json" -d '{"name": "morpheus", "job": "leader"}'
- Javascript:
async function createUser() {
try {
const response = await fetch("https://reqres.in/api/users", {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify({ name: "morpheus", job: "leader" })
});
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
const data = await response.json();
console.log(data);
} catch (error) {
console.error("Error:", error);
}
}
createUser();
- Python:
import requests
response = requests.post("https://reqres.in/api/users", json={"name": "morpheus", "job": "leader"})
if response.status_code == 201:
print(response.json())
else:
print('Error:', response.status_code, response.text)