Retrieve Blog
Retrieve a specific blog post by its unique slug.
HTTP Request
GET/api/shop/blog/:slug
Authorization
Authorization
- Required: No
- Permission: None (public access) or Authenticated users
- Authentication: None or Token-based authentication
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| slug | String | Yes | URL-friendly slug of the blog post |
Example Requests
- 🐍 Python
- 🌐 Curl
1import requests
2response = requests.get('http://www.example.com/api/shop/blog/my-first-blog-post/')
3print(response.json())1curl -X GET "http://www.example.com/api/shop/blog/my-first-blog-post/" -H "Authorization: Token <your_api_key>"Status Codes
| Code | Description |
|---|---|
| 200 | Blog post retrieved successfully |
| 400 | Bad request — invalid parameters |
| 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 |
| 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 | Object | Author details including `id`, `username`, and `full_name` |
| featured_image | Object or null | Details of the featured image or null if none exists |
| 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) |
Notes
- If is_published is False, the blog post will not appear in this list for unauthenticated users or users without proper permissions. To view unpublished posts, authentication is required.
- The
excerptfield provides a short summary of the blog post. - The
truncated_excerptfield provides a shortened version of the excerpt, useful for previews. - The
human_readable_viewsfield provides a more understandable view count, making it easier for users to grasp the post's popularity. - The
featured_imagefield contains the URL of the featured image for the blog post, if available. - The
created_atandupdated_atfields are automatically set to the current timestamp when the blog post is created or updated. - To prevent excessive data transfer, the
bodyfield is not included in the list response. It can be retrieved separately using theRetrieve a Blog Postendpoint.