Retrieve Blog
Retrieve a specific blog post by its unique ID.
HTTP Request
GET/api/blog/posts/:id
Authorization
Authorization
- Required: Yes
- Permission: Staff or Admin
- Authentication: Token-based (Authorization: Token <your_api_key>)
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| id | Integer | Yes | Unique ID of the blog post to retrieve |
Example Requests
- 🐍 Python
- 🌐 Curl
1import requests
2response = requests.get('http://www.example.com/api/blog/posts/1', headers={
3 'Authorization': 'Token <your_api_key>'
4})
5
6print(response.json())1curl
2curl -X GET "http://www.example.com/api/blog/posts/1" -H "Authorization: Token <your_api_key>"Status Codes
| Code | Description |
|---|---|
| 200 | Blog post retrieved successfully |
| 400 | Bad request — invalid parameters |
| 401 | Unauthorized — authentication required |
| 403 | Forbidden — insufficient permissions |
| 404 | Not found — blog post does not exist |
| 500 | Internal server error |
Response Fields
| Field | Type | Description |
|---|---|---|
| id | Integer | Unique ID of the blog post |
| title | String | Title of the blog post |
| slug | String | Slug for the blog post |
| views | Integer | Number of views the blog post has received |
| human_readable_views | String | Human-readable format of the views (e.g., 1.2K) |
| excerpt | String | Short summary or excerpt of the blog post |
| truncated_excerpt | String | Truncated version of the excerpt (e.g., first 100 characters) |
| author_data | Object | Author details including `id`, `username`, and `full_name` |
| featured_image_data | Object | Featured image data including `id`, `type`, `name`, `size`, `human_readable_size`, `f`, `width`, `height`, and `mode` |
| body | String | Full content of the blog post |
| truncated_body | String | Truncated version of the body (e.g., first 200 characters) |
| created_at | String (ISO 8601) | Timestamp when the blog post was created |
| updated_at | String (ISO 8601) | Timestamp when the blog post was last updated |
Author Data Structure
| Field | Type | Description |
|---|---|---|
| id | Integer | Unique ID of the author |
| username | String | Username of the author |
| full_name | String | Full name of the author (first and last name combined) |
Featured Image Data Structure
| Field | Type | Description |
|---|---|---|
| id | Integer | Unique ID of the featured image |
| type | String | File type (e.g., image/jpeg) |
| name | String | Original file name |
| size | Integer | File size in bytes |
| human_readable_size | String | Human readable file size (e.g., 2.5 MB) |
| f | String | URL to access the image file |
| width | Integer | Image width in pixels |
| height | Integer | Image height in pixels |
| mode | String | Color mode (e.g., RGB, CMYK) |