Posts
Last updated 2026-05-20
Copy-ready blog-post JSON: list, single post, search, paginate, per-user posts, comments per post, add, update, delete. Live REST endpoint at /posts.
Posts
fetch('https://jsonexamples.com/posts')
.then(res => res.json())
.then(console.log);Response
{
"posts": [
{
"id": 1,
"title": "His mother had always taught him",
"body": "His mother had always taught him not to ever think of himself as better than others...",
"userId": 9,
"tags": ["history", "american", "crime"],
"reactions": 2
}
// 30 items
],
"total": 150,
"skip": 0,
"limit": 30
}fetch('https://jsonexamples.com/posts/1')
.then(res => res.json())
.then(console.log);Response
{
"id": 1,
"title": "His mother had always taught him",
"body": "...",
"userId": 9,
"tags": ["history", "american", "crime"],
"reactions": 2
}GET
Search posts
fetch('https://jsonexamples.com/posts/search?q=love')
.then(res => res.json())
.then(console.log);Response
{
"posts": [
{ "id": 7, "title": "This is important to remember.", "body": "...love...", "tags": ["magical", "crime"] }
// 11 results
],
"total": 11,
"skip": 0,
"limit": 11
}- Use
limitandskipfor pagination.limit=0returns all items. - Pass
selectwith comma-separated keys to trim the payload.
fetch('https://jsonexamples.com/posts?limit=10&skip=10&select=title,reactions,userId')
.then(res => res.json())
.then(console.log);Response
{
"posts": [
{ "id": 11, "title": "It wasn't quite yet time to panic.", "reactions": 5, "userId": 25 }
// 10 items
],
"total": 150,
"skip": 10,
"limit": 10
}/* getting posts of user with id 5 */
fetch('https://jsonexamples.com/posts/user/5')
.then(res => res.json())
.then(console.log);Response
{
"posts": [
{ "id": 17, "title": "She was in a hurry.", "userId": 5, "tags": ["french", "magical", "english"] }
],
"total": 3,
"skip": 0,
"limit": 3
}/* getting comments of posts id 1 */
fetch('https://jsonexamples.com/posts/1/comments')
.then(res => res.json())
.then(console.log);Response
{
"comments": [
{ "id": 131, "body": "You are my safest place.", "postId": 1, "user": { "id": 7, "username": "dpettegre6" } }
],
"total": 1,
"skip": 0,
"limit": 1
}POST
Add a new post
- Adding a new post will not persist on the server.
fetch('https://jsonexamples.com/posts/add', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
title: 'I am in love with someone.',
userId: 5,
/* other post data */
})
})
.then(res => res.json())
.then(console.log);Response
{
"id": 1,
"title": "I am in love with someone.",
"userId": 5
}/* updating title of post with id 1 */
fetch('https://jsonexamples.com/posts/1', {
method: 'PUT',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ title: 'I think I should shift to the moon' })
})
.then(res => res.json())
.then(console.log);Response
{
"id": "1",
"title": "I think I should shift to the moon",
"body": "...",
"userId": 9,
"tags": ["history", "american", "crime"],
"reactions": 2
}DELETE
Delete a post
fetch('https://jsonexamples.com/posts/1', { method: 'DELETE' })
.then(res => res.json())
.then(console.log);Response
{
"id": 1,
"title": "His mother had always taught him",
"isDeleted": true,
"deletedOn": /* ISOTime */
}