Topics


Request all topics

/api/topics/
You'll get paginated data with following structure:

{
    "count": 149,
    "next": "http://127.0.0.1:8000/api/topics/?page=2",
    "previous": null,
    "results": [
        {
            "id": 159,
            "name": "Test",
            "starter": {
                "id": 1,
                "username": "automan",
                "detail_url": "http://127.0.0.1:8000/api/users/1/"
            },
            "views": 1,
            "last_updated": "11.06.2018, 09:01",
            "posts_url": "http://127.0.0.1:8000/api/topics/159/posts/",
            "reply_topic": "http://127.0.0.1:8000/api/topics/159/reply/",
            "board": {
                "id": 3,
                "name": "Smoking room",
                "description": "Discuss anything",
                "posts_count": 9,
                "topics_count": 8,
                "last_post_datetime": "11.06.2018, 09:27",
                "topics_url": "http://127.0.0.1:8000/api/boards/3/topics/"
            }
        },
        ...
    ]
}

Request specific topic by given id

/api/topics/id/
You'll get paginated data with following structure:

{
    "count": 149,
    "next": "http://127.0.0.1:8000/api/topics/?page=2",
    "previous": null,
    "results": [
        {
            "id": 159,
            "name": "Test",
            "starter": {
                "id": 1,
                "username": "automan",
                "detail_url": "http://127.0.0.1:8000/api/users/1/"
            },
            "views": 1,
            "last_updated": "11.06.2018, 09:01",
            "posts_url": "http://127.0.0.1:8000/api/topics/159/posts/",
            "reply_topic": "http://127.0.0.1:8000/api/topics/159/reply/",
            "board": {
                "id": 3,
                "name": "Smoking room",
                "description": "Discuss anything",
                "posts_count": 9,
                "topics_count": 8,
                "last_post_datetime": "11.06.2018, 09:27",
                "topics_url": "http://127.0.0.1:8000/api/boards/3/topics/"
            }
        },
        ...
    ]
}


Request topic posts (Posts inside that topic):

/api/topics/id/posts/
You'll get a paginated list of topic posts, with following structure:

{
    "count": 4,
    "next": null,
    "previous": null,
    "results": [
        {
            "id": 3,
            "html_message": "<p>Test</p>",
            "message": "Test",
            "created_by": {
                "id": 1,
                "username": "automan",
                "detail_url": "http://127.0.0.1:8000/api/users/1/"
            },
            "created_at": "09.03.2018, 11:43",
            "edit_post_url": "http://127.0.0.1:8000/api/posts/3/edit/"
        },
        ...
    ]
}


Make a reply for topic (requires authentication):

/api/topics/id/reply/
Only POST method allowed. To reply a topic you need to send data with attribute "message" inside. In message text you can use markdown rules. If everything right you'll receive created post with following structure:

{
    "id": 166,
    "html_message": "<p>What's structure of returned object?</p>",
    "message": "What's structure of returned object?",
    "created_by": {
        "id": 1,
        "username": "automan",
        "detail_url": "http://127.0.0.1:8000/api/users/1/"
    },
    "created_at": "13.06.2018, 11:39",
    "edit_post_url": "http://127.0.0.1:8000/api/posts/166/edit/",
    "topic": {
        "id": 3,
        "name": "What if I enter very long topic subject? Ha?",
        "starter": {
            "id": 1,
            "username": "automan",
            "detail_url": "http://127.0.0.1:8000/api/users/1/"
        },
        "views": 19,
        "last_updated": "09.03.2018, 11:43",
        "posts_url": "http://127.0.0.1:8000/api/topics/3/posts/",
        "reply_topic": "http://127.0.0.1:8000/api/topics/3/reply/"
    }
}