-
Notifications
You must be signed in to change notification settings - Fork 2
Backend Endpoints
Sanjeev Kotha edited this page Oct 28, 2022
·
23 revisions
Overview of the APIs Endpoints
| Modules | URLs | Methods Available |
|---|---|---|
| Authors | /authors/ | GET |
| Single Author | /authors/{AUTHOR_ID}/ | GET, POST |
| Followers | /authors/{AUTHOR_ID}/followers | GET |
| Follower | /authors/{AUTHOR_ID}/followers/{FOREIGN_AUTHOR_ID} | GET, PUT, DELETE |
| Post | /authors/{AUTHOR_ID}/posts/{POST_ID} | GET, POST, DELETE |
| Single Post | /authors/{AUTHOR_ID}/posts/ | GET, POST |
| Image Posts | /authors/{AUTHOR_ID}/posts/{POST_ID}/image | GET |
| Comments | /authors/{AUTHOR_ID}/posts/{POST_ID}/comments | GET, POST |
| Like (Posts) | /authors/{AUTHOR_ID}/posts/{POST_ID}/likes | GET |
| Like (Comments) | /authors/{AUTHOR_ID}/posts/{POST_ID}/comments/{COMMENT_ID}/likes | GET |
| Liked | /authors/{AUTHOR_ID}/liked/ | GET |
| Inbox | /authors/{AUTHOR_ID}/inbox/ | GET, POST, DELETE |
-
URL: /authors/
-
GET [local]: retrieve all profiles on the server (paginated)
-
Optional Query Parameters:
- page: page to return
- size: number of authors per page
-
Example Response:
"type": "authors",
"page": 1
"size": 2
"items":[
{
"type":"author",
"id":"http://127.0.0.1:5454/authors/1d698d25ff008f7538453c120f581471",
"url":"http://127.0.0.1:5454/authors/1d698d25ff008f7538453c120f581471",
"host":"http://127.0.0.1:5454/",
"displayName":"Greg Johnson",
"github": "http://github.com/gjohnson",
"profileImage": "https://i.imgur.com/k7XVwpB.jpeg"
},
{
"type":"author",
"id":"http://127.0.0.1:5454/authors/9de17f29c12e8f97bcbbd34cc908f1baba40658e",
"host":"http://127.0.0.1:5454/",
"displayName":"Lara Croft",
"url":"http://127.0.0.1:5454/authors/9de17f29c12e8f97bcbbd34cc908f1baba40658e",
"github": "http://github.com/laracroft",
"profileImage": "https://i.imgur.com/k7XVwpB.jpeg"
}
]
}
-
URL: /authors/{AUTHOR_ID}
-
GET [local]: retrieve AUTHOR_ID’s profile
-
Example Response:
{
"type":"author",
"id":"http://127.0.0.1:5454/authors/9de17f29c12e8f97bcbbd34cc908f1baba40658e",
"host":"http://127.0.0.1:5454/",
"displayName":"Lara Croft",
"url":"http://127.0.0.1:5454/authors/9de17f29c12e8f97bcbbd34cc908f1baba40658e",
"github": "http://github.com/laracroft",
"profileImage": "https://i.imgur.com/k7XVwpB.jpeg"
}
- POST: Update the author’s profile. Expects to receive a JSON-formatted author profile.
- URL: /authors/{AUTHOR_ID}/posts/
- GET [local]: get the recent posts from author AUTHOR_ID (paginated)
- Optional Query Parameters:
- page: page to return
- size: number of authors per page
- Example Response:
200 OK
{
"type": "posts",
"items": [
{
"id": "9bc1eb3b-33cf-4cdf-b71f-bc7810148698",
"type": "post",
"title": "First Post",
"source": "http://127.0.0.1:8000/posts/9bc1eb3b-33cf-4cdf-b71f-bc7810148698",
"origin": "http://127.0.0.1:8000/posts/9bc1eb3b-33cf-4cdf-b71f-bc7810148698",
"description": "Desc of First",
"contentType": "text/plain",
"content": "Content of First",
"author": {
"type": "author",
"id": "aec4ad5c-103c-4a53-8d3d-f4ab84c9d83b",
"url": "http://127.0.0.1:8000/authors/aec4ad5c-103c-4a53-8d3d-f4ab84c9d83b",
"host": "http://127.0.0.1:8000/",
"displayName": "sanjeev-kotha",
"github": null,
"profileImage": null
},
"categories": [
"Test"
],
"comments": "http://127.0.0.1:8000/authors/aec4ad5c-103c-4a53-8d3d-f4ab84c9d83b/posts/9bc1eb3b-33cf-4cdf-b71f-bc7810148698/comments",
"commentsSrc": {
"type": "comments",
"post": "9bc1eb3b-33cf-4cdf-b71f-bc7810148698",
"id": "http://127.0.0.1:8000/authors/aec4ad5c-103c-4a53-8d3d-f4ab84c9d83b/posts/9bc1eb3b-33cf-4cdf-b71f-bc7810148698/comments",
"comments": [
{
"id": "f9b29700-6948-4405-99d0-25c602fa83c6",
"type": "comment",
"comment": "test comment",
"contentType": "text/plain",
"url": "http://127.0.0.1:8000/authors/aec4ad5c-103c-4a53-8d3d-f4ab84c9d83b/posts/9bc1eb3b-33cf-4cdf-b71f-bc7810148698/comments/f9b29700-6948-4405-99d0-25c602fa83c6",
"author": {
"type": "author",
"id": "aec4ad5c-103c-4a53-8d3d-f4ab84c9d83b",
"url": "http://127.0.0.1:8000/authors/aec4ad5c-103c-4a53-8d3d-f4ab84c9d83b",
"host": "http://127.0.0.1:8000/",
"displayName": "sanjeev-kotha",
"github": null,
"profileImage": null
},
"published": "2022-10-27T07:37:01Z"
}
]
},
"published": "2022-10-27T07:35:26Z",
"visibility": "PUBLIC",
"unlisted": false,
"url": "http://127.0.0.1:8000/authors/aec4ad5c-103c-4a53-8d3d-f4ab84c9d83b/posts/9bc1eb3b-33cf-4cdf-b71f-bc7810148698"
}
]
}
- POST [local]: create a new post but generate a new id (authenticated)
- Example Request:
{
"type": "post",
"title": "First post",
"description": "This is the first post",
"contentType": "text/plain",
"content": "This is the first post content",
"categories": ["web", "tutorial"],
"visibility":"PUBLIC",
"unlisted":false
}
- Example Response:
201 Created
{
"id": "151e4db1-a9bd-413a-aed2-c687e2a79f25",
"type": "post",
"title": "First post",
"source": "http://127.0.0.1:8000/posts/151e4db1-a9bd-413a-aed2-c687e2a79f25",
"origin": "http://127.0.0.1:8000/posts/151e4db1-a9bd-413a-aed2-c687e2a79f25",
"description": "This is the first post",
"contentType": "text/plain",
"content": "This is the first post content",
"author": {
"type": "author",
"id": "aec4ad5c-103c-4a53-8d3d-f4ab84c9d83b",
"url": "http://127.0.0.1:8000/authors/aec4ad5c-103c-4a53-8d3d-f4ab84c9d83b",
"host": "http://127.0.0.1:8000/",
"displayName": "sanjeev-kotha",
"github": null,
"profileImage": null
},
"categories": [
"web",
"tutorial"
],
"comments": "http://127.0.0.1:8000/authors/aec4ad5c-103c-4a53-8d3d-f4ab84c9d83b/posts/151e4db1-a9bd-413a-aed2-c687e2a79f25/comments",
"commentsSrc": {
"type": "comments",
"post": "151e4db1-a9bd-413a-aed2-c687e2a79f25",
"id": "http://127.0.0.1:8000/authors/aec4ad5c-103c-4a53-8d3d-f4ab84c9d83b/posts/151e4db1-a9bd-413a-aed2-c687e2a79f25/comments",
"comments": []
},
"published": "2022-10-28T07:23:00.055846Z",
"visibility": "PUBLIC",
"unlisted": false,
"url": "http://127.0.0.1:8000/authors/aec4ad5c-103c-4a53-8d3d-f4ab84c9d83b/posts/151e4db1-a9bd-413a-aed2-c687e2a79f25"
}
- URL: /authors/{AUTHOR_ID}/posts/{POST_ID}/
- GET [local]: get the post whose id is POST_ID
- Example Response:
200 OK
{
"id": "9bc1eb3b-33cf-4cdf-b71f-bc7810148698",
"type": "post",
"title": "First Post",
"source": "http://127.0.0.1:8000/posts/9bc1eb3b-33cf-4cdf-b71f-bc7810148698",
"origin": "http://127.0.0.1:8000/posts/9bc1eb3b-33cf-4cdf-b71f-bc7810148698",
"description": "Desc of First",
"contentType": "text/plain",
"content": "Content of First",
"author": {
"type": "author",
"id": "aec4ad5c-103c-4a53-8d3d-f4ab84c9d83b",
"url": "http://127.0.0.1:8000/authors/aec4ad5c-103c-4a53-8d3d-f4ab84c9d83b",
"host": "http://127.0.0.1:8000/",
"displayName": "sanjeev-kotha",
"github": null,
"profileImage": null
},
"categories": [
"Test"
],
"comments": "http://127.0.0.1:8000/authors/aec4ad5c-103c-4a53-8d3d-f4ab84c9d83b/posts/9bc1eb3b-33cf-4cdf-b71f-bc7810148698/comments",
"commentsSrc": {
"type": "comments",
"post": "9bc1eb3b-33cf-4cdf-b71f-bc7810148698",
"id": "http://127.0.0.1:8000/authors/aec4ad5c-103c-4a53-8d3d-f4ab84c9d83b/posts/9bc1eb3b-33cf-4cdf-b71f-bc7810148698/comments",
"comments": [
{
"id": "f9b29700-6948-4405-99d0-25c602fa83c6",
"type": "comment",
"comment": "test comment",
"contentType": "text/plain",
"url": "http://127.0.0.1:8000/authors/aec4ad5c-103c-4a53-8d3d-f4ab84c9d83b/posts/9bc1eb3b-33cf-4cdf-b71f-bc7810148698/comments/f9b29700-6948-4405-99d0-25c602fa83c6",
"author": {
"type": "author",
"id": "aec4ad5c-103c-4a53-8d3d-f4ab84c9d83b",
"url": "http://127.0.0.1:8000/authors/aec4ad5c-103c-4a53-8d3d-f4ab84c9d83b",
"host": "http://127.0.0.1:8000/",
"displayName": "sanjeev-kotha",
"github": null,
"profileImage": null
},
"published": "2022-10-27T07:37:01Z"
}
]
},
"published": "2022-10-27T07:35:26Z",
"visibility": "PUBLIC",
"unlisted": false,
"url": "http://127.0.0.1:8000/authors/aec4ad5c-103c-4a53-8d3d-f4ab84c9d83b/posts/9bc1eb3b-33cf-4cdf-b71f-bc7810148698"
}
- POST [local]: update the post whose id is POST_ID (authenticated)
- Example Request:
{
"description": "Updated",
"categories": ["Hi"]
}
- Example Response:
201 Created
{
"id": "151e4db1-a9bd-413a-aed2-c687e2a79f25",
"type": "post",
"title": "First post",
"source": "http://127.0.0.1:8000/posts/151e4db1-a9bd-413a-aed2-c687e2a79f25",
"origin": "http://127.0.0.1:8000/posts/151e4db1-a9bd-413a-aed2-c687e2a79f25",
"description": "Updated",
"contentType": "text/plain",
"content": "This is the first post content",
"author": {
"type": "author",
"id": "aec4ad5c-103c-4a53-8d3d-f4ab84c9d83b",
"url": "http://127.0.0.1:8000/authors/aec4ad5c-103c-4a53-8d3d-f4ab84c9d83b",
"host": "http://127.0.0.1:8000/",
"displayName": "sanjeev-kotha",
"github": null,
"profileImage": null
},
"categories": [
"Hi"
],
"comments": "http://127.0.0.1:8000/authors/aec4ad5c-103c-4a53-8d3d-f4ab84c9d83b/posts/151e4db1-a9bd-413a-aed2-c687e2a79f25/comments",
"commentsSrc": {
"type": "comments",
"post": "151e4db1-a9bd-413a-aed2-c687e2a79f25",
"id": "http://127.0.0.1:8000/authors/aec4ad5c-103c-4a53-8d3d-f4ab84c9d83b/posts/151e4db1-a9bd-413a-aed2-c687e2a79f25/comments",
"comments": []
},
"published": "2022-10-28T07:23:00.055846Z",
"visibility": "PUBLIC",
"unlisted": false,
"url": "http://127.0.0.1:8000/authors/aec4ad5c-103c-4a53-8d3d-f4ab84c9d83b/posts/151e4db1-a9bd-413a-aed2-c687e2a79f25"
}
- DELETE [local]: remove the post whose id is POST_ID (authenticated)
- Example Response
200 OK
"Deleted Successfully"
- PUT [local]: create a post where its id is POST_ID (authenticated)
- Example Request
{
"type": "post",
"title": "Second post",
"description": "This is the second post",
"contentType": "text/plain",
"content": "This is the second post content",
"categories": ["web", "tutorial"],
"visibility":"PUBLIC",
"unlisted":false
}
- Example Response
201 Created
{
"id": "151e4eb1-a9bd-423a-aed2-c687e2a79f25",
"type": "post",
"title": "Second post",
"source": "http://127.0.0.1:8000/posts/151e4eb1-a9bd-423a-aed2-c687e2a79f25",
"origin": "http://127.0.0.1:8000/posts/151e4eb1-a9bd-423a-aed2-c687e2a79f25",
"description": "This is the second post",
"contentType": "text/plain",
"content": "This is the second post content",
"author": {
"type": "author",
"id": "aec4ad5c-103c-4a53-8d3d-f4ab84c9d83b",
"url": "http://127.0.0.1:8000/authors/aec4ad5c-103c-4a53-8d3d-f4ab84c9d83b",
"host": "http://127.0.0.1:8000/",
"displayName": "sanjeev-kotha",
"github": null,
"profileImage": null
},
"categories": [
"web",
"tutorial"
],
"comments": "http://127.0.0.1:8000/authors/aec4ad5c-103c-4a53-8d3d-f4ab84c9d83b/posts/151e4eb1-a9bd-423a-aed2-c687e2a79f25/comments",
"commentsSrc": {
"type": "comments",
"post": "151e4eb1-a9bd-423a-aed2-c687e2a79f25",
"id": "http://127.0.0.1:8000/authors/aec4ad5c-103c-4a53-8d3d-f4ab84c9d83b/posts/151e4eb1-a9bd-423a-aed2-c687e2a79f25/comments",
"comments": []
},
"published": "2022-10-28T08:04:36.934502Z",
"visibility": "PUBLIC",
"unlisted": false,
"url": "http://127.0.0.1:8000/authors/aec4ad5c-103c-4a53-8d3d-f4ab84c9d83b/posts/151e4eb1-a9bd-423a-aed2-c687e2a79f25"
}
- URL: /authors/{AUTHOR_ID}/posts/{POST_ID}/
- GET [local]: get the list of comments of the post whose id is POST_ID (paginated)
- Example Response: '''test''''
- **POST:**add comment to the post with POST_ID
- URL: /authors/{AUTHOR_ID}/posts/{POST_ID}/likes
- GET [local]: retrieve a list of likes from other authors on AUTHOR_ID’s post POST_ID
- Example Response: '''test''''
- URL: /authors/{AUTHOR_ID}/posts/{POST_ID}/comments/{COMMENT_ID}/likes
- GET [local]: retrieve a list of likes from other authors on AUTHOR_ID’s post-POST_ID's comment-COMMENT_ID
- Example Response: '''test''''
- **POST:**add comment to the post with POST_ID