Skip to content
This repository was archived by the owner on Apr 10, 2021. It is now read-only.

Endpoints Documentation

ColeBoytinck edited this page Mar 27, 2020 · 18 revisions

NOTICE: These API endpoints are also used by our front end system. In order to ensure you receive our API responses and not redirects to log into our HTML webpages, you should pass the "Accept: application/json" header in your request.

http://service/author/str:author_id/ retrieve author's profile

  • request method: GET
  • url parameter: author_id: UUID
  • example response:
{
  "id":"http://service/author/9de17f29c12e8f97bcbbd34cc908f1baba40658e",
  "host":"http://127.0.0.1:5454/",
  "displayName":"Lara",
  "url":"http://127.0.0.1:5454/author/9de17f29c12e8f97bcbbd34cc908f1baba40658e",
  "friends": [
    {
      "id":"http://127.0.0.1:5454/author/8d919f29c12e8f97bcbbd34cc908f19ab9496989",
      "host":"http://127.0.0.1:5454/",
      "displayName":"Greg",
      "url": "http://127.0.0.1:5454/author/8d919f29c12e8f97bcbbd34cc908f19ab9496989"
    }
  ],

  # Optional attributes
  "github": "http://github.com/lara",
  "firstName": "Lara",
  "lastName": "Smith",
  "email": "lara@lara.com",
  "bio": "Hi, I'm Lara"
} 
  • response status code:
  • 404: author not found
  • 405: request methods not allowed
  • 200: success retrieval of author information

http://service/author/ retrieve all authors registered on the server

  • request method: GET
  • example response:

[
{
"id": "testing-mandala.herokuapp.com/author/ea9c2f9a980d4fe18a2988770417be19",
"host": "testing-mandala.herokuapp.com",
"url": "testing-mandala.herokuapp.com/author/ea9c2f9a980d4fe18a2988770417be19",
"displayName": "dog",
"firstName": "dog",
"lastName": "dog"
},
{
"id": "testing-mandala.herokuapp.com/author/562d7e0c594d4a44b2aa3e53d7cb84bb",
"host": "testing-mandala.herokuapp.com",
"url": "testing-mandala.herokuapp.com/author/562d7e0c594d4a44b2aa3e53d7cb84bb",
"displayName": "cat",
"firstName": "cat",
"lastName": "cat"
},
{
"id": "testing-mandala.herokuapp.com/author/301e977fc9f04a51aa9f41094526ff68",
"host": "testing-mandala.herokuapp.com",
"url": "testing-mandala.herokuapp.com/author/301e977fc9f04a51aa9f41094526ff68",
"displayName": "ida",
"firstName": "ida",
"lastName": "ida"
}
]
  • response status code:
  • 405: Method not allowed, only GET would work
  • 200: success retrieval of author information

http://service/author/str:author1_id/friends/path:author2_id/ Ask if 2 authors are friends

  • request method: GET
  • url parameter: author1_id: UUID author2_id: full url of author (w/o protocol)
  • example response:
{	"query":"friends",
        # Array of Author UUIDs
        "authors":[
            "http://127.0.0.1:5454/author/de305d54-75b4-431b-adb2-eb6b9e546013",
            "http://127.0.0.1:5454/author/ae345d54-75b4-431b-adb2-fb6b9e547891"
        ],
        # boolean true or false
        "friends": true
}
  • response status code:
  • 405: request methods not allowed
  • 200: succesfully retrieval of friendship information
  • 401: authentication required

http://service/str:author_id/addfriend/ view a list of available authors to befriend

  • request method: GET
  • url parameter: author1_id: UUID
  • example response:
{
    "available_authors_to_befriend": [
        "localhost:8000/author/198238a04a1a409cbb4b52ef373fbd27",
        "127.0.0.1:8000/author/b5154eb3b16740eda96857233b165678",
        "localhost:8000/author/d747a675e1054e5b9fe32c5d1a5d277c",
        "localhost:8000/author/99baa477e25b406696f0f61655716197"
    ]
}
  • response status code: 405: request methods not allowed 404: author record not found 200: succesfully retrieval of available friends information

