forked from abramhindle/CMPUT404-project-socialdistribution
-
Notifications
You must be signed in to change notification settings - Fork 3
Objects
Sean Meyers edited this page Feb 11, 2023
·
1 revision
- HTTP Methods not explicitly listed are not allowed methods
- Most HTTP methods are local only, and provided for local node use.
- URL: ://service/authors/
- GET [local, remote]: retrieve all profiles on the server (paginated)
- page: how many pages
- size: how big is a page
- GET [local, remote]: retrieve all profiles on the server (paginated)
- Example query: GET ://service/authors?page=10&size=5
- Gets the 5 authors, authors 45 to 49.
- Example: GET ://service/authors/
{ "type": "authors", "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: ://service/authors/{AUTHOR_ID}/
- GET [local, remote]: retrieve AUTHOR_ID’s profile
- POST [local]: update AUTHOR_ID’s profile
- Example Format:
{ "type":"author", # ID of the Author "id":"http://127.0.0.1:5454/authors/9de17f29c12e8f97bcbbd34cc908f1baba40658e", # the home host of the author "host":"http://127.0.0.1:5454/", # the display name of the author "displayName":"Lara Croft", # url to the authors profile "url":"http://127.0.0.1:5454/authors/9de17f29c12e8f97bcbbd34cc908f1baba40658e", # HATEOS url for Github API "github": "http://github.com/laracroft", # Image from a public domain "profileImage": "https://i.imgur.com/k7XVwpB.jpeg" }
- URL: ://service/authors/{AUTHOR_ID}/followers
- GET [local, remote]: get a list of authors who are AUTHOR_ID’s followers
- URL: ://service/authors/{AUTHOR_ID}/followers/{FOREIGN_AUTHOR_ID}
- DELETE [local]: remove FOREIGN_AUTHOR_ID as a follower of AUTHOR_ID
- PUT [local]: Add FOREIGN_AUTHOR_ID as a follower of AUTHOR_ID (must be authenticated)
- GET [local, remote] check if FOREIGN_AUTHOR_ID is a follower of AUTHOR_ID
- Example: GET ://service/authors/{AUTHOR_ID}/followers
{ "type": "followers", "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" } ] }
- This allows you to follow someone you, so they can send you their post.
- If the recipient accepts the Friend Request then you are friends
- If the recipient folows you, you are true friends
- Sent to inbox of “object”
- Example format:
{ "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 of the Author "id":"http://127.0.0.1:5454/authors/9de17f29c12e8f97bcbbd34cc908f1baba40658e", # the home host of the author "host":"http://127.0.0.1:5454/", # the display name of the author "displayName":"Lara Croft", # url to the authors profile "url":"http://127.0.0.1:5454/authors/9de17f29c12e8f97bcbbd34cc908f1baba40658e", # HATEOS url for Github API "github": "http://github.com/laracroft", # Image from a public domain "profileImage": "https://i.imgur.com/k7XVwpB.jpeg" } }
- URL: ://service/authors/{AUTHOR_ID}/posts/{POST_ID}
- GET [local, remote] get the public post whose id is POST_ID
- POST [local] update the post whose id is POST_ID (must be authenticated)
- DELETE [local] remove the post whose id is POST_ID
- PUT [local] create a post where its id is POST_ID
- Creation URL ://service/authors/{AUTHOR_ID}/posts/
- GET [local, remote] get the recent posts from author AUTHOR_ID (paginated)
- POST [local] create a new post but generate a new id
- Be aware that Posts can be images that need base64 decoding.
- posts can also hyperlink to images that are public
- Example Format:
{ "type":"post", # title of a post "title":"A post title about a post about web dev", # id of the post "id":"http://127.0.0.1:5454/authors/9de17f29c12e8f97bcbbd34cc908f1baba40658e/posts/764efa883dda1e11db47671c4a3bbd9e" # where did you get this post from? "source":"http://lastplaceigotthisfrom.com/posts/yyyyy", # where is it actually from "origin":"http://whereitcamefrom.com/posts/zzzzz", # a brief description of the post "description":"This post discusses stuff -- brief", # The content type of the post # assume either # text/markdown -- common mark # text/plain -- UTF-8 # application/base64 # image/png;base64 # this is an embedded png -- images are POSTS. So you might have a user make 2 posts if a post includes an image! # image/jpeg;base64 # this is an embedded jpeg # for HTML you will want to strip tags before displaying "contentType":"text/plain", "content":"Þā wæs on burgum Bēowulf Scyldinga, lēof lēod-cyning, longe þrāge folcum gefrǣge (fæder ellor hwearf, aldor of earde), oð þæt him eft onwōc hēah Healfdene; hēold þenden lifde, gamol and gūð-rēow, glæde Scyldingas. Þǣm fēower bearn forð-gerīmed in worold wōcun, weoroda rǣswan, Heorogār and Hrōðgār and Hālga til; hȳrde ic, þat Elan cwēn Ongenþēowes wæs Heaðoscilfinges heals-gebedde. Þā wæs Hrōðgāre here-spēd gyfen, wīges weorð-mynd, þæt him his wine-māgas georne hȳrdon, oð þæt sēo geogoð gewēox, mago-driht micel. Him on mōd bearn, þæt heal-reced hātan wolde, medo-ærn micel men gewyrcean, þone yldo bearn ǣfre gefrūnon, and þǣr on innan eall gedǣlan geongum and ealdum, swylc him god sealde, būton folc-scare and feorum gumena. Þā ic wīde gefrægn weorc gebannan manigre mǣgðe geond þisne middan-geard, folc-stede frætwan. Him on fyrste gelomp ǣdre mid yldum, þæt hit wearð eal gearo, heal-ærna mǣst; scōp him Heort naman, sē þe his wordes geweald wīde hæfde. Hē bēot ne ālēh, bēagas dǣlde, sinc æt symle. Sele hlīfade hēah and horn-gēap: heaðo-wylma bād, lāðan līges; ne wæs hit lenge þā gēn þæt se ecg-hete āðum-swerian 85 æfter wæl-nīðe wæcnan scolde. Þā se ellen-gǣst earfoðlīce þrāge geþolode, sē þe in þȳstrum bād, þæt hē dōgora gehwām drēam gehȳrde hlūdne in healle; þǣr wæs hearpan swēg, swutol sang scopes. Sægde sē þe cūðe frum-sceaft fīra feorran reccan", # the author has an ID where by authors can be disambiguated "author":{ "type":"author", # ID of the Author "id":"http://127.0.0.1:5454/authors/9de17f29c12e8f97bcbbd34cc908f1baba40658e", # the home host of the author "host":"http://127.0.0.1:5454/", # the display name of the author "displayName":"Lara Croft", # url to the authors profile "url":"http://127.0.0.1:5454/authors/9de17f29c12e8f97bcbbd34cc908f1baba40658e", # HATEOS url for Github API "github": "http://github.com/laracroft", # Image from a public domain (optional, can be missing) "profileImage": "https://i.imgur.com/k7XVwpB.jpeg" }, # categories this post fits into (a list of strings "categories":["web","tutorial"], # comments about the post # return a maximum number of comments # total number of comments for this post "count": 1023, # the first page of comments "comments":"http://127.0.0.1:5454/authors/9de17f29c12e8f97bcbbd34cc908f1baba40658e/posts/de305d54-75b4-431b-adb2-eb6b9e546013/comments" # commentsSrc is OPTIONAL and can be missing # You should return ~ 5 comments per post. # should be sorted newest(first) to oldest(last) # this is to reduce API call counts "commentsSrc":{ "type":"comments", "page":1, "size":5, "post":"http://127.0.0.1:5454/authors/9de17f29c12e8f97bcbbd34cc908f1baba40658e/posts/764efa883dda1e11db47671c4a3bbd9e" "id":"http://127.0.0.1:5454/authors/9de17f29c12e8f97bcbbd34cc908f1baba40658e/posts/de305d54-75b4-431b-adb2-eb6b9e546013/comments" "comments":[ { "type":"comment", "author":{ "type":"author", # ID of the Author (UUID) "id":"http://127.0.0.1:5454/authors/1d698d25ff008f7538453c120f581471", # url to the authors information "url":"http://127.0.0.1:5454/authors/1d698d25ff008f7538453c120f581471", "host":"http://127.0.0.1:5454/", "displayName":"Greg Johnson", # HATEOS url for Github API "github": "http://github.com/gjohnson", # Image from a public domain "profileImage": "https://i.imgur.com/k7XVwpB.jpeg" }, "comment":"Sick Olde English", "contentType":"text/markdown", # ISO 8601 TIMESTAMP "published":"2015-03-09T13:07:04+00:00", # ID of the Comment (UUID) "id":"http://127.0.0.1:5454/authors/9de17f29c12e8f97bcbbd34cc908f1baba40658e/posts/de305d54-75b4-431b-adb2-eb6b9e546013/comments/f6255bb01c648fe967714d52a89e8e9c", } ] } # ISO 8601 TIMESTAMP "published":"2015-03-09T13:07:04+00:00", # visibility ["PUBLIC","FRIENDS"] "visibility":"PUBLIC", # for visibility PUBLIC means it is open to the wild web # FRIENDS means if we're direct friends I can see the post # FRIENDS should've already been sent the post so they don't need this "unlisted":false # unlisted means it is public if you know the post name -- use this for images, it's so images don't show up in timelines }
Image Posts are just posts that are images. But they are encoded as base64 data. You can inline an image post using a data url or you can use this shortcut to get the image if authenticated to see it.
- URL: ://service/authors/{AUTHOR_ID}/posts/{POST_ID}/image
- GET [local, remote] get the public post converted to binary as an iamge
- return 404 if not an image
- GET [local, remote] get the public post converted to binary as an iamge
- This end point decodes image posts as images. This allows the use of image tags in markdown.
- You can use this to proxy or cache images.
- URL: ://service/authors/{AUTHOR_ID}/posts/{POST_ID}/comments
- GET [local, remote] get the list of comments of the post whose id is POST_ID (paginated)
- POST [local] if you post an object of “type”:”comment”, it will add your comment to the post whose id is POST_ID
- example comment from ://service/authors/{AUTHOR_ID}/posts/{POST_ID}/comments
{ "type":"comment", "author":{ "type":"author", # ID of the Author (UUID) "id":"http://127.0.0.1:5454/authors/1d698d25ff008f7538453c120f581471", # url to the authors information "url":"http://127.0.0.1:5454/authors/1d698d25ff008f7538453c120f581471", "host":"http://127.0.0.1:5454/", "displayName":"Greg Johnson", # HATEOS url for Github API "github": "http://github.com/gjohnson", # Image from a public domain "profileImage": "https://i.imgur.com/k7XVwpB.jpeg" } "comment":"Sick Olde English", "contentType":"text/markdown", # ISO 8601 TIMESTAMP "published":"2015-03-09T13:07:04+00:00", # ID of the Comment (UUID) "id":"http://127.0.0.1:5454/authors/9de17f29c12e8f97bcbbd34cc908f1baba40658e/posts/de305d54-75b4-431b-adb2-eb6b9e546013/comments/f6255bb01c648fe967714d52a89e8e9c", } - example comments from a post
{ "type":"comments", "page":1, "size":5, "post":"http://127.0.0.1:5454/authors/9de17f29c12e8f97bcbbd34cc908f1baba40658e/posts/764efa883dda1e11db47671c4a3bbd9e" "id":"http://127.0.0.1:5454/authors/9de17f29c12e8f97bcbbd34cc908f1baba40658e/posts/de305d54-75b4-431b-adb2-eb6b9e546013/comments" "comments":[ { "type":"comment", "author":{ "type":"author", # ID of the Author (UUID) "id":"http://127.0.0.1:5454/authors/1d698d25ff008f7538453c120f581471", # url to the authors information "url":"http://127.0.0.1:5454/authors/1d698d25ff008f7538453c120f581471", "host":"http://127.0.0.1:5454/", "displayName":"Greg Johnson", # HATEOS url for Github API "github": "http://github.com/gjohnson", # Image from a public domain "profileImage": "https://i.imgur.com/k7XVwpB.jpeg" }, "comment":"Sick Olde English", "contentType":"text/markdown", # ISO 8601 TIMESTAMP "published":"2015-03-09T13:07:04+00:00", # ID of the Comment (UUID) "id":"http://127.0.0.1:5454/authors/9de17f29c12e8f97bcbbd34cc908f1baba40658e/posts/de305d54-75b4-431b-adb2-eb6b9e546013/comments/f6255bb01c648fe967714d52a89e8e9c", } ] }
- You can like posts and comments
- Send them to the inbox of the author of the post or comment
- URL: ://service/authors/{AUTHOR_ID}/inbox/
- POST [local, remote]: send a like object to AUTHOR_ID
- URL: ://service/authors/{AUTHOR_ID}/posts/{POST_ID}/likes
- GET [local, remote] a list of likes from other authors on AUTHOR_ID’s post POST_ID
- URL: ://service/authors/{AUTHOR_ID}/posts/{POST_ID}/comments/{COMMENT_ID}/likes
- GET [local, remote] a list of likes from other authors on AUTHOR_ID’s post POST_ID comment COMMENT_ID
- Example like object:
{ "@context": "https://www.w3.org/ns/activitystreams", "summary": "Lara Croft Likes your post", "type": "Like", "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" }, "object":"http://127.0.0.1:5454/authors/9de17f29c12e8f97bcbbd34cc908f1baba40658e/posts/764efa883dda1e11db47671c4a3bbd9e" }
- URL: ://service/authors/{AUTHOR_ID}/liked
- GET [local, remote] list what public things AUTHOR_ID liked.
- It’s a list of of likes originating from this author
- Note: be careful here private information could be disclosed.
- GET [local, remote] list what public things AUTHOR_ID liked.
- Example liked object:
{ "type":"liked", "items":[ { "@context": "https://www.w3.org/ns/activitystreams", "summary": "Lara Croft Likes your post", "type": "Like", "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" }, "object":"http://127.0.0.1:5454/authors/9de17f29c12e8f97bcbbd34cc908f1baba40658e/posts/764efa883dda1e11db47671c4a3bbd9e" } ] }
- The inbox is all the new posts from who you follow
- URL: ://service/authors/{AUTHOR_ID}/inbox
- GET [local]: if authenticated get a list of posts sent to AUTHOR_ID (paginated)
- POST [local, remote]: send a post to the author
- if the type is “post” then add that post to AUTHOR_ID’s inbox
- if the type is “follow” then add that follow is added to AUTHOR_ID’s inbox to approve later
- if the type is “like” then add that like to AUTHOR_ID’s inbox
- if the type is “comment” then add that comment to AUTHOR_ID’s inbox
- DELETE [local]: clear the inbox
- Example, retrieving an inbox
{ "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":"Þā wæs on burgum Bēowulf Scyldinga, lēof lēod-cyning, longe þrāge folcum gefrǣge (fæder ellor hwearf, aldor of earde), oð þæt him eft onwōc hēah Healfdene; hēold þenden lifde, gamol and gūð-rēow, glæde Scyldingas. Þǣm fēower bearn forð-gerīmed in worold wōcun, weoroda rǣswan, Heorogār and Hrōðgār and Hālga til; hȳrde ic, þat Elan cwēn Ongenþēowes wæs Heaðoscilfinges heals-gebedde. Þā wæs Hrōðgāre here-spēd gyfen, wīges weorð-mynd, þæt him his wine-māgas georne hȳrdon, oð þæt sēo geogoð gewēox, mago-driht micel. Him on mōd bearn, þæt heal-reced hātan wolde, medo-ærn micel men gewyrcean, þone yldo bearn ǣfre gefrūnon, and þǣr on innan eall gedǣlan geongum and ealdum, swylc him god sealde, būton folc-scare and feorum gumena. Þā ic wīde gefrægn weorc gebannan manigre mǣgðe geond þisne middan-geard, folc-stede frætwan. Him on fyrste gelomp ǣdre mid yldum, þæt hit wearð eal gearo, heal-ærna mǣst; scōp him Heort naman, sē þe his wordes geweald wīde hæfde. Hē bēot ne ālēh, bēagas dǣlde, sinc æt symle. Sele hlīfade hēah and horn-gēap: heaðo-wylma bād, lāðan līges; ne wæs hit lenge þā gēn þæt se ecg-hete āðum-swerian 85 æfter wæl-nīðe wæcnan scolde. Þā se ellen-gǣst earfoðlīce þrāge geþolode, sē þe in þȳstrum bād, þæt hē dōgora gehwām drēam gehȳrde hlūdne in healle; þǣr wæs hearpan swēg, swutol sang scopes. Sægde sē þe cūðe frum-sceaft fīra feorran reccan", "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 } ] }