
🔑 How to use ReqRes for API testing
ReqRes is a hosted mock API — point your HTTP client at it and you get realistic JSON responses for testing UIs, interceptors, and error handling.
- Hit a list endpoint. GET https://reqres.in/api/users?page=2 returns paginated fake users — check reqres.in for current usage/key requirements.
- Test CRUD flows. POST/PUT/PATCH/DELETE to /api/users echo realistic created/updated responses with timestamps and IDs.
- Simulate auth. POST /api/login and /api/register return tokens for happy paths and 400s for missing fields — ideal for testing error states.
- Test slow responses. Add ?delay=3 to any request to simulate latency and exercise loading states.
📚 Documentation & Examples
Everything you need to integrate with ReqRes
🚀 Quick Start Examples
// ReqRes API Example
const response = await fetch('https://reqres.in/', {
method: 'GET',
headers: {
'Content-Type': 'application/json'
}
});
const data = await response.json();
console.log(data);Using the Reqres.in Public API with JavaScript
Reqres.in is a great resource that provides a public API that you can use to build and test your applications. In this article, we'll show you how to use the Reqres.in API with JavaScript and provide some example code to get you started.
How to Get a Reqres API Key
Reqres now requires a free API key on every request — calls without one return HTTP 401 with {"error":"missing_api_key"}. (Older examples that hit the endpoints with no key no longer work.)
- Go to https://app.reqres.in/ and sign up for a free account.
- Open the API Keys page (https://app.reqres.in/api-keys) and copy your key.
- Send it in the
x-api-keyheader on every request.
curl "https://reqres.in/api/users/2" -H "x-api-key: YOUR_API_KEY"
This applies to all endpoints — for example, creating a user:
curl -X POST "https://reqres.in/api/users" \
-H "x-api-key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"name":"John Doe","job":"Developer"}'
Reqres is still a free fake-data API for prototyping and testing (it doesn't persist changes), but the key is now mandatory on the free tier; paid plans add higher limits and features. If you get a 401, check that the x-api-key header is present and spelled correctly.
Getting Started
First, let's take a quick look at the available endpoints of the Reqres.in API.
-
GET /api/users
Returns a list of users.
-
GET /api/users/{id}
Returns a single user.
-
POST /api/users
Creates a new user.
-
PUT /api/users/{id}
Updates an existing user.
-
DELETE /api/users/{id}
Deletes an existing user.
Example Code
We'll start by using the fetch method to make our API calls. This method allows us to make network requests and handle the returned data. Here's some example code to get you started:
// Get list of users
fetch("https://reqres.in/api/users")
.then(response => response.json())
.then(data => console.log(data));
// Get a single user
fetch("https://reqres.in/api/users/2")
.then(response => response.json())
.then(data => console.log(data));
// Create a new user
fetch("https://reqres.in/api/users", {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify({
name: "John Doe",
job: "Developer"
})
})
.then(response => response.json())
.then(data => console.log(data));
// Update an existing user
fetch("https://reqres.in/api/users/2", {
method: "PUT",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify({
name: "Jane Doe",
job: "Designer"
})
})
.then(response => response.json())
.then(data => console.log(data));
// Delete an existing user
fetch("https://reqres.in/api/users/2", {
method: "DELETE"
})
.then(response => console.log(response));
Conclusion
Using the Reqres.in public API with JavaScript is a great way to get started with building and testing your applications. With the available endpoints and some example code, you'll be up and running in no time. Happy coding!
❓ Frequently Asked Questions
Is ReqRes free?
Yes — ReqRes is free for testing and prototyping. Check reqres.in for current usage notes, as the service has added a lightweight API-key signup for higher usage.
What is ReqRes used for?
Testing front-end code against a real hosted HTTP API without building a backend: pagination, CRUD, auth flows, error responses, and artificial delays.
What are alternatives to ReqRes?
JSONPlaceholder (fake blog data), DummyJSON (products/carts/users), MockAPI.io (custom schemas), and httpbin.org (request inspection) are the most common free alternatives.






