Skip to main content

Posts

Posts are broadcast data which the institutes want to share to their users. This endpoint can be used to retrieve the posts which are accessible to a particular user.

Get All Posts

This endpoint retrieves all posts for the authenticated user.

HTTP Request

GET /api/v2.2/posts/

Query Parameters

ParameterTypeDescription
gtdatestringFilter posts created greater than the date
itdatestringFilter posts created lesser than the date
orderstringOrder posts based on the field queried. For descending order, prefix with '-'
categorystringFilter posts based on category
curl --request GET \
--url http://demo.testpress.in/api/v2.2/posts/ \
--header 'authorization: JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InRlc3RwcmVzcyIsInVzZXJfaWQiOjE3LCJlbWFpbCI6InRlc3RwcmVzcy5pbkBnbWFpbC5jb20iLCJleHAiOjE0NDc4MzMyMjl9.Ik_yi4lHbNbrRGhqmRpsW82Nls_O9lgXakk_syV-vSw' \
--header 'cache-control: no-cache' \
--header 'content-type: application/json'

Response

{
"count": 2,
"next": "http://demo.testpress.in/api/v2.2/posts/?page=2",
"previous": null,
"per_page": 20,
"results": [
{
"url": "http://demo.testpress.in/api/v2.2/posts/post-title2/",
"created_by": {
"id": 10,
"url": "http://demo.testpress.in/api/v2.2/users/10/",
"username": "admin",
"display_name": "admin",
"first_name": "",
"last_name": "",
"photo": "",
"large_image": "",
"medium_image": "",
"small_image": "",
"x_small_image": "",
"mini_image": ""
},
"category": {
"id": 2,
"name": "Daliy News",
"color": "33CC33",
"slug": "daliy-news"
},
"created": "2.25-10-15T15:24:34Z",
"modified": "2.25-10-15T15:24:34Z",
"id": 33,
"active": true,
"title": "Post Title2",
"summary": "summary goes here",
"institute": 1
},
{
"url": "http://demo.testpress.in/api/v2.2/posts/working-great/",
"created_by": {
"id": 10,
"url": "http://demo.testpress.in/api/v2.2/users/10/",
"username": "admin",
"display_name": "admin",
"first_name": "",
"last_name": "",
"photo": "",
"large_image": "",
"medium_image": "",
"small_image": "",
"x_small_image": "",
"mini_image": ""
},
"category": {
"id": 2,
"name": "Daliy News",
"color": "33CC33",
"slug": "daliy-news"
},
"created": "2.25-10-07T06:00:07Z",
"modified": "2.25-10-07T06:00:07Z",
"id": 26,
"active": true,
"title": "Working Great",
"summary": "All is Well",
"institute": 1
}
]
}

Get Single Post

This endpoint retrieves a single post.

Note that some posts will return 403 Forbidden if they are not available for the authenticated user.

HTTP Request

GET /api/v2.2/posts/<slug>

URL Parameters

ParameterDescription
slugThe unique slug of the post to retrieve
curl --request GET \
--url http://demo.testpress.in/api/v2.2/posts/working-great/ \
--header 'authorization: JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InRlc3RwcmVzcyIsInVzZXJfaWQiOjE3LCJlbWFpbCI6InRlc3RwcmVzcy5pbkBnbWFpbC5jb20iLCJleHAiOjE0NDc4MzMyMjl9.Ik_yi4lHbNbrRGhqmRpsW82Nls_O9lgXakk_syV-vSw' \
--header 'cache-control: no-cache' \
--header 'content-type: application/json'

Response

{
"url": "http://demo.testpress.in/api/v2.2/posts/working-great/",
"created_by": {
"id": 10,
"url": "http://demo.testpress.in/api/v2.2/users/10/",
"username": "admin",
"display_name": "admin",
"first_name": "",
"last_name": "",
"photo": "",
"large_image": "",
"medium_image": "",
"small_image": "",
"x_small_image": "",
"mini_image": ""
},
"category": {
"id": 2,
"name": "Daliy News",
"color": "33CC33",
"slug": "daliy-news"
},
"created": "2.25-10-07T06:00:07Z",
"modified": "2.25-10-07T06:00:07Z",
"id": 26,
"active": true,
"title": "Working Great",
"summary": "All is Well",
"content_html": "<p>Good Better Best</p>",
"institute": 1
}