http://service/author/unfriend unfriend two authors given in request body

  • request method: POST
  • example request body:
{
	"author_id" : "127.0.0.1:8000/author/9d411951f13246728c2a1d00c081e680",
	"friend_id" : "localhost:8000/author/99baa477e25b406696f0f61655716197"
}
  • response status code:
  • 422: request body missing field
  • 405: request methods not allowed
  • 404: trying to remove friendship that does not exist
  • 200: successfully removal of friendship

http://service/author/path:author_id/friends/

  • url parameter: author_id: full url of author
  • request method: POST ask a service if anyone in the list is a friend
  • example request body:
{
	"query":"friends",
	"author":"<full url of author>",
	# Array of Author ids
	"authors": [
	    "http://127.0.0.1:5454/author/de305d54-75b4-431b-adb2-eb6b9e546013",
		"http://127.0.0.1:5454/author/ae345d54-75b4-431b-adb2-fb6b9e547891",
		"...",
		"...",
		"..."
  	]
}
  • example response:
{
	"query":"friends",
 	"author":"<authorid>", # where <authorid> is the full URL of the author in question
 	# Array of Author ids who are friends
	"authors": [
	    "http://127.0.0.1:5454/author/de305d54-75b4-431b-adb2-eb6b9e546013",
		"http://127.0.0.1:5454/author/ae345d54-75b4-431b-adb2-fb6b9e547891",
		"..."
  	]
}
  • request method: GET retrieve a list of friends of current user
  • example response:
{
	"query":"friends",
	# Array of Author UUIDs
	"authors":[
		"http://host3/author/de305d54-75b4-431b-adb2-eb6b9e546013",
		"http://host2/author/ae345d54-75b4-431b-adb2-fb6b9e547891"
	]
}
  • response status code:
  • 200: successful retrieval of information
  • 405: request methods not allowed
  • 422: post body missing entries
  • 401: Authentication required

http://service/friendrequest to make a friend request

  • request method: POST
  • example request body:
{
	"query":"friendrequest",
	"author": {
		"id":"http://127.0.0.1:5454/author/de305d54-75b4-431b-adb2-eb6b9e546013",
		"host":"http://127.0.0.1:5454/",
		"displayName":"Greg Johnson"
                "url":"http://127.0.0.1:5454/author/de305d54-75b4-431b-adb2-eb6b9e546013",
	},
	"friend": {
		"id":"http://127.0.0.1:5454/author/de305d54-75b4-431b-adb2-eb6b9e637281",
		"host":"http://127.0.0.1:5454/",
		"displayName":"Lara Croft",
                "url":"http://127.0.0.1:5454/author/de305d54-75b4-431b-adb2-eb6b9e546013",

	}
}
  • response status code:
  • 422: post body missing entires
  • 200: firendrequest successfully sent
  • 405: request methods not allowed
  • 409: send friend request when two users already friended or already in a follow relationship
  • 401: Authentication required
  • request method: POST to accept a friend request
  • example request body:
{
	"query":"friendrequest",
	"author": {
		"id":"localhost:8000/author/c730cf54a83d4d0982ec13a578692793",
		"host":"http://localhost:8000/",
		"displayName":"Greg Johnson",
        "url":"http://localhost:8000/author/de305d54-75b4-431b-adb2-eb6b9e546013"
	},
	"friend": {
		"id":"localhost:8000/author/ba6cf5db6a164c00a85bd717ec6ada60",
		"host":"http://localhost:8000/",
		"displayName":"Lara Croft",
        "url":"http://localhost:8000/author/de305d54-75b4-431b-adb2-eb6b9e546013"

	}
}

  • request method: DELETE to reject a friend request
  • example request body:
{
	"query":"friendrequest",
	"author": {
		"id":"localhost:8000/author/c730cf54a83d4d0982ec13a578692793",
		"host":"http://localhost:8000/",
		"displayName":"Greg Johnson",
        "url":"http://localhost:8000/author/de305d54-75b4-431b-adb2-eb6b9e546013"
	},
	"friend": {
		"id":"localhost:8000/author/ba6cf5db6a164c00a85bd717ec6ada60",
		"host":"http://localhost:8000/",
		"displayName":"Lara Croft",
        "url":"http://localhost:8000/author/de305d54-75b4-431b-adb2-eb6b9e546013"

	}
}

  • response status code:
  • 405: request methods not allowed
  • 422: request body missing entries
  • 404: handle a friend request that doesn't exist
  • 200: friend request successfully handled

