Mock API is a small fake REST API. It exposes six resources with full CRUD, one-level nested routes, and query filtering. Writes are real: creating, updating, or deleting an item actually changes the in-memory data for as long as the server keeps running.
Base URL: https://mockapi.abdkarim.com
| Resource | Base path | Count | Description |
|---|---|---|---|
| Posts | /api/posts | 100 | Blog posts, each owned by a user. |
| Comments | /api/comments | 500 | Comments left on a post. |
| Albums | /api/albums | 100 | Photo albums, each owned by a user. |
| Photos | /api/photos | 5000 | Photos belonging to an album. |
| Todos | /api/todos | 200 | Todo items, each owned by a user. |
| Users | /api/users | 10 | Users of the system. |
Any top-level field on a resource can be used as a query parameter for exact-match filtering, e.g. ?userId=1 or ?completed=true. Multiple parameters are combined with AND.
Data starts from a deterministic seed and lives in memory on the server. POST, PUT, PATCH, and DELETE really mutate that data for the lifetime of the server process — restarting the dev server resets everything back to the seed data.
Every operation below is demonstrated against the posts resource — the same patterns apply to any of the six resources.
fetch("https://mockapi.abdkarim.com/api/posts/1")
.then((response) => response.json())
.then((json) => console.log(json));
// { id: 1, userId: 1, title: "...", body: "..." }fetch("https://mockapi.abdkarim.com/api/posts")
.then((response) => response.json())
.then((json) => console.log(json));
// [{ id: 1, userId: 1, title: "...", body: "..." }, ...] (100 items)fetch("https://mockapi.abdkarim.com/api/posts", {
method: "POST",
body: JSON.stringify({
title: "foo",
body: "bar",
userId: 1,
}),
headers: {
"Content-type": "application/json; charset=UTF-8",
},
})
.then((response) => response.json())
.then((json) => console.log(json));
// { title: "foo", body: "bar", userId: 1, id: 101 }
// This really is added to the in-memory store — GET /api/posts/101 will return it.fetch("https://mockapi.abdkarim.com/api/posts/1", {
method: "PUT",
body: JSON.stringify({
id: 1,
title: "foo",
body: "bar",
userId: 1,
}),
headers: {
"Content-type": "application/json; charset=UTF-8",
},
})
.then((response) => response.json())
.then((json) => console.log(json));
// { id: 1, title: "foo", body: "bar", userId: 1 }fetch("https://mockapi.abdkarim.com/api/posts/1", {
method: "PATCH",
body: JSON.stringify({
title: "foo",
}),
headers: {
"Content-type": "application/json; charset=UTF-8",
},
})
.then((response) => response.json())
.then((json) => console.log(json));
// { id: 1, title: "foo", body: "...", userId: 1 }
// Only "title" changes — every other field keeps its previous value.fetch("https://mockapi.abdkarim.com/api/posts/1", {
method: "DELETE",
});
// 204 No Content — GET /api/posts/1 will now return 404.fetch("https://mockapi.abdkarim.com/api/posts?userId=1")
.then((response) => response.json())
.then((json) => console.log(json));
// Only posts where userId equals 1.fetch("https://mockapi.abdkarim.com/api/posts/1/comments")
.then((response) => response.json())
.then((json) => console.log(json));
// Equivalent to fetch("https://mockapi.abdkarim.com/api/comments?postId=1")