Posts

This section describes the endpoints for managing posts.

Post Model

The Post object represents a post in the system.

Post Object
{
    "id": 0,
    "title": "string",
    "content": "string",
    "poster": 0,
    "post_date": 0,
    "likes": 0,
    "likers": [0],
    "nsfw": false,
    "belongs_to": 0,
    "edited": false,
    "edited_at": 0
}

Endpoints

/posts [GET]

Get a list of all posts, sorted by date (newest first).

Return Example

200 OK
[
    {
        "id": 1,
        "title": "Nergeo just launched!",
        "content": "Welcome to the new platform!",
        "poster": 1,
        "post_date": 1752889000,
        "likes": 0,
        "likers": [2,3,4],
        "nsfw": false,
        "belongs_to": 1,
        "edited": false,
        "edited_at": 0
    }
]
* /posts [POST]

Create a new post.

Request Example

Body
{
    "title": "My New Post",
    "content": "This is the content of my new post.",
    "nsfw": false,
    "belongs_to": 1
}

Return Example

201 Created
{
    "id": 16,
    "title": "My New Post",
    "content": "This is the content of my new post.",
    "poster": 1,
    "post_date": 1752894400,
    "likes": 0,
    "likers": null,
    "nsfw": false,
    "belongs_to": 1,
    "edited": false,
    "edited_at": 0
}
/posts/{id} [GET]

Get a single post by its ID.

Return Example

200 OK
{
    "id": 1,
    "title": "Nergeo just launched!",
    "content": "Welcome to the new platform!",
    "poster": 1,
    "post_date": 1752889000,
    "likes": 0,
    "likers": [2,3,4],
    "nsfw": false,
    "belongs_to": 1,
    "edited": false,
    "edited_at": 0
}
* /posts/{id}/edit [PUT]

Edit a post by its ID. You can only edit your own posts.

Request Example

Body
{
    "title": "My Edited Post",
    "content": "This is the new content.",
    "nsfw": false
}
/users/{id}/posts [GET]

Get all posts made by a specific user.

/communities/{id}/posts [GET]

Get all posts made in a specific community.

* /posts/{id}/like [POST]

Like a post by its ID.

* /posts/{id}/unlike [POST]

Remove a like from a post by its ID.

* /posts/{id}/haveiliked [GET]

Check if the authenticated user has liked a post.

Return Example

200 OK
{
    "liked": true
}

Last updated