http://service/friendrequest/str:author_id to retrieve pending requests of author

  • request method: GET
  • example response:
{
    "query": "retrieve_friend_requests",
    "author": "127.0.0.1:8000/author/c730cf54a83d4d0982ec13a578692793",
    "request": [
       "http://host3/author/de305d54-75b4-431b-adb2-eb6b9e546013",
       "http://host2/author/ae345d54-75b4-431b-adb2-fb6b9e547891"
      ]
}
  • response status code:
  • 405: request method not allowed
  • 200: successful retrieval of information

http://service/user/login display user login page

  • request method: GET

http://service/user/signup display user signup page

  • request method: POST

http://service/user/logout display user logout page

  • request method: GET

http://service/author/posts retrieve posts that are visible to the currently authenticated user

  • request method: GET
  • If a page is provided, it retreives the posts in that page else returns page 0
  • If a size is provided, retrieves pages as the size, up to the maximum set on the server (50). If no size is provided retrieves the default page size (10)
  • example response:
{
    "query": "posts",
    "count": 11,
    "size": 10,
    "previous": "http://127.0.0.1:8000/author/posts?page=1",
    # Array of posts
    "posts": [
        {
            "id": "2d5e7bd7-4c0f-4da2-8d10-5731028b8e3d",
            "title": "public Post by Test",
            "source": "http://lastplaceigotthisfrom.com/posts/yyyyy",
            "origin": "http://whereitcamefrom.com/posts/zzzzz",
            "description": "post to  test visibility = Public",
            "contentType": "text/markdown",
            "content": "This is a public post by test",
            "author": {
                "id": "127.0.0.1:8000/author/42cc076ae73a46c58d0defa51be6751b",
                "email": "test@test.com",
                "bio": "",
                "host": "127.0.0.1:8000",
                "firstName": "test",
                "lastName": "testln",
                "displayName": "",
                "url": "127.0.0.1:8000/author/42cc076ae73a46c58d0defa51be6751b",
                "github": ""
            },
            "categories": [
                "public post"
            ],
            "count": 3,
            "size": 10,
            "next": "http://127.0.0.1:8000/posts/2d5e7bd7-4c0f-4da2-8d10-5731028b8e3d/comments",
            # Array of comments on the post
            "comments": [
                {
                    "id": "9a48eeac-2827-4c77-b729-d8f588414df5",
                    "contentType": "text/markdown",
                    "comment": "comment 6",
                    "published": "2020-03-10T18:09:58.373Z",
                    "author": {
                        "id": "127.0.0.1:8000/author/66e6c59143a948e5b7b7072b6c2d5229",
                        "email": "lara@lara.com",
                        "bio": "Hi, I am lara",
                        "host": "127.0.0.1:8000",
                        "firstName": "Lara",
                        "lastName": "Smith",
                        "displayName": "Greg Johnson",
                        "url": "127.0.0.1:8000/author/66e6c59143a948e5b7b7072b6c2d5229",
                        "github": "http://github.com/gjohnson"
                    }
                },
                {
                    "id": "33ddf889-752f-4cad-be38-258b2332e0de",
                    "contentType": "text/markdown",
                    "comment": "comment 5",
                    "published": "2020-03-10T18:09:49.414Z",
                    "author": {
                        "id": "127.0.0.1:8000/author/42cc076ae73a46c58d0defa51be6751b",
                        "email": "test@test.com",
                        "bio": "",
                        "host": "127.0.0.1:8000",
                        "firstName": "test",
                        "lastName": "testln",
                        "displayName": "",
                        "url": "127.0.0.1:8000/author/42cc076ae73a46c58d0defa51be6751b",
                        "github": ""
                    }
                },
                {
                    "id": "1d566374-b9aa-45a0-b2f1-e5975f26c09a",
                    "contentType": "text/markdown",
                    "comment": "comment 2",
                    "published": "2020-03-10T18:09:27.703Z",
                    "author": {
                        "id": "127.0.0.1:8000/author/42cc076ae73a46c58d0defa51be6751b",
                        "email": "test@test.com",
                        "bio": "",
                        "host": "127.0.0.1:8000",
                        "firstName": "test",
                        "lastName": "testln",
                        "displayName": "",
                        "url": "127.0.0.1:8000/author/42cc076ae73a46c58d0defa51be6751b",
                        "github": ""
                    }
                }
            ],
            "published": "2020-03-10T16:16:17.092Z",
            "visibility": "PUBLIC",
            "visibleTo": [],
            "unlisted": false
        }
    ]
}
  • response status code:
  • 404: author not found
  • 403: You must be logged in to access this Endpoint
  • 200: success retrieval of visible posts

