Resource reference
Posts
Articles connected to users, comments, and lightweight likes.
Data model
Posts schema
Responses include the following fields. Read-only values are generated by the API.
| Field | Type | Required | Description |
|---|---|---|---|
id | integer | Read only | Auto-incrementing resource identifier. |
title | string | Required | Post title, 1 to 200 characters. |
body | string | Required | Post content, 1 to 5,000 characters. |
userId | integer | Optional | Owning user ID. Defaults to 1 when omitted on create. |
user | object | Read only | Nested summary of the current owning user. |
createdAt | ISO 8601 string | Read only | Time the record was created. |
updatedAt | ISO 8601 string | Read only | Time the record was last updated. |
Example object
A complete post
{
"id": 1,
"title": "Getting Started with Modern Web Development: A Practical First Project",
"body": "This is a comprehensive article about getting started with modern web development.",
"userId": 1,
"createdAt": "2026-07-22T00:00:03.599Z",
"updatedAt": "2026-07-22T00:00:03.599Z",
"user": {
"id": 1,
"name": "John Doe",
"username": "johndoe",
"email": "john.doe@example.com"
}
}Endpoints
Read and write posts
Every example uses the shared free API. Replace :id with a numeric record ID.
GET/posts
List posts
Returns paginated posts with a nested user summary.
curl 'https://api.apimocker.com/posts'Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
_page or page | integer | Optional | Page number. Defaults to 1. |
_limit or limit | integer | Optional | Items per page. Defaults to 10 and is capped at 100. |
_sort | string | Optional | Field used for sorting. Defaults to id. |
_order | asc | desc | Optional | Sort direction. Defaults to asc. |
_delay | integer | Optional | Artificial response delay in milliseconds. |
userId | integer | Optional | Filter by owner. |
title_like | string | Optional | Partial, case-insensitive title match. |
body_like | string | Optional | Partial, case-insensitive body match. |
Example response
{
"data": [
{
"id": 1,
"title": "Getting Started with Modern Web Development: A Practical First Project",
"body": "This is a comprehensive article about getting started with modern web development.",
"userId": 1,
"createdAt": "2026-07-22T00:00:03.599Z",
"updatedAt": "2026-07-22T00:00:03.599Z",
"user": {
"id": 1,
"name": "John Doe",
"username": "johndoe",
"email": "john.doe@example.com"
}
}
],
"pagination": {
"page": 1,
"limit": 10,
"total": 100,
"totalPages": 10,
"hasNext": true,
"hasPrev": false
}
}GET/posts/search?q=development
Search posts
Searches title and body with pagination and sorting.
curl 'https://api.apimocker.com/posts/search?q=development'Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
q | string | Required | Case-insensitive search text. |
_page or page | integer | Optional | Page number. Defaults to 1. |
_limit or limit | integer | Optional | Items per page. Defaults to 10 and is capped at 100. |
_sort | string | Optional | Field used for sorting. Defaults to id. |
_order | asc | desc | Optional | Sort direction. Defaults to asc. |
_delay | integer | Optional | Artificial response delay in milliseconds. |
Example response
{
"query": "development",
"total": 20,
"totalPages": 2,
"page": 1,
"limit": 10,
"hasNext": true,
"hasPrev": false,
"results": [
{
"id": 1,
"title": "Getting Started with Modern Web Development: A Practical First Project",
"body": "This is a comprehensive article about getting started with modern web development.",
"userId": 1,
"createdAt": "2026-07-22T00:00:03.599Z",
"updatedAt": "2026-07-22T00:00:03.599Z",
"user": {
"id": 1,
"name": "John Doe",
"username": "johndoe",
"email": "john.doe@example.com"
}
}
]
}GET/posts/:id
Get one post
Returns a post directly with its nested user summary.
curl 'https://api.apimocker.com/posts/1'Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id | integer | Required | The resource ID from the URL path. |
_delay | integer | Optional | Artificial response delay in milliseconds. |
Example response
{
"id": 1,
"title": "Getting Started with Modern Web Development: A Practical First Project",
"body": "This is a comprehensive article about getting started with modern web development.",
"userId": 1,
"createdAt": "2026-07-22T00:00:03.599Z",
"updatedAt": "2026-07-22T00:00:03.599Z",
"user": {
"id": 1,
"name": "John Doe",
"username": "johndoe",
"email": "john.doe@example.com"
}
}GET/posts/:id/likes
Get a post's like count
Returns the current number of likes for a post.
curl 'https://api.apimocker.com/posts/1/likes'Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id | integer | Required | The resource ID from the URL path. |
Example response
{
"postId": 1,
"likes": 4
}POST/posts/:id/likes
Add a like
Adds an anonymous like or records an optional user ID.
curl -X POST 'https://api.apimocker.com/posts/1/likes' \
-H 'Content-Type: application/json' \
-d '{ "userId": 2 }'Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id | integer | Required | The resource ID from the URL path. |
Request body
{
"userId": 2
}Example response
{
"message": "Like added successfully",
"like": {
"id": 5,
"postId": 1,
"userId": 2,
"createdAt": "2026-07-22T12:00:00.000Z"
},
"totalLikes": 5
}- Writes affect the shared dataset until the next daily reset.
- Unknown fields are rejected by the database layer.
POST/posts
Create a post
Creates a post. userId defaults to 1 when omitted.
curl -X POST 'https://api.apimocker.com/posts' \
-H 'Content-Type: application/json' \
-d '{ "title": "A frontend testing workflow", "body": "Build the UI against predictable JSON.", "userId": 1 }'Request body
{
"title": "A frontend testing workflow",
"body": "Build the UI against predictable JSON.",
"userId": 1
}Example response
{
"id": 1,
"title": "Getting Started with Modern Web Development: A Practical First Project",
"body": "This is a comprehensive article about getting started with modern web development.",
"userId": 1,
"createdAt": "2026-07-22T00:00:03.599Z",
"updatedAt": "2026-07-22T00:00:03.599Z",
"user": {
"id": 1,
"name": "John Doe",
"username": "johndoe",
"email": "john.doe@example.com"
}
}- Writes affect the shared dataset until the next daily reset.
- Unknown fields are rejected by the database layer.
PUT/posts/:id
Replace a post
Updates a post. Title and body are required.
curl -X PUT 'https://api.apimocker.com/posts/1' \
-H 'Content-Type: application/json' \
-d '{ "title": "Updated title", "body": "Updated post body.", "userId": 1 }'Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id | integer | Required | The resource ID from the URL path. |
Request body
{
"title": "Updated title",
"body": "Updated post body.",
"userId": 1
}Example response
{
"id": 1,
"title": "Getting Started with Modern Web Development: A Practical First Project",
"body": "This is a comprehensive article about getting started with modern web development.",
"userId": 1,
"createdAt": "2026-07-22T00:00:03.599Z",
"updatedAt": "2026-07-22T00:00:03.599Z",
"user": {
"id": 1,
"name": "John Doe",
"username": "johndoe",
"email": "john.doe@example.com"
}
}- Writes affect the shared dataset until the next daily reset.
- Unknown fields are rejected by the database layer.
PATCH/posts/:id
Update selected post fields
Updates only the provided fields.
curl -X PATCH 'https://api.apimocker.com/posts/1' \
-H 'Content-Type: application/json' \
-d '{ "title": "A more specific title" }'Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id | integer | Required | The resource ID from the URL path. |
Request body
{
"title": "A more specific title"
}Example response
{
"id": 1,
"title": "Getting Started with Modern Web Development: A Practical First Project",
"body": "This is a comprehensive article about getting started with modern web development.",
"userId": 1,
"createdAt": "2026-07-22T00:00:03.599Z",
"updatedAt": "2026-07-22T00:00:03.599Z",
"user": {
"id": 1,
"name": "John Doe",
"username": "johndoe",
"email": "john.doe@example.com"
}
}- Writes affect the shared dataset until the next daily reset.
- Unknown fields are rejected by the database layer.
DELETE/posts/:id
Delete a post
Deletes the post and cascades to its comments and likes.
curl -X DELETE 'https://api.apimocker.com/posts/1'Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id | integer | Required | The resource ID from the URL path. |
- Writes affect the shared dataset until the next daily reset.
- Unknown fields are rejected by the database layer.