Fake REST API

Four realistic resources — posts, comments, users, todos — with relations, filtering, sorting, pagination, and simulated writes that return believable responses without persisting anything.

https://sampleapi.top/api

Base URL — append any path below.

Endpoints

MethodPathDescription
GET/postsList posts. Filter by userId. Search by q.
GET/posts/{id}Get a single post.
POST/postsSimulate create. Returns 201.
PUT/posts/{id}Simulate full replace.
PATCH/posts/{id}Simulate partial merge.
DELETE/posts/{id}Simulate delete.
GET/posts/{id}/commentsComments for a post.
GET/commentsList comments. Filter by postId.
GET/comments/{id}Get a single comment.
POST/commentsSimulate create.
GET/usersList users.
GET/users/{id}Get a single user.
POST/usersSimulate create.
GET/users/{id}/postsPosts by user.
GET/users/{id}/todosTodos by user.
GET/todosList todos. Filter by userId, completed.
GET/todos/{id}Get a single todo.
POST/todosSimulate create.

Resource shapes

Post

{
  "id": 1,
  "userId": 1,
  "title": "Welcome to SampleAPI",
  "body": "This is a sample post you can fetch, edit, or delete.",
  "tags": ["welcome", "getting-started"],
  "createdAt": "2024-01-04T09:12:00Z"
}

Comment

{
  "id": 1,
  "postId": 1,
  "name": "First!",
  "email": "riley@example.com",
  "body": "Nice to see this live."
}

User

{
  "id": 1,
  "name": "Riley Carter",
  "username": "rileyc",
  "email": "riley@example.com",
  "phone": "555-0101",
  "website": "riley.example.dev",
  "company": { "name": "Northwind Labs", "catchPhrase": "Pragmatic engineering" },
  "address": { "street": "12 Oak Lane", "city": "Boulder", "zipcode": "80301", "country": "USA" }
}

Todo

{
  "id": 1,
  "userId": 1,
  "title": "Write integration tests",
  "completed": true,
  "dueDate": "2024-01-15"
}

Recipes

Paginated list with total count

curl -i "https://sampleapi.top/api/posts?_page=2&_limit=5"
const r = await fetch('https://sampleapi.top/api/posts?_page=2&_limit=5');
const items = await r.json();
const total = Number(r.headers.get('X-Total-Count'));
console.log({ items, total });

Filter todos by user and status

curl -s "https://sampleapi.top/api/todos?userId=2&completed=false"

Sort posts newest first

curl -s "https://sampleapi.top/api/posts?_sort=createdAt&_order=desc&_limit=10"

Search posts

curl -s "https://sampleapi.top/api/posts?q=cors"

Simulated PATCH

curl -s -X PATCH https://sampleapi.top/api/posts/1 \
  -H "Content-Type: application/json" \
  -d '{"title":"Updated title"}'

Important: fake writes are not stored

POST, PUT, PATCH, and DELETE return a believable success response (with generated id, merged fields, or a deleted: true flag) but never modify the server-side data. The next request will see the original fixtures. This is by design so the dataset stays clean for every user.