http://service/author/{author_id}/posts retrieves all posts made by {AUTHOR_ID} visible to the currently authenticated user

  • request method: GET
  • url parameter: author_id: UUID
  • If a page is provided, it retreives the posts in that page else returns page 0
  • If a size is provided, retrieves pages as the size, up to the maximum set on the server (50). If no size is provided retrieves the default page size (10)
  • example response:
{
    "query": "posts",
    "count": 1,
    "size": 10,
    "posts": [
        {
            "id": "e0f2ff2d-2103-4e30-93bb-01c18112a235",
            "title": "server Post by Mary",
            "source": "http://lastplaceigotthisfrom.com/posts/yyyyy",
            "origin": "http://whereitcamefrom.com/posts/zzzzz",
            "description": "testing stream",
            "contentType": "text/markdown",
            "content": "this is a server post by mary",
            "author": {
                "id": "127.0.0.1:8000/author/ee1172c76b0d4b4193bc8209249ed01e",
                "email": "mary@mary.com",
                "bio": "",
                "host": "127.0.0.1:8000",
                "firstName": "mary",
                "lastName": "M",
                "displayName": "",
                "url": "127.0.0.1:8000/author/ee1172c76b0d4b4193bc8209249ed01e",
                "github": ""
            },
            "categories": [
                "server post"
            ],
            "count": 0,
            "size": 10,
            "next": "127.0.0.1:8000/posts/e0f2ff2d-2103-4e30-93bb-01c18112a235/comments",
            "comments": [],
            "published": "2020-03-10T16:27:34.072Z",
            "visibility": "SERVERONLY",
            "visibleTo": [],
            "unlisted": false
        }
    ]
}
  • response status code:
  • 404: author not found, User does not exist
  • 403: You must be logged in to access this Endpoint
  • 200: success retrieval of visible posts

