Blogs
Blog post management
Retrieves a paginated list of blogs. Admins see all; users see only 'published'. Sorted by creation date descending.
Maximum number of items to return.
20
Number of items to skip for pagination.
0
GET /api/v1/blogs/ HTTP/1.1
Host: blog-api.codewithsadee.com
Authorization: Bearer JWT
Accept: */*
{
"limit": 1,
"offset": 1,
"total": 1,
"blogs": [
{
"_id": "text",
"title": "text",
"slug": "text",
"content": "text",
"banner": {
"url": "text",
"width": 1,
"height": 1
},
"author": {
"_id": "text",
"username": "text",
"email": "[email protected]",
"role": "user",
"firstName": "text",
"lastName": "text",
"socialLinks": {
"website": "text",
"facebook": "text",
"instagram": "text",
"linkedin": "text",
"x": "text",
"youtube": "text"
},
"createdAt": "2025-07-28T18:23:29.495Z",
"updatedAt": "2025-07-28T18:23:29.495Z"
},
"viewsCount": 0,
"likesCount": 0,
"commentsCount": 0,
"status": "draft",
"publishedAt": "2025-07-28T18:23:29.495Z",
"updatedAt": "2025-07-28T18:23:29.495Z"
}
]
}
Creates a new blog post. Requires banner image upload. Admin role required.
HTML content
draft
Possible values: Banner image file (png/jpg/webp, max 2MB)
POST /api/v1/blogs/ HTTP/1.1
Host: blog-api.codewithsadee.com
Authorization: Bearer JWT
Content-Type: multipart/form-data
Accept: */*
Content-Length: 74
{
"title": "text",
"content": "text",
"status": "draft",
"banner_image": "binary"
}
{
"blog": {
"_id": "text",
"title": "text",
"slug": "text",
"content": "text",
"banner": {
"url": "text",
"width": 1,
"height": 1
},
"author": {
"_id": "text",
"username": "text",
"email": "[email protected]",
"role": "user",
"firstName": "text",
"lastName": "text",
"socialLinks": {
"website": "text",
"facebook": "text",
"instagram": "text",
"linkedin": "text",
"x": "text",
"youtube": "text"
},
"createdAt": "2025-07-28T18:23:29.495Z",
"updatedAt": "2025-07-28T18:23:29.495Z"
},
"viewsCount": 0,
"likesCount": 0,
"commentsCount": 0,
"status": "draft",
"publishedAt": "2025-07-28T18:23:29.495Z",
"updatedAt": "2025-07-28T18:23:29.495Z"
}
}
Retrieves a paginated list of blogs by a specific user. Admins see all; users see only 'published'. Sorted by creation date descending.
ID of the user.
Maximum number of items to return.
20
Number of items to skip for pagination.
0
GET /api/v1/blogs/user/{userId} HTTP/1.1
Host: blog-api.codewithsadee.com
Authorization: Bearer JWT
Accept: */*
{
"limit": 1,
"offset": 1,
"total": 1,
"blogs": [
{
"_id": "text",
"title": "text",
"slug": "text",
"content": "text",
"banner": {
"url": "text",
"width": 1,
"height": 1
},
"author": {
"_id": "text",
"username": "text",
"email": "[email protected]",
"role": "user",
"firstName": "text",
"lastName": "text",
"socialLinks": {
"website": "text",
"facebook": "text",
"instagram": "text",
"linkedin": "text",
"x": "text",
"youtube": "text"
},
"createdAt": "2025-07-28T18:23:29.495Z",
"updatedAt": "2025-07-28T18:23:29.495Z"
},
"viewsCount": 0,
"likesCount": 0,
"commentsCount": 0,
"status": "draft",
"publishedAt": "2025-07-28T18:23:29.495Z",
"updatedAt": "2025-07-28T18:23:29.495Z"
}
]
}
Retrieves a single blog post by its unique slug. Regular users cannot view 'draft' posts.
Slug of the blog post.
GET /api/v1/blogs/{slug} HTTP/1.1
Host: blog-api.codewithsadee.com
Authorization: Bearer JWT
Accept: */*
{
"blog": {
"_id": "text",
"title": "text",
"slug": "text",
"content": "text",
"banner": {
"url": "text",
"width": 1,
"height": 1
},
"author": {
"_id": "text",
"username": "text",
"email": "[email protected]",
"role": "user",
"firstName": "text",
"lastName": "text",
"socialLinks": {
"website": "text",
"facebook": "text",
"instagram": "text",
"linkedin": "text",
"x": "text",
"youtube": "text"
},
"createdAt": "2025-07-28T18:23:29.495Z",
"updatedAt": "2025-07-28T18:23:29.495Z"
},
"viewsCount": 0,
"likesCount": 0,
"commentsCount": 0,
"status": "draft",
"publishedAt": "2025-07-28T18:23:29.495Z",
"updatedAt": "2025-07-28T18:23:29.495Z"
}
}
Updates an existing blog post. Banner update optional. Admin role required (route security).
ID of the blog post.
HTML content
New banner image file (png/jpg/webp, max 2MB)
PUT /api/v1/blogs/{blogId} HTTP/1.1
Host: blog-api.codewithsadee.com
Authorization: Bearer JWT
Content-Type: multipart/form-data
Accept: */*
Content-Length: 74
{
"title": "text",
"content": "text",
"status": "draft",
"banner_image": "binary"
}
{
"blog": {
"_id": "text",
"title": "text",
"slug": "text",
"content": "text",
"banner": {
"url": "text",
"width": 1,
"height": 1
},
"author": {
"_id": "text",
"username": "text",
"email": "[email protected]",
"role": "user",
"firstName": "text",
"lastName": "text",
"socialLinks": {
"website": "text",
"facebook": "text",
"instagram": "text",
"linkedin": "text",
"x": "text",
"youtube": "text"
},
"createdAt": "2025-07-28T18:23:29.495Z",
"updatedAt": "2025-07-28T18:23:29.495Z"
},
"viewsCount": 0,
"likesCount": 0,
"commentsCount": 0,
"status": "draft",
"publishedAt": "2025-07-28T18:23:29.495Z",
"updatedAt": "2025-07-28T18:23:29.495Z"
}
}
Deletes a blog post by ID. Also removes banner. Admin role required (route security).
ID of the blog post.
DELETE /api/v1/blogs/{blogId} HTTP/1.1
Host: blog-api.codewithsadee.com
Authorization: Bearer JWT
Accept: */*
No content
Was this helpful?