Skip to content

Backend API Post

alexbali edited this page Mar 31, 2021 · 9 revisions

Post

/service/author/{AUTHOR_ID}/posts/{POST_ID} will get you the post of that author with the 5 most recent comments

  • Request Method: GET
  • Example Response

    "type": "post",
    "title": "goat post lebron",
    "id": "ec46af16-4a8c-403e-91c7-e6a6860bbcc6",
    "source": "localhost:8000/some_random_source",
    "origin": "local host:9900",
    "description": "aruso is the goat",
    "contentType": "text/plain",
    "content": "first post with new API",
    "author": {
        "type": "author",
        "id": "d1df0f23-cd4f-4875-b79b-dca706093b89",
        "host": "http://localhost:8000/",
        "displayName": "goatjames",
        "url": "somerandomUrl for now",
        "github": ""
    },
    "categories": [
        "fitness,",
        "travel,",
        "compscience"
    ],
    "count": 2,
    "comments": [
        {
            "type": "comment",
            "author": {
                "type": "author",
                "id": "d1df0f23-cd4f-4875-b79b-dca706093b89",
                "host": "http://localhost:8000/",
                "displayName": "goatjames",
                "url": "somerandomUrl for now",
                "github": ""
            },
            "comment": "nice weather",
            "contentType": "text/markdown",
            "published": "2021-03-03T00:23:11.783Z",
            "id": "fe7ffefe-0920-4728-aec2-4ad123272f12"
        },
        {
            "type": "comment",
            "author": {
                "type": "author",
                "id": "d1df0f23-cd4f-4875-b79b-dca706093b89",
                "host": "http://localhost:8000/",
                "displayName": "goatjames",
                "url": "somerandomUrl for now",
                "github": ""
            },
            "comment": "what's good bro",
            "contentType": "text/markdown",
            "published": "2021-03-03T00:22:55.689Z",
            "id": "fe7ffefe-0920-4728-aec2-4ad123272f11"
        }
    ],
    "published": "2021-03-03T00:16:35.719Z",
    "visibility": "PUBLIC",
    "unlisted": "false"
}

GET all Posts of an Author: localhost:8000/service/author/{author_id}/posts/

  • Request Method: GET
  • Example Response
{
    "posts": [
        {
            "type": "post",
            "title": "hello",
            "id": "e2c7c5cd-af31-4ae6-8d8a-4fae37fb33f7",
            "source": "localhost:8000/some_random_source",
            "origin": "http://localhost:8000",
            "description": "what's good ",
            "contentType": "text/plain",
            "content": "some random content",
            "author": {
                "type": "author",
                "id": "21c18158-5fa3-45c4-b12b-bd0f5dd071d5",
                "host": "http://localhost:8000/",
                "displayName": "goatjames",
                "url": "somerandomUrl for now",
                "github": ""
            },
            "categories": [],
            "count": 0,
            "comments": [],
            "published": "2021-03-30T07:30:32.559Z",
            "visibility": "PUBLIC",
            "unlisted": "false"
        }
    ]
}

POST Requests:

URL: ://service/author/{AUTHOR_ID}/posts/{POST_ID=null} will create the post for that author.

POST Body:

{
    "title": "second post",
    "description": "description of the second post -> caruso is the goat",
    "categories": "fitness, travel, compsci",
    "content": "long detailed content of the post",
    "origin": "local host:9900"
}

PUT Requests:

URL: ://service/author/{AUTHOR_ID}/posts/{POST_ID} PUT Body:

{
    "title": "goat post",
    "description": "Caruso is the goat",
    "categories": "fitness, travel, compsci",
    "content": "first post with new API",
    "origin": "local host:9900",
    "visibility": PUBLIC
    "shared_with": ""
}

DELETE Requests:

URL: ://service/author/{AUTHOR_ID}/posts/{POST_ID} -> this will delete the post with the id you provided.


Clone this wiki locally