📄 Post Endpoints - abrakingoo/social_network GitHub Wiki
📝 Add Post
Endpoint:
POST /api/addPosts
Content-Type:
multipart/form-data
Authentication:
Requires login and CSRF protection (session_id
+ X-CSRF-Token
)
Description:
Creates a new post with optional media attachments and visibility control. Multiple media files can be attached. Posts can be public, visible to followers, or restricted to specific users.
Request Parameters (FormData):
Parameter | Type | Required | Description |
---|---|---|---|
content | string | Yes | Description text of the post |
media | file[] | Optional | One or more images/GIFs/videos |
privacy | string | Optional | Visibility level: public (default), almost_private , or private |
visible_to | string | Conditional | JSON-encoded array of user UUIDs (only used when privacy = private ) |
Allowed privacy
values:
public
— post visible to all usersalmost_private
— visible only to accepted followersprivate
— visible only to users specified invisible_to
Example for visible_to
in Postman:
Key | Value |
---|---|
visible_to | ["uuid1", "uuid2", "uuid3"] |
The
visible_to
field must be a JSON-encoded array of strings, not plain text.
Allowed Media MIME Types:
image/jpeg
image/png
image/gif
video/mp4
video/quicktime
Response – Success:
{
"message": "Post added successfully"
}
Response – Error:
{
"error": "Descriptive error message"
}
📥 Get Posts
Endpoint:
GET /api/getPosts
Authentication:
Requires login (session_id
cookie)
Description:
Retrieves a list of posts, including their content, media, comment threads, and interaction metrics (likes, dislikes, etc.).
Response – Success:
[
{
"id": "string",
"group_id": "string",
"content": "string",
"likes_count": 0,
"dislikes_count": 0,
"comments_count": 0,
"comments": [
{
"id": "string",
"post_id": "string",
"user_id": "string",
"group_id": "string",
"content": "string",
"media": [
{ "url": "string" }
],
"likes_count": 0,
"dislikes_count": 0,
"created_at": "2023-01-01T00:00:00Z"
}
],
"media": [
{ "url": "string" }
],
"privacy": "string",
"created_at": "2023-01-01T00:00:00Z"
}
]
Response – Error:
{
"error": "Descriptive error message"
}
💬 Add Comment
Endpoint:
POST /api/addComment
CORS Support:
Also accepts OPTIONS
request for CORS preflight.
Authentication:
Requires login (session_id cookie) and CSRF protection (X-CSRF-Token header)
Content-Type:
application/json
Description:
Adds a new comment to a post or as a reply to another comment.
Request Body:
{
"post_id": "string", // ID of the post being commented on
"content": "string", // Text content of the comment
"comment_id": "string" // Optional: ID of the comment being replied to (for nested comments)
}
Response:
Success:
{
"message": "Comment added successfully"
}
Error:
{
"error": "Descriptive error message"
}