Comments
Overview
Section titled “Overview”The Comments resource provides fake comment data with names, emails, and body content.
Endpoints
Section titled “Endpoints”Available Endpoints
| Method | Endpoint | Description |
|---|---|---|
| GET | /v1/comments | List all comments |
| GET | /v1/comments/:id | Get a specific comment |
Comment Object
Section titled “Comment Object”{ "id": 1, "postId": 1, "name": "Jane Doe", "email": "jane@example.com", "body": "Great post!", "createdAt": "2026-01-15T10:30:00.000Z", "updatedAt": "2026-01-15T10:30:00.000Z"}| Field | Type | Description |
|---|---|---|
id |
number |
Unique identifier |
postId |
number |
ID of the post |
name |
string |
Commenter’s name |
email |
string |
Commenter’s email |
body |
string |
Comment content |
createdAt |
string |
ISO 8601 timestamp |
updatedAt |
string |
ISO 8601 timestamp |
List Comments
Section titled “List Comments”curl https://api.phantomjson.app/v1/commentsQuery Parameters
Section titled “Query Parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
page |
number |
1 |
Page number |
limit |
number |
20 |
Items per page (max: 100) |
sort |
string |
— | Sort field and direction |
q |
string |
— | Search query |
fields |
string |
— | Fields to return |
postId |
number |
— | Filter by post ID |
Response
Section titled “Response”{ "data": [ { "id": 1, "postId": 1, "name": "Jane Doe", "email": "jane@example.com", "body": "Great post!" } ], "meta": { "total": 1500, "page": 1, "limit": 20, "totalPages": 75 }}Get Comment by ID
Section titled “Get Comment by ID”curl https://api.phantomjson.app/v1/comments/1Response
Section titled “Response”{ "data": { "id": 1, "postId": 1, "name": "Jane Doe", "email": "jane@example.com", "body": "Great post!" }}Examples
Section titled “Examples”Search Comments
Section titled “Search Comments”curl "https://api.phantomjson.app/v1/comments?q=great"Filter by Post
Section titled “Filter by Post”curl "https://api.phantomjson.app/v1/comments?postId=1"Sort by Name
Section titled “Sort by Name”curl "https://api.phantomjson.app/v1/comments?sort=name:asc"Field Selection
Section titled “Field Selection”curl "https://api.phantomjson.app/v1/comments?fields=id,name,body"Relations
Section titled “Relations”- Post — Each comment belongs to a post (
postId) - Access comments for a specific post via
/v1/posts/:id/comments
