S'Post API Documentation

REST API for posts, reactions, uploads, and system stats.

Server URL

https://s-post-server/api

Post Endpoints

POST /post/make

Create a new post. Accepts multipart/form-data.

curl -X POST https://s-post-server/api/post/make \
  -F "author=John Doe" \
  -F "content=Hello world!" \
  -F "image=@photo.jpg"
{
  "success": true,
  "post": {
    "_id": "abc123",
    "author": "John Doe",
    "content": "Hello world!",
    "image": "/api/uploads/photo.jpg",
    "likes": 0,
    "dislikes": 0,
    "createdAt": "2025-08-24T12:00:00Z"
  }
}
POST /post/load

Fetch paginated posts.

{
  "loadedPost": ["id1","id2"],
  "limit": 20
}
{
  "found": true,
  "posts": [
    {
      "_id": "xyz456",
      "author": "Jane",
      "content": "New update",
      "likes": 3,
      "dislikes": 0,
      "createdAt": "2025-08-24T12:20:00Z"
    }
  ]
}
POST /post/like

Like or dislike a post.

POST /api/post/like?_id=xyz456&positive=true
{
  "liked": true,
 }

Stats

GET /stats

Get total post count and reactions count.

{
  "success": true,
  "posts": 134,
  "reactions": 98
}

Uploads

GET /uploads/:filename

Fetch uploaded image or file.

GET /api/uploads/photo.jpg

Single Post

GET /api/post/single?_id={postId}&type={type}

types query: api, app
serves single post, in two response , html and api

Api Response Sample
        
{
 found: true,
 post: {
 author: "sadiq",
 content: "sample post getting",
 createdAt: 16297229282729,
 likes: 100,
 dislikes: 0
 }
}
        
      

Home

GET /

Serves the static homepage (home.html).