Skip to main content

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

ParameterTypeRequiredDescription
slugStringYesURL-friendly slug of the blog post

Example Requests

1import requests
2response = requests.get('http://www.example.com/api/shop/blog/my-first-blog-post/')
3print(response.json())

Status Codes

CodeDescription
200Blog post retrieved successfully
400Bad request — invalid parameters
404Not found — blog post does not exist
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.