Get All Blog Posts
Retrieve a list of blog posts with optional filtering, searching, and pagination.
HTTP Request
GET/api/shop/blog
Authorization
Authorization
- Required: No
- Permission: None (public access) or Authenticated users
- Authentication: None or Token-based authentication
Query Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
| limit | integer | — | Number of results to return per page. |
| offset | integer | — | Number of results to skip before returning results. |
| search | string | — | Search term to filter results by `id`, `title`, `slug`, `body`. |
| ordering | string | — | Field to order results by (`title`, `views`, `created_at`, `updated_at`, `author__id`, `author__username`, `author__first_name`, `author__last_name`). |
| views_min | integer | — | Minimum number of views to filter results. |
| views_max | integer | — | Maximum number of views to filter results. |
| has_image | boolean | — | Filter results to only include posts with an image. |
| id_min | integer | — | Minimum ID of the blog post. |
| id_max | integer | — | Maximum ID of the blog post. |
| created_date | string | — | Exact creation date (`YYYY-MM-DD`). |
| updated_date | string | — | Exact last update date (`YYYY-MM-DD`). |
| created_from | string | — | Start date for blog posts created after this date (`YYYY-MM-DD`). |
| updated_from | string | — | Start date for blog posts updated after this date (`YYYY-MM-DD`). |
| created_to | string | — | End date for blog posts created before this date (`YYYY-MM-DD`). |
| updated_to | string | — | End date for blog posts updated before this date (`YYYY-MM-DD`). |
Example Requests
- 🐍 Python
- 🌐 Curl
1import requests
2api = requests.Session()
3response = api.get('http://www.example.com/api/shop/blog/', params={
4 'limit': 5,
5 'ordering': 'created_at',
6 'search': 'example'
7})
8print(response.json())1curl "http://www.example.com/api/shop/blog/?limit=5&ordering=created_at&search=example"Status Codes
| Code | Description |
|---|---|
| 200 | Blog posts retrieved successfully |
| 400 | Bad request — invalid parameters |
| 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.