A description of all the API endpoints, their URL and request parameters.
url : /users/profile/
method : GET
Successful : 200_OK
Unsuccessful : 404_BAD_REQUEST / 401_UNAUTHORIZED
Response : {
"roll",
"username",
"name",
"email",
"fblink"
}
Note : User needs to be logged in to use this API.
url : /users/auth/login/
method : POST
parameters = {
"username" : "<username>",
"password" : "<password>:
}
Successful : 200_OK
Unsuccessful : 400_BAD_REQUEST / 401_UNAUTHORIZED
url : /users/auth/logout/
method : POST
parameters = {}
Successful : 200_OK
Unsuccessful : 401_UNAUTHORIZED
To follow another user.
url : /users/follow/
method : PUT
parameters = {"username" : "<username of the user to be followed>"}
Successful : 200_OK
Unsuccessful : 400_BAD_REQUEST / 401_UNAUTHORIZED
To unfollow a user who is already followed.
url : /users/unfollow/
method : DELETE
parameters = {"username" : "<username of the user to be unfollowed">}
Successful : 200_OK
Unsuccessful : 400_BAD_REQUEST / 401_UNAUTHORIZED
To see posts from followed users and streams
url : /users/feed/
method : GET
Successful : {
"post_title",
"post_text",
"pub_date",
"last_modified",
"author",
"stream"
}
Unsuccessful : 401_UNAUTHORIZED
To display posts corresponding to a user
url : /users/<int:pk>/posts
method : GET
comments : pk in url is the primary key for user
Successful : {
[
{
"post_title",
"post_text",
"pub_date",
"last_modified",
"author",
"stream"
},
],
"username"
}
Unsuccessful : 404_NOT_FOUND
To display posts corresponding to bookmarks of a loggedin user
url: /users/bookmarks/
method: GET
comments: the user must be logged in
Successful : {
"post_title",
"post_text",
"pub_date",
"last_modified",
"author",
"stream"
}
Unsuccessful : 400_BAD_REQUEST / 401_UNAUTHORIZED
To create a new post
url : /posts/create/
method : POST
parameters = {
"title" : "<title of the post to be created>",
"text" : "<contents of the post>",
"stream" : "<title of the stream under which this post comes>"
}
Successful : 201_CREATED
Unsuccessful : 400_BAD_REQUEST / 401_UNAUTHORIZED
Allows deletion of a post by its author.
url : /posts/delete/
method : DELETE
parameters = {"pk" : "<primary key of the post>"}
Successful : 204_NO_CONTENT
Unsuccessful : 400_BAD_REQUEST / 401_UNAUTHORIZED
To see a post in detail
url : /posts/view/<int:pk>/
method : GET
Successful : {
"pk",
"post_title",
"post_text",
"pub_date",
"last_modified",
"author",
"stream"
}
Unsuccessful : 404_NOT_FOUND
Edit post if user is the author.
url : /posts/edit/
method : PUT
parameters = {
"pk" : "<primary key of the post>",
"title" : "<new title>",
"text" : "<new content>"
}
Successful : 201_CREATED
Unsuccessful : 400_BAD_REQUEST / 401_UNAUTHORIZED
To follow a stream.
url : /streams/follow/
method : PUT
parameters = {"title" : "<title of the stream to be followed>"}
Successful : 200_OK
Unsuccessful : 400_BAD_REQUEST / 401_UNAUTHORIZED
To unfollow a stream.
url : /streams/unfollow/
method : DELETE
parameters = {"title" : "<title of the stream to be unfollowed>"}
Successful : 200_OK
Unsuccessful : 400_BAD_REQUEST / 401_UNAUTHORIZED
To display posts corresponding to a stream
url : /streams/<int:pk>/posts/
method : GET
Successful : {
"title",
[
{
"post_title",
"post_text",
"pub_date",
"last_modified",
"author",
"stream"
},
]
}
Unsuccessful : 404_NOT_FOUND
Displays all the streams subscribed by the user.
url : /streams/subbed/
method : GET
Successful : [
{
"title",
"description",
"pk"
},
]
200_OK
Unsuccessful : 400_BAD_REQUEST / 401_UNAUTHORIZED
url : /streams/all/
method : GET
Successful : [
{
"title",
"description",
"pk",
"is_subscribed"
},
]
200_OK
Unsuccessful : 400_BAD_REQUEST / 401_UNAUTHORIZED
To bookmark a post or to unbookmark already existing bookmark
url : /bookmarks/create/
method : POST
parameters = {"pk":"<primary key of the post>"}
Successful : 201_CREATED / 204_NO_CONTENT
Unsuccessful : 400_BAD_REQUEST / 401_UNAUTHORIZED
To comment on post or sub-comment on a comment
url : /comments/create/
method : POST
parameters = {
"content" : "<content of comment>",
"post_id" : "<primary key of the post>",
"parent_id" : "<primary key of the parent comment">
}
comments : parent_id is not required if the comment is not a reply
Successful : {
"pk",
"parent",
"post",
"content",
"created_at",
"user"
"replies": []
}
200_OK
Unsuccessful : 400_BAD_REQUEST / 401_UNAUTHORIZED / 404_NOT_FOUND
To delete a comment on a post(all sub-comments will be deleted)/delete sub-comments(all of its sub-comments will be deleted).Recursive deletion will be followed
url : /comments/delete
method : DELETE
parameters = {
"pk":"<primary key of the comment>"
}
Successful : 204_NO_CONTENT
Unsuccessful : 400_BAD_REQUEST / 401_UNAUTHORIZED / 404_NOT_FOUND
View all the comments (and their replies) of a post recursively.
url: /comments/view/<int:pk>/
method : GET
pk = primary key of the post
Successful : [
{
"pk",
"parent",
"post",
"content",
"created_at",
"user"
"replies": [
<comment>,
<comment>
]
},
]
Unsuccessful : 404_NOT_FOUND