Skip to content

Users

Fetch all users

fetch('https://dummyapi.online/api/users')
.then((response) => response.json())
.then((json) => console.log(json));
Output
[
{
"id": 1,
"name": "John Doe",
"username": "johndoe",
"email": "johndoe@example.com",
"address": {
"street": "123 Main St",
"city": "San Francisco",
"state": "CA",
"zipcode": "94111"
}
},
{
"id": 2,
"name": "Jane Doe",
"username": "janedoe",
"email": "janedoe@example.com",
"address": {
"street": "456 Market St",
"city": "Los Angeles",
"state": "CA",
"zipcode": "90001"
}
},
...
]

Fetch a single user

Getting a single user by ID. In this example, we use the /api/users/1 route.

fetch('https://dummyapi.online/api/users/1')
.then((response) => response.json())
.then((json) => console.log(json));
Output
{
"id": 1,
"name": "John Doe",
"username": "johndoe",
"email": "johndoe@example.com",
"address": {
"street": "123 Main St",
"city": "San Francisco",
"state": "CA",
"zipcode": "94111"
}
}

Create a User

Creating a new user in the system. At this moment, we only support creating users through the /api/users route.

fetch('https://dummyapi.online/api/users', {
method: 'POST',
body: JSON.stringify({
id: 11,
name: "Elon Musk",
username: "elonmusk",
email: "elonmusk@planet.mars"
}),
headers: {
'Content-type': 'application/json'
},
})
.then((response) => response.json())
.then((json) => console.log(json));
Output
{
"message": "User created successfully:",
"id": 11,
"name": "Elon Musk",
"username": "elonmusk",
"email": "elonmusk@planet.mars"
}

Important: Please note that resources will not be actually updated on our server, but you will receive a legitimate response as if they were!

Show All Available Users

To view all available users, you can open the Users Endpoint in your browser.