Resources
Posts
Writes are simulated
POST, PUT, PATCH, and DELETE validate your input and return realistic responses, but the shared dataset is never modified.
Endpoints
- GET
/postsList posts - GET
/posts/searchSearch posts - GET
/posts/{id}Get a post - GET
/posts/{id}/commentsList a post's comments - POST
/postsCreate a post (simulated) - PUT
/posts/{id}Replace a post (simulated) - PATCH
/posts/{id}Update a post (simulated) - DELETE
/posts/{id}Delete a post (simulated)
The post object
Use select to return a subset of these fields. Sort with sortBy on id, title, views, userId; search matches title, body, tags. See query parameters.
| Field | Type | Notes |
|---|---|---|
id | integer | min -9007199254740991, max 9007199254740991 |
title | string | |
body | string | |
userId | integer | min -9007199254740991, max 9007199254740991 |
tags | string[] | |
reactions | object | |
reactions.likes | integer | min -9007199254740991, max 9007199254740991 |
reactions.dislikes | integer | min -9007199254740991, max 9007199254740991 |
views | integer | min -9007199254740991, max 9007199254740991 |
List posts
/api/v1/postsReturns a paginated list of posts. Supports pagination, field selection, sorting, and filtering.
Parameters
| Name | In | Type | Description |
|---|---|---|---|
limit | query | integer | Number of records to return (1-100).Default: 30Range: 1-100 |
skip | query | integer | Number of records to skip before returning results.Default: 0Range: 0-1000000 |
select | query | string | Comma-separated list of fields to return. id is always included. Allowed: id, title, body, userId, tags, reactions, views. |
sortBy | query | string | Field to sort by.One of: id, title, views, userIdDefault: id |
order | query | string | Sort direction.One of: asc, descDefault: asc |
userId | query | integer | Only return posts that belong to this user ID. |
tag | query | string | Only return posts with this tag. |
delay | query | integer | Delay the response by this many milliseconds (0-5000). Subject to a stricter rate limit.Range: 0-5000 |
Status codes
- 200A page of posts with
total,skip, andlimitmetadata. - 400Invalid path or query parameter (
INVALID_PARAMETER/INVALID_ID). - 429Too many requests from this IP (
RATE_LIMIT_EXCEEDED). - 503The database is temporarily unavailable (
SERVICE_UNAVAILABLE).
Request
curl 'https://test.naimulhassan.me/api/v1/posts?limit=2'Example responses
Captured from the real API with the requests shown on this page.
{
"posts": [
{
"id": 1,
"title": "Why I write tests before fixing bugs",
"body": "Writing the failing test first made the bug impossible to ignore. Pairing for an hour was faster than a day of back-and-forth messages. Clear error messages turned out to be the best documentation we had.",
"userId": 1,
"tags": [
"coding",
"weekend"
],
"reactions": {
"likes": 398,
"dislikes": 28
},
"views": 1472
},
{
"id": 2,
"title": "My slow Sunday pour-over routine",
"body": "Sharing a pot with neighbors turned into a weekly tradition. Fresh water and a clean kettle make a bigger difference than I expected. Weighing the beans felt fussy at first, but the cups became noticeably more consistent.",
"userId": 1,
"tags": [
"coffee",
"learning",
"beginners"
],
"reactions": {
"likes": 330,
"dislikes": 8
},
"views": 1187
}
],
"total": 100,
"skip": 0,
"limit": 2
}Try it
Search posts
/api/v1/posts/searchCase-insensitive search across title, body, tags. Returns an empty posts array with total: 0 when nothing matches.
Parameters
| Name | In | Type | Description |
|---|---|---|---|
qrequired | query | string | Search term (1-100 characters). |
limit | query | integer | Number of records to return (1-100).Default: 30Range: 1-100 |
skip | query | integer | Number of records to skip before returning results.Default: 0Range: 0-1000000 |
select | query | string | Comma-separated list of fields to return. id is always included. Allowed: id, title, body, userId, tags, reactions, views. |
sortBy | query | string | Field to sort by.One of: id, title, views, userIdDefault: id |
order | query | string | Sort direction.One of: asc, descDefault: asc |
delay | query | integer | Delay the response by this many milliseconds (0-5000). Subject to a stricter rate limit.Range: 0-5000 |
Status codes
- 200Matching posts (possibly empty).
- 400Missing or invalid
qparameter (INVALID_PARAMETER). - 429Too many requests from this IP (
RATE_LIMIT_EXCEEDED).
Request
curl 'https://test.naimulhassan.me/api/v1/posts/search?q=coffee&limit=2'Example responses
Captured from the real API with the requests shown on this page.
{
"posts": [
{
"id": 2,
"title": "My slow Sunday pour-over routine",
"body": "Sharing a pot with neighbors turned into a weekly tradition. Fresh water and a clean kettle make a bigger difference than I expected. Weighing the beans felt fussy at first, but the cups became noticeably more consistent.",
"userId": 1,
"tags": [
"coffee",
"learning",
"beginners"
],
"reactions": {
"likes": 330,
"dislikes": 8
},
"views": 1187
},
{
"id": 12,
"title": "Finding the right grind size by taste",
"body": "I wrote down every recipe change in a small notebook for a month. Fresh water and a clean kettle make a bigger difference than I expected. Sharing a pot with neighbors turned into a weekly tradition.",
"userId": 22,
"tags": [
"coffee",
"habits"
],
"reactions": {
"likes": 834,
"dislikes": 22
},
"views": 3371
}
],
"total": 10,
"skip": 0,
"limit": 2
}Try it
Get a post
/api/v1/posts/{id}Returns a single post by its numeric ID.
Parameters
| Name | In | Type | Description |
|---|---|---|---|
idrequired | path | integer | Numeric post ID (positive integer).Min: 1 |
select | query | string | Comma-separated list of fields to return. id is always included. Allowed: id, title, body, userId, tags, reactions, views. |
delay | query | integer | Delay the response by this many milliseconds (0-5000). Subject to a stricter rate limit.Range: 0-5000 |
Status codes
- 200The post object.
- 400Invalid path or query parameter (
INVALID_PARAMETER/INVALID_ID). - 404No record exists with that ID (
RESOURCE_NOT_FOUND).
Request
curl 'https://test.naimulhassan.me/api/v1/posts/1'Example responses
Captured from the real API with the requests shown on this page.
{
"id": 1,
"title": "Why I write tests before fixing bugs",
"body": "Writing the failing test first made the bug impossible to ignore. Pairing for an hour was faster than a day of back-and-forth messages. Clear error messages turned out to be the best documentation we had.",
"userId": 1,
"tags": [
"coding",
"weekend"
],
"reactions": {
"likes": 398,
"dislikes": 28
},
"views": 1472
}Try it
List a post's comments
/api/v1/posts/{id}/commentsReturns comments whose postId matches the post ID. Returns 404 if the post does not exist.
Parameters
| Name | In | Type | Description |
|---|---|---|---|
idrequired | path | integer | Numeric post ID (positive integer).Min: 1 |
limit | query | integer | Number of records to return (1-100).Default: 30Range: 1-100 |
skip | query | integer | Number of records to skip before returning results.Default: 0Range: 0-1000000 |
select | query | string | Comma-separated list of fields to return. id is always included. Allowed: id, body, postId, userId, likes. |
sortBy | query | string | Field to sort by.One of: id, likes, postId, userIdDefault: id |
order | query | string | Sort direction.One of: asc, descDefault: asc |
delay | query | integer | Delay the response by this many milliseconds (0-5000). Subject to a stricter rate limit.Range: 0-5000 |
Status codes
- 200A page of comments.
- 400Invalid path or query parameter (
INVALID_PARAMETER/INVALID_ID). - 404The post does not exist (
RESOURCE_NOT_FOUND).
Request
curl 'https://test.naimulhassan.me/api/v1/posts/1/comments?limit=2'Example responses
Captured from the real API with the requests shown on this page.
{
"comments": [
{
"id": 1,
"body": "Do you have any recommendations for someone just starting out?",
"postId": 1,
"userId": 87,
"likes": 9
},
{
"id": 261,
"body": "Could you share more details about how you got started?",
"postId": 1,
"userId": 28,
"likes": 50
}
],
"total": 4,
"skip": 0,
"limit": 2
}Try it
Create a post (simulated)
/api/v1/postsValidates the body and returns the post as it would be created, with the next available ID. Nothing is persisted: the shared dataset is never modified.
Headers
| Name | In | Type | Description |
|---|---|---|---|
Content-Typerequired | header | string | Must be application/json. |
Request body
Posts fields.
| Field | Type | Required | Notes |
|---|---|---|---|
title | string | Yes | min length 1, max length 200 |
body | string | Yes | min length 1, max length 5000 |
userId | integer | Yes | min 0, max 1000000000 |
tags | string[] | No |
Status codes
- 201The simulated post, including its new
id. - 400The request body is not valid JSON (
INVALID_JSON). - 422The JSON body failed validation (
VALIDATION_ERROR).
Request
curl -X POST 'https://test.naimulhassan.me/api/v1/posts' \
-H 'Content-Type: application/json' \
-d '{
"title": "My first API request",
"body": "Today I sent my first request to Mock APIs.",
"userId": 5
}'Example responses
Captured from the real API with the requests shown on this page.
{
"id": 101,
"title": "My first API request",
"body": "Today I sent my first request to Mock APIs.",
"userId": 5,
"tags": []
}Try it
Replace a post (simulated)
/api/v1/posts/{id}Validates a complete replacement body and returns the resulting post. The stored record is not changed.
Parameters
| Name | In | Type | Description |
|---|---|---|---|
idrequired | path | integer | Numeric post ID (positive integer).Min: 1 |
Headers
| Name | In | Type | Description |
|---|---|---|---|
Content-Typerequired | header | string | Must be application/json. |
Request body
Complete post representation.
| Field | Type | Required | Notes |
|---|---|---|---|
title | string | Yes | min length 1, max length 200 |
body | string | Yes | min length 1, max length 5000 |
userId | integer | Yes | min 0, max 1000000000 |
tags | string[] | No |
Status codes
- 200The replaced post.
- 400Invalid path or query parameter (
INVALID_PARAMETER/INVALID_ID). - 404No record exists with that ID (
RESOURCE_NOT_FOUND). - 422The JSON body failed validation (
VALIDATION_ERROR).
Request
curl -X PUT 'https://test.naimulhassan.me/api/v1/posts/1' \
-H 'Content-Type: application/json' \
-d '{
"title": "Updated title",
"body": "Completely replaced body text.",
"userId": 1,
"tags": [
"update"
]
}'Example responses
Captured from the real API with the requests shown on this page.
{
"id": 1,
"title": "Updated title",
"body": "Completely replaced body text.",
"userId": 1,
"tags": [
"update"
]
}Try it
Update a post (simulated)
/api/v1/posts/{id}Merges the provided fields into the existing post and returns the result. The stored record is not changed.
Parameters
| Name | In | Type | Description |
|---|---|---|---|
idrequired | path | integer | Numeric post ID (positive integer).Min: 1 |
Headers
| Name | In | Type | Description |
|---|---|---|---|
Content-Typerequired | header | string | Must be application/json. |
Request body
Any subset of post fields.
| Field | Type | Required | Notes |
|---|---|---|---|
title | string | No | min length 1, max length 200 |
body | string | No | min length 1, max length 5000 |
userId | integer | No | min 0, max 1000000000 |
tags | string[] | No |
Status codes
- 200The updated post.
- 400Invalid path or query parameter (
INVALID_PARAMETER/INVALID_ID). - 404No record exists with that ID (
RESOURCE_NOT_FOUND). - 422The JSON body failed validation (
VALIDATION_ERROR).
Request
curl -X PATCH 'https://test.naimulhassan.me/api/v1/posts/1' \
-H 'Content-Type: application/json' \
-d '{
"title": "Patched title"
}'Example responses
Captured from the real API with the requests shown on this page.
{
"id": 1,
"title": "Patched title",
"body": "Writing the failing test first made the bug impossible to ignore. Pairing for an hour was faster than a day of back-and-forth messages. Clear error messages turned out to be the best documentation we had.",
"userId": 1,
"tags": [
"coding",
"weekend"
],
"reactions": {
"likes": 398,
"dislikes": 28
},
"views": 1472
}Try it
Delete a post (simulated)
/api/v1/posts/{id}Returns 204 No Content if the post exists. The record is not actually removed.
Parameters
| Name | In | Type | Description |
|---|---|---|---|
idrequired | path | integer | Numeric post ID (positive integer).Min: 1 |
Status codes
- 204Empty body.
- 400Invalid path or query parameter (
INVALID_PARAMETER/INVALID_ID). - 404No record exists with that ID (
RESOURCE_NOT_FOUND).
Request
curl -X DELETE 'https://test.naimulhassan.me/api/v1/posts/1'Example responses
Captured from the real API with the requests shown on this page.
No response body.