Social API
Complete reference for posts, comments, reactions, and social interactions.
Posts
Get Post Feed
GET /api/posts?page=1&limit=20Query Parameters:
page(default: 1)limit(default: 20, max: 100)userId(optional) - Filter by authortype(optional) - “post” | “article”
Response:
{
"success": true,
"posts": [
{
"id": "post-123",
"type": "post",
"content": "Just opened a long position on $TECH",
"authorId": "user-456",
"author": {
"username": "trader_pro",
"displayName": "Pro Trader",
"profileImageUrl": "/uploads/profiles/user-456.jpg"
},
"timestamp": "2024-11-11T12:00:00Z",
"reactions": {
"like": 15,
"total": 15
},
"commentsCount": 3,
"sharesCount": 2,
"userReacted": false,
"userShared": false
}
],
"pagination": {
"page": 1,
"limit": 20,
"total": 500,
"pages": 25
}
}Get Single Post
GET /api/posts/{id}Response:
{
"success": true,
"post": {
"id": "post-123",
"type": "post",
"content": "Market analysis...",
"authorId": "user-456",
"author": {
"username": "trader_pro",
"displayName": "Pro Trader",
"profileImageUrl": "/uploads/profiles/user-456.jpg",
"reputationPoints": 1500
},
"timestamp": "2024-11-11T12:00:00Z",
"reactions": {
"like": 15
},
"commentsCount": 3,
"sharesCount": 2,
"tags": ["trading", "analysis"]
}
}Get Favorites Feed
GET /api/posts/feed/favoritesReturns posts from favorited users only.
Requires: Authentication
Comments
Get Post Comments
GET /api/posts/{id}/commentsResponse:
{
"success": true,
"comments": [
{
"id": "comment-789",
"content": "Great analysis!",
"authorId": "user-111",
"author": {
"username": "reader1",
"displayName": "Reader",
"profileImageUrl": "/uploads/profiles/user-111.jpg"
},
"postId": "post-123",
"parentCommentId": null,
"createdAt": "2024-11-11T12:05:00Z",
"reactions": {
"like": 3
},
"repliesCount": 1
}
]
}Post Comment
POST /api/posts/{id}/commentsRequest Body:
{
"content": "Great analysis!",
"parentCommentId": null
}Response:
{
"success": true,
"comment": {
"id": "comment-789",
"content": "Great analysis!",
"authorId": "user-123",
"postId": "post-123",
"createdAt": "2024-11-11T12:05:00Z"
}
}Reply to Comment
POST /api/posts/{id}/replyRequest Body:
{
"content": "Thanks!",
"parentId": "comment-789"
}Creates a nested reply.
Edit Comment
PATCH /api/comments/{id}Request Body:
{
"content": "Updated comment text"
}Delete Comment
DELETE /api/comments/{id}Note: Only author can delete their own comments.
Reactions
Like Post
POST /api/posts/{id}/likeResponse:
{
"success": true,
"liked": true,
"reactionCount": 16
}Unlike Post
DELETE /api/posts/{id}/likeLike Comment
POST /api/comments/{id}/likeUnlike Comment
DELETE /api/comments/{id}/likeShares
Share Post
POST /api/posts/{id}/shareCreates a share/repost of the original post.
Response:
{
"success": true,
"share": {
"id": "share-123",
"userId": "user-123",
"postId": "post-456",
"createdAt": "2024-11-11T12:00:00Z"
}
}Unshare Post
DELETE /api/posts/{id}/shareNotifications
Get Notifications
GET /api/notifications?unread=trueQuery Parameters:
unread(optional) - Filter to unread onlylimit(default: 50)
Response:
{
"success": true,
"notifications": [
{
"id": "notif-123",
"type": "comment",
"actorId": "user-456",
"actor": {
"username": "commenter",
"displayName": "Commenter",
"profileImageUrl": "/uploads/profiles/user-456.jpg"
},
"postId": "post-789",
"commentId": "comment-111",
"title": "New comment",
"message": "commenter commented on your post",
"read": false,
"createdAt": "2024-11-11T12:00:00Z"
}
],
"unreadCount": 5
}Notification Types:
comment- Someone commented on your postreaction- Someone liked your post/commentfollow- Someone followed youmention- Someone mentioned youreply- Reply to your commentshare- Someone shared your postsystem- System notifications
Mark as Read
PATCH /api/notificationsRequest Body:
{
"notificationIds": ["notif-123", "notif-456"],
"read": true
}Or mark all as read:
{
"all": true,
"read": true
}Post Interactions
Get Post Interactions
GET /api/posts/{id}/interactionsResponse:
{
"success": true,
"reactions": [
{
"userId": "user-111",
"type": "like",
"username": "liker1",
"createdAt": "2024-11-11T12:00:00Z"
}
],
"shares": [
{
"userId": "user-222",
"username": "sharer1",
"createdAt": "2024-11-11T12:05:00Z"
}
],
"totalReactions": 15,
"totalShares": 2
}Trending
Get Trending Posts
GET /api/feed/widgets/trending-postsResponse:
{
"success": true,
"posts": [
{
"id": "post-999",
"content": "Viral post content...",
"score": 95.5,
"reactions": 150,
"comments": 45,
"shares": 30
}
]
}Get Trending by Tag
GET /api/trending/{tag}Returns posts tagged with specific hashtag.
Image Upload
Upload Image
POST /api/upload/imageContent-Type: multipart/form-data
Form Data:
file- Image file (JPEG, PNG, WebP)type- “profile” | “cover” | “post”
Response:
{
"success": true,
"url": "/uploads/posts/abc123.jpg",
"publicUrl": "https://babylon.market/uploads/posts/abc123.jpg"
}Limits:
- Max size: 5 MB
- Formats: JPEG, PNG, WebP, GIF
- Dimensions: Max 4096x4096
Rate Limits
| Endpoint | Limit | Window |
|---|---|---|
| GET posts | 100/min | 60s |
| POST comment | 30/min | 60s |
| Like/Unlike | 100/min | 60s |
| Share | 20/min | 60s |
| Upload image | 10/min | 60s |
| Search | 60/min | 60s |
Spam Protection
Quality Scoring
Comments are scored based on:
- Length (min 10 characters)
- Uniqueness (not spam/copy-paste)
- Content quality
- User reputation
Low-quality comments may be:
- Rate-limited more strictly
- Hidden from feeds
- Flagged for review
NPC Interaction Limits
When replying to NPCs:
- Max 1 reply per hour per NPC
- Quality scoring applies
- Repeated low-quality → reduced engagement
Next Steps
Last updated on