Documentation menu

Resource reference

Posts

Articles connected to users, comments, and lightweight likes.

100 records after each resetView live JSON

Data model

Posts schema

Responses include the following fields. Read-only values are generated by the API.

FieldTypeRequiredDescription
idintegerRead onlyAuto-incrementing resource identifier.
titlestringRequiredPost title, 1 to 200 characters.
bodystringRequiredPost content, 1 to 5,000 characters.
userIdintegerOptionalOwning user ID. Defaults to 1 when omitted on create.
userobjectRead onlyNested summary of the current owning user.
createdAtISO 8601 stringRead onlyTime the record was created.
updatedAtISO 8601 stringRead onlyTime the record was last updated.

Example object

A complete post

JSON
{
  "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 request
curl 'https://api.apimocker.com/posts'

Parameters

ParameterTypeRequiredDescription
_page or pageintegerOptionalPage number. Defaults to 1.
_limit or limitintegerOptionalItems per page. Defaults to 10 and is capped at 100.
_sortstringOptionalField used for sorting. Defaults to id.
_orderasc | descOptionalSort direction. Defaults to asc.
_delayintegerOptionalArtificial response delay in milliseconds.
userIdintegerOptionalFilter by owner.
title_likestringOptionalPartial, case-insensitive title match.
body_likestringOptionalPartial, case-insensitive body match.

Example response

JSON
{
  "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 request
curl 'https://api.apimocker.com/posts/search?q=development'

Parameters

ParameterTypeRequiredDescription
qstringRequiredCase-insensitive search text.
_page or pageintegerOptionalPage number. Defaults to 1.
_limit or limitintegerOptionalItems per page. Defaults to 10 and is capped at 100.
_sortstringOptionalField used for sorting. Defaults to id.
_orderasc | descOptionalSort direction. Defaults to asc.
_delayintegerOptionalArtificial response delay in milliseconds.

Example response

JSON
{
  "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 request
curl 'https://api.apimocker.com/posts/1'

Parameters

ParameterTypeRequiredDescription
idintegerRequiredThe resource ID from the URL path.
_delayintegerOptionalArtificial response delay in milliseconds.

Example response

JSON
{
  "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 request
curl 'https://api.apimocker.com/posts/1/likes'

Parameters

ParameterTypeRequiredDescription
idintegerRequiredThe resource ID from the URL path.

Example response

JSON
{
  "postId": 1,
  "likes": 4
}

POST/posts/:id/likes

Add a like

201 Created

Adds an anonymous like or records an optional user ID.

cURL request
curl -X POST 'https://api.apimocker.com/posts/1/likes' \
  -H 'Content-Type: application/json' \
  -d '{   "userId": 2 }'

Parameters

ParameterTypeRequiredDescription
idintegerRequiredThe resource ID from the URL path.

Request body

JSON
{
  "userId": 2
}

Example response

JSON
{
  "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

201 Created

Creates a post. userId defaults to 1 when omitted.

cURL request
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

JSON
{
  "title": "A frontend testing workflow",
  "body": "Build the UI against predictable JSON.",
  "userId": 1
}

Example response

JSON
{
  "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

200 OK

Updates a post. Title and body are required.

cURL request
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

ParameterTypeRequiredDescription
idintegerRequiredThe resource ID from the URL path.

Request body

JSON
{
  "title": "Updated title",
  "body": "Updated post body.",
  "userId": 1
}

Example response

JSON
{
  "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

200 OK

Updates only the provided fields.

cURL request
curl -X PATCH 'https://api.apimocker.com/posts/1' \
  -H 'Content-Type: application/json' \
  -d '{   "title": "A more specific title" }'

Parameters

ParameterTypeRequiredDescription
idintegerRequiredThe resource ID from the URL path.

Request body

JSON
{
  "title": "A more specific title"
}

Example response

JSON
{
  "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

204 No Content

Deletes the post and cascades to its comments and likes.

cURL request
curl -X DELETE 'https://api.apimocker.com/posts/1'

Parameters

ParameterTypeRequiredDescription
idintegerRequiredThe resource ID from the URL path.
  • Writes affect the shared dataset until the next daily reset.
  • Unknown fields are rejected by the database layer.