-
Notifications
You must be signed in to change notification settings - Fork 2
Backend Endpoints
marzookh 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}/comments
- GET [local]: get the list of comments of the post whose id is POST_ID (paginated)
- Example Response:
200 OK
{
"type": "comments",
"page": 1,
"size": 1,
"post": "http://127.0.0.1:8000/authors/aec4ad5c-103c-4a53-8d3d-f4ab84c9d83b/posts/9bc1eb3b-33cf-4cdf-b71f-bc7810148698",
"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"
}
]
}
- POST: add a comment to the post with POST_ID
- Example Request:
{
"type": "comment",
"comment": "Test comment",
"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
},
"contentType": "text/plain"
}
- Example Response:
201 Created
{
"id": "25c49455-41d0-4e4c-a959-87aaca58eed3",
"type": "comment",
"comment": "Test comment",
"contentType": "text/plain",
"url": "http://127.0.0.1:8000/authors/e9ddddea-464c-4b91-9ff7-fda54c69125d/posts/8e384737-d5af-4836-90f8-fda9a04df59f/comments/25c49455-41d0-4e4c-a959-87aaca58eed3",
"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-28T08:16:09.766276Z"
}
- 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 a comment to the post with POST_ID
- URL: /authors/{AUTHOR_ID}/followers
- GET [local]: get a list of authors who are AUTHOR_ID’s followers
- Example Response:
{
"type": "followers",
"items": [
{
"type": "author",
"id": "8306e579-e97e-4ea9-b2df-369eac2cc8cc",
"url": "http://127.0.0.1:5454/authors/8306e579-e97e-4ea9-b2df-369eac2cc8cc",
"host": http://127.0.0.1:5454/,
"displayName": "TestAuthor3",
"github": "http://test3github.com/",
"profileImage": "https://i.imgur.com/k7XVwpB.jpeg"
}
]
-
URL: /authors/{AUTHOR_ID}/followers/{FOREIGN_AUTHOR_ID}
-
GET: [local]: check if FOREIGN_AUTHOR_ID is a follower of AUTHOR_ID*
-
Example Response:
{
"type": "follower",
"id": "8306e579-e97e-4ea9-b2df-369eac2cc8cc",
"url": "http://127.0.0.1:5454/authors/8306e579-e97e-4ea9-b2df-369eac2cc8cc",
"host": http://127.0.0.1:5454/,
"displayName": "TestAuthor3",
"github": "http://test3github.com/",
"profileImage": "https://i.imgur.com/k7XVwpB.jpeg"
}
- PUT: Add FOREIGN_AUTHOR_ID as a follower of AUTHOR_ID (authenticated)
- Example Response:
{
"type": "follower",
"detail": "Foreign author TestAuthor3 is now following the author TestAuthor1."
}
- DELETE: Remove FOREIGN_AUTHOR_ID as a follower of AUTHOR_ID
- Example Response:
{
"type": "follower",
"detail": "Foreign author TestAuthor3 is no longer following the author TestAuthor1."
}
- Example Request:
{
"type": "Follow",
"summary":"Greg wants to follow Lara",
"actor":{
"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"
},
"object":{
"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}/inbox
- GET: [local]: if authenticated get a list of posts sent to AUTHOR_ID (paginated)
- Example Response:
{
"type":"inbox",
"author":"http://127.0.0.1:5454/authors/c1e3db8ccea4541a0f3d7e5c75feb3fb",
"items":[
{
"type":"post",
"title":"A Friendly post title about a post about web dev",
"id":"http://127.0.0.1:5454/authors/9de17f29c12e8f97bcbbd34cc908f1baba40658e/posts/764efa883dda1e11db47671c4a3bbd9e"
"source":"http://lastplaceigotthisfrom.com/posts/yyyyy",
"origin":"http://whereitcamefrom.com/posts/zzzzz",
"description":"This post discusses stuff -- brief",
"contentType":"text/plain",
"content":"example content",
"author":{
"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"
},
"categories":["web","tutorial"],
"comments":"http://127.0.0.1:5454/authors/9de17f29c12e8f97bcbbd34cc908f1baba40658e/posts/de305d54-75b4-431b-adb2-eb6b9e546013/comments"
"published":"2015-03-09T13:07:04+00:00",
"visibility":"FRIENDS",
"unlisted":false
},
{
"type":"post",
"title":"DID YOU READ MY POST YET?",
"id":"http://127.0.0.1:5454/authors/9de17f29c12e8f97bcbbd34cc908f1baba40658e/posts/999999983dda1e11db47671c4a3bbd9e",
"source":"http://lastplaceigotthisfrom.com/posts/yyyyy",
"origin":"http://whereitcamefrom.com/posts/zzzzz",
"description":"Whatever",
"contentType":"text/plain",
"content":"Are you even reading my posts Arjun?",
"author":{
"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"
},
"categories":["web","tutorial"],
"comments":"http://127.0.0.1:5454/authors/9de17f29c12e8f97bcbbd34cc908f1baba40658e/posts/de305d54-75b4-431b-adb2-eb6b9e546013/comments"
"published":"2015-03-09T13:07:04+00:00",
"visibility":"FRIENDS",
"unlisted":false
}
]
}
- POST: [local]: send a post to the author
- DELETE: clear the inbox
- URL: /register
- Example Response:
{
"username": [
"A user with that username already exists."
],
"password": [
"This password is too common."
]
}
- URL: /login
- Example Response:
{
"detail": "Your username and password didn't match. Please try again."
}
- URL: /logout
- Example Response:
{"detail": "You have logged out successfully! Sad to see you go..."}