Skip to content

RESTful API P7

annypanny edited this page Nov 29, 2016 · 1 revision

/author/posts

  • It used to get the content of all the posts that public to the current authenticate author.

  • It returned a JSON.

  • JSON file contains:

    • "count"
    • "posts"
    • "next"
    • "query"
    • "size"
    • "previous"

    and in each "posts", it has:

    • "id"
    • "published"
    • "title"
    • "description"
    • "contentType"
    • "content"
    • "source"
    • "origin"
    • "author"
    • "comments"
    • "visibility"
    • "image"

    and in each "comments", it has:

    • "author"
    • "comment"
    • "pubdate"
    • "id"
    • "contentType"
    • "post"

    and in each "author", it has:

    • "id"
    • "first_name"
    • "last_name"
    • "github"
    • "host"
    • "avatar"
    • "authors"
    • "email"
    • "displayName"
    • "url"
    • "local"

    and in each "author" inside comments, it has:

    • "displayName"
    • "id"
    • "host"
    • "url"
    • "github"

Optional parameter:

  • ?page={integer}

    The page you want to see now and it's less than or equal to the total number of pages the server has.

    example url: http://127.0.0.1:8000/posts/?page=2 (shows page 2)

  • ?page={integer}&size={integer}

    The page you want to see now, and each page shows exactly the number of post you request in the size.

    example url: http://127.0.0.1:8000/posts/?page=2&size=5 (shows page 2, and each page has 5 posts)

Method:

GET

Example:

GET /author/posts