http://service/posts Gets all the public posts available stored on the server

  • request method: GET
  • query parameters:
    • size: the number of posts to retrieve on a page
    • page: which page of posts to retrieve
{
    "query": "posts",
    "count": 2,
    "size": 2,
    "posts": [
        {
            "title": "A Post from Mandala",
            "source": "https://cmput404-group-project-mandala.herokuapp.com/posts/08c9fe2b0bc04dd5b5cdf27cc4f5b861",
            "origin": "https://cmput404-group-project-mandala.herokuapp.com/posts/08c9fe2b0bc04dd5b5cdf27cc4f5b861",
            "description": "Posting from Mandala for the first time",
            "contentType": "TYPE_MARKDOWN",
            "content": "Hey everyone? How is it going? What is your *favorite* food?",
            "author": {
                "id": "cmput404-group-project-mandala.herokuapp.com/author/1ab9cf9afb3845ceb34cc6e124231eb6",
                "host": "cmput404-group-project-mandala.herokuapp.com",
                "displayName": "Mandala Joe",
                "url": "cmput404-group-project-mandala.herokuapp.com/author/1ab9cf9afb3845ceb34cc6e124231eb6",
                "github": "https://github.com/AustinGrey"
            },
            "categories": [
                "welcome"
            ],
            "count": 1,
            "size": 352,
            "next": "https://cmput404-group-project-mandala.herokuapp.com/posts/08c9fe2b0bc04dd5b5cdf27cc4f5b861/comments",
            "comments": [
                {
                    "author": {
                        "id": "cmput404-group-project-mandala.herokuapp.com/author/1ab9cf9afb3845ceb34cc6e124231eb6",
                        "host": "cmput404-group-project-mandala.herokuapp.com",
                        "displayName": "Mandala Joe",
                        "url": "cmput404-group-project-mandala.herokuapp.com/author/1ab9cf9afb3845ceb34cc6e124231eb6",
                        "github": "https://github.com/AustinGrey"
                    },
                    "comment": "Commenting on your own posts *in* _markdown_",
                    "contentType": "text/markdown",
                    "published": "2020-03-24T00:01:23.767Z",
                    "id": "00821a1628c741aa9915b9153fb93056"
                }
            ],
            "published": "2020-03-24T00:00:54.301Z",
            "id": "08c9fe2b0bc04dd5b5cdf27cc4f5b861",
            "visibility": "PUBLIC",
            "visibleTo": [],
            "unlisted": false
        },
        {
            "title": "My new science experiment",
            "source": "https://cmput404-group-project-mandala.herokuapp.com/posts/b5f051566c7d42dfaa247cb3cadaa1bc",
            "origin": "https://cmput404-group-project-mandala.herokuapp.com/posts/b5f051566c7d42dfaa247cb3cadaa1bc",
            "description": "Talking about my new science experiment",
            "contentType": "TYPE_PLAIN",
            "content": " Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam ornare elit sem, ut mollis felis porttitor quis. Sed dapibus ullamcorper blandit. Suspendisse tincidunt accumsan libero a interdum. Phasellus arcu turpis, efficitur nec orci eu, condimentum dapibus nisi. Mauris porttitor tristique finibus. Nunc non mi vel sapien tristique interdum. In quis justo id lacus lobortis fermentum vel egestas purus. Quisque tincidunt nibh ex. Etiam non augue aliquet, tincidunt tellus in, convallis arcu. Praesent ullamcorper tortor diam, sit amet lobortis tortor imperdiet quis.\r\n\r\nNulla suscipit sit amet libero in rutrum. Donec sed efficitur tellus, sed pretium urna. Phasellus nisi enim, ultrices ac elementum vel, posuere id risus. In sodales enim non est viverra, finibus viverra erat porttitor. Aenean vulputate, odio vitae bibendum pulvinar, augue turpis hendrerit urna, nec feugiat enim mi in velit. Mauris suscipit, augue sed rhoncus cursus, tortor tortor vehicula leo, sed fringilla libero nisi at enim. Ut sit amet vulputate lectus. Duis convallis quam lectus, hendrerit bibendum dui ultricies in. Aenean condimentum laoreet lectus sit amet imperdiet. Proin eget tempor libero. Sed et est orci. Cras in neque in justo ullamcorper porttitor eleifend suscipit sem. Proin ultricies nec enim eu efficitur. Curabitur vestibulum malesuada massa, sed pulvinar nulla ornare placerat. Donec luctus, nibh sed pretium vulputate, mi arcu pellentesque dolor, eget tempus mauris odio nec libero. Vivamus nec interdum quam, vitae aliquam orci. ",
            "author": {
                "id": "cmput404-group-project-mandala.herokuapp.com/author/e95f822df831464eafc79ab66ab38741",
                "host": "cmput404-group-project-mandala.herokuapp.com",
                "displayName": "Mandala Stacy",
                "url": "cmput404-group-project-mandala.herokuapp.com/author/e95f822df831464eafc79ab66ab38741",
                "github": ""
            },
            "categories": [
                "science"
            ],
            "count": 2,
            "size": 1876,
            "next": "https://cmput404-group-project-mandala.herokuapp.com/posts/b5f051566c7d42dfaa247cb3cadaa1bc/comments",
            "comments": [
                {
                    "author": {
                        "id": "cmput404-group-project-mandala.herokuapp.com/author/a4d9bf5c087941c28f83159e73e6ce2d",
                        "host": "cmput404-group-project-mandala.herokuapp.com",
                        "displayName": "ColeBoytinck",
                        "url": "cmput404-group-project-mandala.herokuapp.com/author/a4d9bf5c087941c28f83159e73e6ce2d",
                        "github": "https://github.com/ColeBoytinck"
                    },
                    "comment": "This is a comment",
                    "contentType": "",
                    "published": "2020-03-24T00:52:52.235Z",
                    "id": "3ca616bf3305472a9511f139f89779ff"
                },
                {
                    "author": {
                        "id": "cmput404-group-project-mandala.herokuapp.com/author/a4d9bf5c087941c28f83159e73e6ce2d",
                        "host": "cmput404-group-project-mandala.herokuapp.com",
                        "displayName": "ColeBoytinck",
                        "url": "cmput404-group-project-mandala.herokuapp.com/author/a4d9bf5c087941c28f83159e73e6ce2d",
                        "github": "https://github.com/ColeBoytinck"
                    },
                    "comment": "Leave a comment",
                    "contentType": "",
                    "published": "2020-03-24T03:06:35.131Z",
                    "id": "47ed0b5dc7a74c869b3bca89fc12b0ba"
                }
            ],
            "published": "2020-03-24T00:26:42.321Z",
            "id": "b5f051566c7d42dfaa247cb3cadaa1bc",
            "visibility": "PUBLIC",
            "visibleTo": [],
            "unlisted": false
        }
    ]
}
  • Will error out if you request the HTML page and are not logged in as a user locally. Servers wishing to connect using the API must pass the accept header in order to receive JSON
  • response status codes:
    • 200: successful retrieval of posts
    • 401: you did not send Authentication: basic {base64 of 'username:password'}, or it was sent improperly

