Documentation menu

Resource reference

Comments

Post comments with author details and a nested post summary.

500 records after each resetView live JSON

Data model

Comments schema

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

FieldTypeRequiredDescription
idintegerRead onlyAuto-incrementing resource identifier.
namestringRequiredComment subject or author label, 1 to 100 characters.
emailemail stringRequiredValid author email address.
bodystringRequiredComment text, 1 to 1,000 characters.
postIdintegerRequiredParent post ID.
postobjectRead onlyNested parent post ID and title.
createdAtISO 8601 stringRead onlyTime the record was created.
updatedAtISO 8601 stringRead onlyTime the record was last updated.

Example object

A complete comment

JSON
{
  "id": 1,
  "name": "A useful response",
  "email": "reader@example.com",
  "body": "This explanation made the implementation much clearer.",
  "postId": 1,
  "createdAt": "2026-07-22T00:00:03.599Z",
  "updatedAt": "2026-07-22T00:00:03.599Z",
  "post": {
    "id": 1,
    "title": "Getting Started with Modern Web Development: A Practical First Project"
  }
}

Endpoints

Read and write comments

Every example uses the shared free API. Replace :id with a numeric record ID.

GET/comments

List comments

Returns paginated comments with a nested post summary.

cURL request
curl 'https://api.apimocker.com/comments'

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.
body_likestringOptionalPartial, case-insensitive body match.
emailstringOptionalExact email match.

Example response

JSON
{
  "data": [
    {
      "id": 1,
      "name": "A useful response",
      "email": "reader@example.com",
      "body": "This explanation made the implementation much clearer.",
      "postId": 1,
      "createdAt": "2026-07-22T00:00:03.599Z",
      "updatedAt": "2026-07-22T00:00:03.599Z",
      "post": {
        "id": 1,
        "title": "Getting Started with Modern Web Development: A Practical First Project"
      }
    }
  ],
  "pagination": {
    "page": 1,
    "limit": 10,
    "total": 500,
    "totalPages": 50,
    "hasNext": true,
    "hasPrev": false
  }
}

GET/comments/search?q=clearer

Search comments

Searches name, email, and body and returns up to 10 matches.

cURL request
curl 'https://api.apimocker.com/comments/search?q=clearer'

Parameters

ParameterTypeRequiredDescription
qstringRequiredCase-insensitive search text.
_delayintegerOptionalArtificial response delay in milliseconds.

Example response

JSON
{
  "query": "clearer",
  "total": 1,
  "results": [
    {
      "id": 1,
      "name": "A useful response",
      "email": "reader@example.com",
      "body": "This explanation made the implementation much clearer.",
      "postId": 1,
      "createdAt": "2026-07-22T00:00:03.599Z",
      "updatedAt": "2026-07-22T00:00:03.599Z",
      "post": {
        "id": 1,
        "title": "Getting Started with Modern Web Development: A Practical First Project"
      }
    }
  ]
}

GET/comments/:id

Get one comment

Returns a comment directly with its nested post summary.

cURL request
curl 'https://api.apimocker.com/comments/1'

Parameters

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

Example response

JSON
{
  "id": 1,
  "name": "A useful response",
  "email": "reader@example.com",
  "body": "This explanation made the implementation much clearer.",
  "postId": 1,
  "createdAt": "2026-07-22T00:00:03.599Z",
  "updatedAt": "2026-07-22T00:00:03.599Z",
  "post": {
    "id": 1,
    "title": "Getting Started with Modern Web Development: A Practical First Project"
  }
}

POST/comments

Create a comment

201 Created

Creates a comment for an existing post.

cURL request
curl -X POST 'https://api.apimocker.com/comments' \
  -H 'Content-Type: application/json' \
  -d '{   "name": "Helpful article",   "email": "reader@example.com",   "body": "This was useful.",   "postId": 1 }'

Request body

JSON
{
  "name": "Helpful article",
  "email": "reader@example.com",
  "body": "This was useful.",
  "postId": 1
}

Example response

JSON
{
  "id": 1,
  "name": "A useful response",
  "email": "reader@example.com",
  "body": "This explanation made the implementation much clearer.",
  "postId": 1,
  "createdAt": "2026-07-22T00:00:03.599Z",
  "updatedAt": "2026-07-22T00:00:03.599Z",
  "post": {
    "id": 1,
    "title": "Getting Started with Modern Web Development: A Practical First Project"
  }
}

  • Writes affect the shared dataset until the next daily reset.
  • Unknown fields are rejected by the database layer.

PUT/comments/:id

Replace a comment

200 OK

Updates a comment. Name, email, body, and postId are required.

cURL request
curl -X PUT 'https://api.apimocker.com/comments/1' \
  -H 'Content-Type: application/json' \
  -d '{   "name": "Updated comment",   "email": "reader@example.com",   "body": "The updated response.",   "postId": 1 }'

Parameters

ParameterTypeRequiredDescription
idintegerRequiredThe resource ID from the URL path.

Request body

JSON
{
  "name": "Updated comment",
  "email": "reader@example.com",
  "body": "The updated response.",
  "postId": 1
}

Example response

JSON
{
  "id": 1,
  "name": "A useful response",
  "email": "reader@example.com",
  "body": "This explanation made the implementation much clearer.",
  "postId": 1,
  "createdAt": "2026-07-22T00:00:03.599Z",
  "updatedAt": "2026-07-22T00:00:03.599Z",
  "post": {
    "id": 1,
    "title": "Getting Started with Modern Web Development: A Practical First Project"
  }
}

  • Writes affect the shared dataset until the next daily reset.
  • Unknown fields are rejected by the database layer.

PATCH/comments/:id

Update selected comment fields

200 OK

Updates only the provided fields.

cURL request
curl -X PATCH 'https://api.apimocker.com/comments/1' \
  -H 'Content-Type: application/json' \
  -d '{   "body": "A corrected response." }'

Parameters

ParameterTypeRequiredDescription
idintegerRequiredThe resource ID from the URL path.

Request body

JSON
{
  "body": "A corrected response."
}

Example response

JSON
{
  "id": 1,
  "name": "A useful response",
  "email": "reader@example.com",
  "body": "This explanation made the implementation much clearer.",
  "postId": 1,
  "createdAt": "2026-07-22T00:00:03.599Z",
  "updatedAt": "2026-07-22T00:00:03.599Z",
  "post": {
    "id": 1,
    "title": "Getting Started with Modern Web Development: A Practical First Project"
  }
}

  • Writes affect the shared dataset until the next daily reset.
  • Unknown fields are rejected by the database layer.

DELETE/comments/:id

Delete a comment

204 No Content

Deletes the comment permanently until the next reset.

cURL request
curl -X DELETE 'https://api.apimocker.com/comments/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.