HTTP 200 OK
Allow: GET, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
	"count": 3,
	"posts": [
	    {
	        "id": "20d4a6fb-da69-4359-90a6-44497ae533cc",
	        "published": "2016-11-27T23:30:44.598751Z",
	        "title": "I love dogs",
	        "description": "Dogs are nice",
	        "contentType": "text/plain",
	        "content": "I like them",
	        "source": "http://socialnets404.herokuapp.com/posts/20d4a6fb-da69-4359-90a6-44497ae533cc/",
	        "origin": "http://socialnets404.herokuapp.com/posts/20d4a6fb-da69-4359-90a6-44497ae533cc/",
	        "author": {
	            "id": "c974a1fd-fa8c-4d99-97d6-6006e0ee0a5f",
	            "first_name": "",
	            "last_name": "",
	            "github": "jiafengwu0301",
	            "host": "http://socialnets404.herokuapp.com/",
	            "avatar": "",
	            "authors": [
	                {
	                    "displayName": "Gustavo Santiago",
	                    "id": "a9284a45-5605-4a47-a967-ad39c35c72ec",
	                    "host": "http://socialnets404.herokuapp.com/author/a9284a45-5605-4a47-a967-ad39c35c72ec",
	                    "url": "http://socialnets404.herokuapp.com/",
	                    "github": "shtanaka",
	                    "is_local": true
	                },
	                {
	                    "displayName": "Jiafeng Wu",
	                    "id": "eb572e7b-7856-468b-bfdf-9b6388f9165c",
	                    "host": "http://socialnets404.herokuapp.com/",
	                    "url": "http://socialnets404.herokuapp.com/author/eb572e7b-7856-468b-bfdf-9b6388f9165c",
	                    "github": "jiafengwu0301",
	                    "is_local": true
	                }
	            ],
	            "email": "[email protected]",
	            "displayName": "Administrator",
	            "url": "http://socialnets404.herokuapp.com/author/c974a1fd-fa8c-4d99-97d6-6006e0ee0a5f",
	            "local": true
	        },
	        "comments": [],
	        "visibility": "PUBLIC",
	        "image": ""
	    },
	    {
	        "id": "e0420969-e020-4bdb-8285-3ea5d0f97878",
	        "published": "2016-11-28T01:45:29.737511Z",
	        "title": "first post",
	        "description": "this is my first post",
	        "contentType": "text/x-markdown",
	        "content": "this is my first post",
	        "source": "http://socialnets404.herokuapp.com/posts/e0420969-e020-4bdb-8285-3ea5d0f97878",
	        "origin": "http://socialnets404.herokuapp.com/posts/e0420969-e020-4bdb-8285-3ea5d0f97878",
	        "author": {
	            "id": "d2325f9c-09de-492a-83a9-409047905e40",
	            "first_name": "iam",
	            "last_name": "user123",
	            "github": "[email protected]",
	            "host": "http://socialnets404.herokuapp.com/",
	            "avatar": "",
	            "authors": [],
	            "email": "[email protected]",
	            "displayName": "iamuser",
	            "url": "http://socialnets404.herokuapp.com/author/d2325f9c-09de-492a-83a9-409047905e40",
	            "local": true
	        },
	        "comments": [
	            {
	                "author": {
	                    "displayName": "Jiafeng Wu",
	                    "id": "eb572e7b-7856-468b-bfdf-9b6388f9165c",
	                    "host": "http://socialnets404.herokuapp.com/",
	                    "url": "http://socialnets404.herokuapp.com/author/eb572e7b-7856-468b-bfdf-9b6388f9165c",
	                    "github": "jiafengwu0301"
	                },
	                "comment": "blah blah blah",
	                "pubdate": "2016-11-28T21:21:32.476742Z",
	                "id": "a94416b4-c6bd-4dac-8fc2-fbf8886c9396",
	                "contentType": "text/plain",
	                "post": "http://socialnets404.herokuapp.com/posts/e0420969-e020-4bdb-8285-3ea5d0f97878"
	            }
	        ],
	        "visibility": "PUBLIC",
	        "image": ""
	    },
	    {
	        "id": "44ad3256-4486-42b9-8e07-9d195e802985",
	        "published": "2016-11-28T00:16:41.358555Z",
	        "title": "I will travel to Japan",
	        "description": "Japan travel",
	        "contentType": "text/plain",
	        "content": "It must be a nice place",
	        "source": "http://socialnets404.herokuapp.com/posts/44ad3256-4486-42b9-8e07-9d195e802985",
	        "origin": "http://socialnets404.herokuapp.com/posts/44ad3256-4486-42b9-8e07-9d195e802985",
	        "author": {
	            "id": "c974a1fd-fa8c-4d99-97d6-6006e0ee0a5f",
	            "first_name": "",
	            "last_name": "",
	            "github": "jiafengwu0301",
	            "host": "http://socialnets404.herokuapp.com/",
	            "avatar": "",
	            "authors": [
	                {
	                    "displayName": "Gustavo Santiago",
	                    "id": "a9284a45-5605-4a47-a967-ad39c35c72ec",
	                    "host": "http://socialnets404.herokuapp.com/author/a9284a45-5605-4a47-a967-ad39c35c72ec",
	                    "url": "http://socialnets404.herokuapp.com/",
	                    "github": "shtanaka",
	                    "is_local": true
	                },
	                {
	                    "displayName": "Jiafeng Wu",
	                    "id": "eb572e7b-7856-468b-bfdf-9b6388f9165c",
	                    "host": "http://socialnets404.herokuapp.com/",
	                    "url": "http://socialnets404.herokuapp.com/author/eb572e7b-7856-468b-bfdf-9b6388f9165c",
	                    "github": "jiafengwu0301",
	                    "is_local": true
	                }
	            ],
	            "email": "[email protected]",
	            "displayName": "Administrator",
	            "url": "http://socialnets404.herokuapp.com/author/c974a1fd-fa8c-4d99-97d6-6006e0ee0a5f",
	            "local": true
	        },
	        "comments": [],
	        "visibility": "FRIENDS",
	        "image": ""
	    }
	],
	"next": null,
	"query": "posts",
	"size": 100,
	"previous": null
}

Clone this wiki locally