Posts
Overview
Section titled “Overview”The Posts resource provides fake blog post data with titles, body content, and user relationships.
Endpoints
Section titled “Endpoints”Available Endpoints
| Method | Endpoint | Description |
|---|---|---|
| GET | /v1/posts | List all posts |
| GET | /v1/posts/:id | Get a specific post |
| GET | /v1/posts/:id/comments | Get post's comments |
Post Object
Section titled “Post Object”{ "id": 1, "userId": 1, "title": "First Post", "body": "This is the body of the first post.", "createdAt": "2026-01-15T10:30:00.000Z", "updatedAt": "2026-01-15T10:30:00.000Z"}| Field | Type | Description |
|---|---|---|
id |
number |
Unique identifier |
userId |
number |
ID of the author |
title |
string |
Post title |
body |
string |
Post content |
createdAt |
string |
ISO 8601 timestamp |
updatedAt |
string |
ISO 8601 timestamp |
List Posts
Section titled “List Posts”curl https://api.phantomjson.app/v1/postsQuery 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 |
userId |
number |
— | Filter by user ID |
Response
Section titled “Response”{ "data": [ { "id": 1, "userId": 1, "title": "First Post", "body": "This is the body of the first post." } ], "meta": { "total": 500, "page": 1, "limit": 20, "totalPages": 25 }}Get Post by ID
Section titled “Get Post by ID”curl https://api.phantomjson.app/v1/posts/1Response
Section titled “Response”{ "data": { "id": 1, "userId": 1, "title": "First Post", "body": "This is the body of the first post." }}Get Post’s Comments
Section titled “Get Post’s Comments”curl https://api.phantomjson.app/v1/posts/1/commentsResponse
Section titled “Response”{ "data": [ { "id": 1, "postId": 1, "name": "Jane Doe", "email": "jane@example.com", "body": "Great post!" } ], "meta": { "total": 3, "page": 1, "limit": 20, "totalPages": 1 }}Examples
Section titled “Examples”Search Posts
Section titled “Search Posts”curl "https://api.phantomjson.app/v1/posts?q=react"Filter by User
Section titled “Filter by User”curl "https://api.phantomjson.app/v1/posts?userId=1"Sort by Date
Section titled “Sort by Date”curl "https://api.phantomjson.app/v1/posts?sort=createdAt:desc"Field Selection
Section titled “Field Selection”curl "https://api.phantomjson.app/v1/posts?fields=id,title,userId"Relations
Section titled “Relations”- User — Each post belongs to a user (
userId) - Comments — Each post has many comments (access via
/v1/posts/:id/comments)
