DocsPosts
Posts API
The posts endpoint offers a dataset of sample blog post data, including details like titles, body content, user IDs, and tags, useful for testing and prototyping content management and social media features in web applications.
GET
/postsReturns a paginated list of posts.
Code Examples
fetch
fetch('https://api.dhanyalvian.my.id/dummy/v1/posts', {
headers: { 'Content-Type': 'application/json' }
})
.then(res => res.json())
.then(data => console.log(data))
.catch(err => console.error(err));URL
https://api.dhanyalvian.my.id/dummy/v1/posts
Query Parameters
| Name | Type | Default | Description |
|---|---|---|---|
| page | number | 1 | Page number for pagination. |
| limit | number | 20 | Number of items per page. |
| search | string | — | Search by name or description. |
Response (200 OK)
{
"meta": {
"reqId": "b7d9c035-438c-4d03-a0d8-23680d06d391",
"code": "200"
},
"message": "",
"pagination": {
"page": 1,
"next": 2,
"record": 1,
"totalPage": 100,
"totalRecord": 100
},
"records": [
{
"id": "100",
"user_id": "228",
"title": "CQRS Pattern - Part 100",
"body": "CQRS Pattern enables developers to build better software faster. Learn the principles and patterns that make it effective.",
"tags": [
"cqrs",
"architecture",
"patterns",
"topic100"
],
"likes": 364,
"dislikes": 29,
"views": 3939
}
]
}Try it Yourself
GET
Query Params
page:
limit:
search:
GET
/posts/:idReturns a single post by ID.
Code Examples
fetch
fetch('https://api.dhanyalvian.my.id/dummy/v1/posts/1', {
headers: { 'Content-Type': 'application/json' }
})
.then(res => res.json())
.then(data => console.log(data))
.catch(err => console.error(err));URL
https://api.dhanyalvian.my.id/dummy/v1/posts/:id
Path Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| id | string | Required | The unique identifier of the user. |
Response (200 OK)
{
"meta": {
"reqId": "b9d9c035-438c-4d03-a0d8-23680d06d391",
"code": "200"
},
"message": "",
"record": {
"id": "1",
"user_id": "49",
"title": "CQRS Pattern - Part 1",
"body": "CQRS Pattern can significantly improve your application's performance. Here's a comprehensive tutorial on getting started.",
"tags": [
"cqrs",
"architecture",
"patterns",
"topic1"
],
"likes": 122,
"dislikes": 30,
"views": 1609
}
}Error Response
{
"meta": {
"reqId": "4a16367e-66bc-4d5c-8ac1-c7e2eb294724",
"code": "400"
},
"message": "Data not found"
}Try it Yourself
GET
GET
/posts/:id/commentsReturns a paginated list of comments by post_id.
Code Examples
fetch
fetch('https://api.dhanyalvian.my.id/dummy/v1/posts/1/comments', {
headers: { 'Content-Type': 'application/json' }
})
.then(res => res.json())
.then(data => console.log(data))
.catch(err => console.error(err));URL
https://api.dhanyalvian.my.id/dummy/v1/posts/:id/comments
Path Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| id | string | Required | The unique identifier of the post. |
Response (200 OK)
{
"meta": {
"reqId": "7c3cc0d3-1e34-4098-98ec-85b8b3263b98",
"code": "200"
},
"message": "",
"pagination": {
"page": 1,
"next": 1,
"record": 2,
"totalPage": 1,
"totalRecord": 2
},
"records": [
{
"id": "86",
"user_id": "155",
"post_id": "1",
"body": "CQRS implementation guide is exactly what I needed.",
"likes": 44
},
{
"id": "1",
"user_id": "49",
"post_id": "1",
"body": "Great article! The CQRS pattern explanation is very clear and easy to understand.",
"likes": 15
}
]
}Error Response
{
"meta": {
"reqId": "4a16367e-66bc-4d5c-8ac1-c7e2eb294724",
"code": "400"
},
"message": "Data not found"
}Try it Yourself
GET