Skip to main content

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

ParameterTypeDefaultDescription
limitintegerNumber of results to return per page.
offsetintegerNumber of results to skip before returning results.
searchstringSearch term to filter results by `id`, `title`, `slug`, `body`.
orderingstringField to order results by (`title`, `views`, `created_at`, `updated_at`, `author__id`, `author__username`, `author__first_name`, `author__last_name`).
views_minintegerMinimum number of views to filter results.
views_maxintegerMaximum number of views to filter results.
has_imagebooleanFilter results to only include posts with an image.
id_minintegerMinimum ID of the blog post.
id_maxintegerMaximum ID of the blog post.
created_datestringExact creation date (`YYYY-MM-DD`).
updated_datestringExact last update date (`YYYY-MM-DD`).
created_fromstringStart date for blog posts created after this date (`YYYY-MM-DD`).
updated_fromstringStart date for blog posts updated after this date (`YYYY-MM-DD`).
created_tostringEnd date for blog posts created before this date (`YYYY-MM-DD`).
updated_tostringEnd date for blog posts updated before this date (`YYYY-MM-DD`).

Example Requests

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())

Status Codes

CodeDescription
200Blog posts retrieved successfully
400Bad request — invalid parameters
500Internal server error

Response Fields

FieldTypeDescription
idIntegerUnique ID of the blog post
titleStringTitle of the blog post
slugStringSlug for the blog post
human_readable_viewsStringHuman-readable format of the views (e.g., 1.2K)
excerptStringShort summary or excerpt of the blog post
truncated_excerptStringTruncated version of the excerpt (e.g., first 100 characters)
authorObjectAuthor details including `id`, `username`, and `full_name`
featured_imageObject or nullDetails of the featured image or null if none exists
created_atString (ISO 8601)Timestamp when the blog post was created
updated_atString (ISO 8601)Timestamp when the blog post was last updated

Author Data Structure

FieldTypeDescription
idIntegerUnique ID of the author
usernameStringUsername of the author
full_nameStringFull name of the author (first and last name combined)

Featured Image Data Structure

FieldTypeDescription
idIntegerUnique ID of the featured image
typeStringFile type (e.g., image/jpeg)
nameStringOriginal file name
sizeIntegerFile size in bytes
human_readable_sizeStringHuman readable file size (e.g., 2.5 MB)
fStringURL to access the image file
widthIntegerImage width in pixels
heightIntegerImage height in pixels
modeStringColor 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 excerpt field provides a short summary of the blog post.
    • The truncated_excerpt field provides a shortened version of the excerpt, useful for previews.
    • The human_readable_views field provides a more understandable view count, making it easier for users to grasp the post's popularity.
    • The featured_image field contains the URL of the featured image for the blog post, if available.
    • The created_at and updated_at fields are automatically set to the current timestamp when the blog post is created or updated.
    • To prevent excessive data transfer, the body field is not included in the list response. It can be retrieved separately using the Retrieve a Blog Post endpoint.