Post APIs

Create new post

post

This api allow the user to create new post to topic in nodebb

Path parameters
tidintegerRequired
Header parameters
AuthorizationstringRequired
Body
contentstringRequired
toPidintegerOptional
Responses
200
successful operation
application/json
post
POST /api/discussion/v2/topics/{tid} HTTP/1.1
Host: staging.sunbirded.org
Authorization: text
Content-Type: application/json
Accept: */*
Content-Length: 46

{
  "content": "Example reply to topic",
  "toPid": 1
}
{
  "code": "code",
  "payload": {
    "topicData": {
      "pinned": 4,
      "lastposttime": 6,
      "upvotes": 7,
      "unreplied": 6,
      "mainPost": {},
      "unread": true,
      "timestampISO": "timestampISO",
      "title": "title",
      "teaserPid": {},
      "tid": 5,
      "uid": 7,
      "lastposttimeISO": "lastposttimeISO",
      "deleterUid": 1,
      "isOwner": true,
      "mainPid": 1,
      "locked": 2,
      "slug": "slug",
      "timestamp": 2,
      "ignored": true,
      "downvotes": 1,
      "icons": {},
      "tags": {},
      "bookmark": {},
      "deleted": 3,
      "postcount": 5,
      "viewcount": 9,
      "titleRaw": "titleRaw",
      "votes": 1,
      "category": {},
      "user": {},
      "cid": 0,
      "teaser": {}
    },
    "postData": {
      "isMain": true,
      "bookmarked": true,
      "selfPost": true,
      "index": 9,
      "pid": 7,
      "timestampISO": "timestampISO",
      "display_edit_tools": true,
      "tid": 4,
      "content": "content",
      "uid": 1,
      "display_moderator_tools": true,
      "display_move_tools": true,
      "topic": {},
      "votes": 6,
      "display_delete_tools": true,
      "user": {},
      "timestamp": 5,
      "cid": 9
    }
  }
}

Create reply to post

post

This api allow the user to create reply to post in nodebb

Path parameters
tidintegerRequired
Header parameters
AuthorizationstringRequired
Body
contentstringRequired
toPidintegerRequired
Responses
200
successful operation
application/json
post
POST /api/discussion/v2/topics/{tid} HTTP/1.1
Host: staging.sunbirded.org
Authorization: text
Content-Type: application/json
Accept: */*
Content-Length: 46

{
  "content": "Example reply to topic",
  "toPid": 1
}
{
  "code": "code",
  "payload": {
    "topicData": {
      "pinned": 4,
      "lastposttime": 6,
      "upvotes": 7,
      "unreplied": 6,
      "mainPost": {},
      "unread": true,
      "timestampISO": "timestampISO",
      "title": "title",
      "teaserPid": {},
      "tid": 5,
      "uid": 7,
      "lastposttimeISO": "lastposttimeISO",
      "deleterUid": 1,
      "isOwner": true,
      "mainPid": 1,
      "locked": 2,
      "slug": "slug",
      "timestamp": 2,
      "ignored": true,
      "downvotes": 1,
      "icons": {},
      "tags": {},
      "bookmark": {},
      "deleted": 3,
      "postcount": 5,
      "viewcount": 9,
      "titleRaw": "titleRaw",
      "votes": 1,
      "category": {},
      "user": {},
      "cid": 0,
      "teaser": {}
    },
    "postData": {
      "isMain": true,
      "bookmarked": true,
      "selfPost": true,
      "index": 9,
      "pid": 7,
      "timestampISO": "timestampISO",
      "display_edit_tools": true,
      "tid": 4,
      "content": "content",
      "uid": 1,
      "display_moderator_tools": true,
      "display_move_tools": true,
      "topic": {},
      "votes": 6,
      "display_delete_tools": true,
      "user": {},
      "timestamp": 5,
      "cid": 9
    }
  }
}

Delete a post by postID

delete

This api allows the user to delete post in the nodebb

Path parameters
pidintegerRequired
Header parameters
AuthorizationstringRequired
Responses
200
successful operation
application/json
delete
DELETE /api/discussion/v2/posts/{pid} HTTP/1.1
Host: staging.sunbirded.org
Authorization: text
Accept: */*
{
  "code": "code",
  "payload": {}
}

Vote a post by postID

post

This api allows the user to vote(Up/down) to post in the nodebb

Path parameters
pidintegerRequired
Header parameters
AuthorizationstringRequired
Body
deltaintegerRequired

delta must be a number. If delta > 0, it's considered an upvote; if delta < 0, it's considered a downvote; otherwise, it's an unvote.

Responses
200
successful operation
application/json
post
POST /api/discussion/v2/posts/{pid}/vote HTTP/1.1
Host: staging.sunbirded.org
Authorization: text
Content-Type: application/json
Accept: */*
Content-Length: 11

{
  "delta": 1
}
{
  "code": "code",
  "payload": {}
}

Remove votes for a post by postID

delete

This api allows the user to delete vote(Up/down) to post in the nodebb

Path parameters
pidintegerRequired
Header parameters
AuthorizationstringRequired
Responses
200
successful operation
application/json
delete
DELETE /api/discussion/v2/posts/{pid}/vote HTTP/1.1
Host: staging.sunbirded.org
Authorization: text
Accept: */*
{
  "code": "code",
  "payload": {}
}

Bookmarks a post by postID

post

This api allows the user to bookmarks a post in the nodebb

Path parameters
pidintegerRequired
Header parameters
AuthorizationstringRequired
Responses
200
successful operation
application/json
post
POST /api/discussion/v2/posts/{pid}/bookmark HTTP/1.1
Host: staging.sunbirded.org
Authorization: text
Accept: */*
{
  "code": "code",
  "payload": {}
}

Removes bookmarks for a post by postID

delete

This api allows the user to Unbookmarks a post in the nodebb

Path parameters
pidintegerRequired
Header parameters
AuthorizationstringRequired
Responses
200
successful operation
application/json
delete
DELETE /api/discussion/v2/posts/{pid}/bookmark HTTP/1.1
Host: staging.sunbirded.org
Authorization: text
Accept: */*
{
  "code": "code",
  "payload": {}
}

Restores a post

put

This api allows the user to Restores a post in the nodebb

Path parameters
pidintegerRequired
Header parameters
AuthorizationstringRequired
Responses
200
successful operation
application/json
put
PUT /api/discussion/v2/posts/{pid}/state HTTP/1.1
Host: staging.sunbirded.org
Authorization: text
Accept: */*
{
  "code": "code",
  "payload": {}
}

Deletes a post (Soft-delete)

delete

This api allows the user to Deletes a post in the nodebb

Path parameters
pidintegerRequired
Header parameters
AuthorizationstringRequired
Responses
200
successful operation
application/json
delete
DELETE /api/discussion/v2/posts/{pid}/state HTTP/1.1
Host: staging.sunbirded.org
Authorization: text
Accept: */*
{
  "code": "code",
  "payload": {}
}

Last updated

Was this helpful?