← Back to All APIs

Posts API

Blog posts with comments and author information

Base URL
https://fakeapi.in/api/posts

API Endpoints

GET/api/posts
Copy All

Get all posts

Parameters

page(number)
Page number for pagination (optional)
limit(number)
Number of posts per page (optional)
sortField(string)
Field to sort by (e.g. title, date, author)
sortOrder(string)
Sorting order (asc or desc)
GET/api/posts/1
Copy All

Get post by ID

Parameters

id(number)
Unique ID of the post to fetch
GET/api/posts?q=First
Copy All

Search posts by title containing 'First'

Parameters

q(string)
Keyword to search posts by title
GET/api/posts?authorId=5
Copy All

Filter posts by author ID

Parameters

authorId(number)
Filter posts by author ID
GET/api/posts?category=Tech
Copy All

Filter posts by category

Parameters

category(string)
Filter posts by category name
GET/api/posts?tags=React
Copy All

Filter posts by tag 'React'

Parameters

tags(string)
Filter posts by tags (comma-separated values)
GET/api/posts?sortField=title&sortOrder=asc
Copy All

Get posts sorted by title ascending

Parameters

sortField(string)
Field to sort by (e.g. title, createdAt)
sortOrder(string)
Sorting order (asc or desc)
GET/api/posts?sortField=title&sortOrder=desc
Copy All

Get posts sorted by title descending

Parameters

sortField(string)
Field to sort by (e.g. title, createdAt)
sortOrder(string)
Sorting order (asc or desc)
GET/api/posts?page=2&limit=10
Copy All

Get posts with pagination (page 2, 10 per page)

Parameters

page(number)
Page number for pagination
limit(number)
Number of posts per page
GET/api/posts?sortField=title&sortOrder=desc&page=2&limit=50
Copy All

Combined filters: search, filter, sort, and paginate posts

Parameters

q(string)
Search keyword for post titles
category(string)
Filter by category name
authorId(number)
Filter by author ID
tags(string)
Filter by tags (comma-separated)
sortField(string)
Field to sort by (e.g. title, createdAt)
sortOrder(string)
Sorting order (asc or desc)
page(number)
Page number for pagination
limit(number)
Number of posts per page
POST/api/posts
Copy All

Create post

Parameters

title(string)
Post title
content(string)
Full content of the post
authorId(number)
ID of the author creating the post
category(string)
Post category
tags(array)
Tags related to the post
status(string)
Post status (draft, published, archived)
image(string)
Featured image URL (optional)
PATCH/api/posts/1
Copy All

Partially update post (only specific fields)

Parameters

id(number)
Post ID to update
fields(object)
Fields to update (e.g. { title, content })
PUT/api/posts/1
Copy All

Update post (replace all fields)

Parameters

id(number)
Post ID to update
title(string)
Updated post title
content(string)
Updated post content
authorId(number)
Updated author ID
category(string)
Updated category
tags(array)
Updated tags
status(string)
Updated post status
image(string)
Updated featured image URL
DELETE/api/posts/1
Copy All

Delete post

Parameters

id(number)
Post ID to delete

Example Usage

Copy All

import axios from "axios";

const API_URL = process.env.NEXT_PUBLIC_API_URL;

// Get all products
axios
  .get(`${API_URL}api/products`)
  .then(res => console.log("All Products:", res.data))
  .catch(err => console.error(err));

// Create a new product
axios
  .post(`${API_URL}api/products`, {
    name: "Laptop",
    price: 79999,
    category: "Electronics"
  })
  .then(res => console.log("Product Created:", res.data))
  .catch(err => console.error(err));

Example Response

Copy All
  {
       "id": 1,
      "title": "Charisma cattus utrum dedico vespillo.",
      "content": "Vindico uter voluntarius sono. Fugiat tenetur voluptatibus earum ipsa. Verumtamen aureus baiulus similique vilitas.
Sono cupiditas delicate bis ager debilito alienus ambitus ter. Anser eveniet tardus. Audio argentum possimus turbo decet.",
      "author": "Jermaine Willms",
      "category": "Education",
      "likes": 797,
      "comments": 175,
      "publishedAt": "2025-10-19T13:29:54.519Z",
      "createdAt": "2024-10-23T03:27:50.255Z"
    }

Quick Actions

Test in Playground

API Status

StatusOperational
Rate Limit1000 requests/hour
Response FormatJSON
Posts API - Blog & Content Management Documentation | FakeAPI.in