http://service/posts/str:post_id/comments/ retrieve post comment

  • request method: GET
  • url parameter: post_id: UUID
  • example response:
{
    "query": "comments",
    "count": 1,
    "size": 1,
    "comments": [
        {
            "contentType": "text/markdown",
            "content": "Commenting on your own posts *in* _markdown_",
            "published": "2020-03-24T00:01:23.767Z",
            "author": {
                "last_login": "2020-03-24T15:00:40.002Z",
                "username": "mandala_joe",
                "first_name": "joe",
                "last_name": "joe",
                "email": "joe@mandala.ca",
                "is_active": true,
                "date_joined": "2020-03-23T23:59:33.818Z",
                "id": "1ab9cf9a-fb38-45ce-b34c-c6e124231eb6",
                "bio": "",
                "host": "cmput404-group-project-mandala.herokuapp.com",
                "display_name": "Mandala Joe",
                "url": "cmput404-group-project-mandala.herokuapp.com/author/1ab9cf9afb3845ceb34cc6e124231eb6",
                "github": "https://github.com/AustinGrey"
            },
            "parentPost": "08c9fe2b-0bc0-4dd5-b5cd-f27cc4f5b861",
            "id": "00821a16-28c7-41aa-9915-b9153fb93056"
        }
    ]
}

Clone this wiki locally