Skip to main content

Get All Blog Posts

Retrieve a list of blog posts with optional filtering, searching, and pagination.

HTTP Request

GET/api/blog/posts

Authorization

Authorization

  • Required: Yes
  • Permission: Staff or Admin
  • Authentication: Token-based (Authorization: Token <your_api_key>)

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`, `slug`, `title`, `body`, `author__id`, `author__username`, `author__email`, `author__first_name`, `author__last_name`.
orderingstringField to order results by (`id`, `title`, `views`, `created_at`, `updated_at`, `author__id`, `author__username`, `author__first_name`, `author__last_name`).
views_minintegerMinimum number of views to filter results by.
views_maxintegerMaximum number of views to filter results by.
has_imagebooleanFilter results to only include posts with a featured image.
id_minintegerMinimum ID to filter results by.
id_maxintegerMaximum ID to filter results by.
created_datestringFilter results by creation date (e.g., `2023-01-01`).
updated_datestringFilter results by last updated date (e.g., `2023-01-01`).
created_fromstringFilter results by creation date range (e.g., `2023-01-01` to `2023-12-31`).
created_tostringFilter results by creation date range (e.g., `2023-01-01` to `2023-12-31`).
updated_fromstringFilter results by last updated date range (e.g., `2023-01-01` to `2023-12-31`).
updated_tostringFilter results by last updated date range (e.g., `2023-01-01` to `2023-12-31`).

Example Requests

1import requests
2response = requests.get('http://www.example.com/api/blog/posts', params={
3  'limit': 5,
4  'ordering': 'created_at',
5  'search': 'Python',
6  'views_min': 100,
7  'views_max': 1000,
8  'has_image': True,
9  'created_from': '2023-01-01',
10  'created_to': '2023-12-31'
11})
12print(response.json())

Status Codes

CodeDescription
200Blog posts retrieved successfully
400Bad request — invalid parameters
401Unauthorized — authentication required
403Forbidden — insufficient permissions
500Internal server error

Response Fields

FieldTypeDescription
idIntegerUnique ID of the blog post
titleStringTitle of the blog post
slugStringSlug for the blog post
viewsIntegerNumber of views the blog post has received
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)
author_dataObjectAuthor details including `id`, `username`, and `full_name`
featured_image_dataObjectFeatured image data including `id`, `type`, `name`, `size`, `human_readable_size`, `f`, `width`, `height`, and `mode`
bodyStringFull content of the blog post
truncated_bodyStringTruncated version of the body (e.g., first 200 characters)
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)