Blog
This endpoint group provides methods for managing blog posts, including listing public posts and administrative operations for creating, retrieving, updating, and deleting posts.
Endpoints
POST /api/rpc (Method: BlogRpc.listPublicPosts)
Description: Lists all PUBLISHED blog posts for the current application.
Request Body:
{ "method": "BlogRpc.listPublicPosts", "params": { "limit": 100 } }Parameters:
Name Type Required Description limitNumberNo The maximum number of posts to return. Defaults to 100. Response:
{ "success": true, "data": { "data": [ { "_id": "65e23f1a0b3c4d5e6f7a8b9c", "title": "My First Blog Post", "slug": "my-first-blog-post", "content": "This is the content of my first blog post.", "status": "published", "appName": "MyApp", "publishedAt": "2023-01-01T12:00:00.000Z", "createdAt": "2023-01-01T11:00:00.000Z", "updatedAt": "2023-01-01T11:30:00.000Z", "imageUrlName": "blog-thumb-my-first-blog-post" } ], "totalCount": 1 } }Example (cURL):
curl -X POST https://api.example.com/api/rpc \ -H "Content-Type: application/json" \ -H "X-API-Key: YOUR_API_KEY" \ -d '{ "method": "BlogRpc.listPublicPosts", "params": { "limit": 50 } }'
POST /api/rpc (Method: BlogRpc.getData)
Description: Admin method to get a paginated list of blog posts for an app.
Request Body:
{ "method": "BlogRpc.getData", "params": { "filter": { "appName": "YourAppName", "status": "draft" }, "sort": { "createdAt": -1 }, "page": 1, "pageSize": 25 } }Parameters:
Name Type Required Description filterObjectNo An object to filter the blog posts. appNameis a required field within the filter.sortObjectNo An object specifying the sort order (e.g., { createdAt: -1 }for descending creation date).pageNumberNo The page number to retrieve. Defaults to 1. pageSizeNumberNo The number of items per page. Defaults to 25. Response:
{ "success": true, "data": { "data": [ { "_id": "65e23f1a0b3c4d5e6f7a8b9c", "title": "Admin Post", "slug": "admin-post", "content": "This is an admin post.", "status": "draft", "appName": "YourAppName", "createdAt": "2023-01-01T11:00:00.000Z", "updatedAt": "2023-01-01T11:30:00.000Z" } ], "totalCount": 1 } }Example (cURL):
curl -X POST https://api.example.com/api/rpc \ -H "Content-Type: application/json" \ -H "X-API-Key: YOUR_API_KEY" \ -d '{ "method": "BlogRpc.getData", "params": { "filter": { "appName": "MyApp", "status": "published" }, "page": 1, "pageSize": 10 } }'
POST /api/rpc (Method: BlogRpc.create)
Description: Creates a new blog post.
Request Body:
{ "method": "BlogRpc.create", "params": { "title": "New Blog Post", "slug": "new-blog-post", "content": "Content of the new post.", "status": "draft", "appName": "MyApp", "publishedAt": null } }Parameters:
Name Type Required Description titleStringYes The title of the blog post. slugStringYes A URL-friendly identifier for the blog post. contentStringYes The main content of the blog post. statusStringYes The publication status of the post (e.g., 'draft', 'published'). appNameStringYes The name of the application this blog post belongs to. publishedAtString|nullNo The date and time the post was published. Response:
{ "success": true, "data": { "_id": "65e23f1a0b3c4d5e6f7a8b9d", "title": "New Blog Post", "slug": "new-blog-post", "content": "Content of the new post.", "status": "draft", "appName": "MyApp", "publishedAt": null, "createdAt": "2023-01-01T12:00:00.000Z", "updatedAt": "2023-01-01T12:00:00.000Z" } }Example (cURL):
curl -X POST https://api.example.com/api/rpc \ -H "Content-Type: application/json" \ -H "X-API-Key: YOUR_API_KEY" \ -d '{ "method": "BlogRpc.create", "params": { "title": "My New Article", "slug": "my-new-article", "content": "This is the exciting content.", "status": "draft", "appName": "MyApp" } }'
POST /api/rpc (Method: BlogRpc.update)
Description: Updates an existing blog post.
Request Body:
{ "method": "BlogRpc.update", "params": { "_id": "65e23f1a0b3c4d5e6f7a8b9c", "title": "Updated Title", "status": "published" } }Parameters:
Name Type Required Description _idStringYes The unique identifier of the blog post to update. titleStringNo The new title for the blog post. slugStringNo The new slug for the blog post. contentStringNo The new content for the blog post. statusStringNo The new publication status for the post. appNameStringNo The new application name for the post. publishedAtString|nullNo The new published date for the post. Response:
{ "success": true, "data": { "_id": "65e23f1a0b3c4d5e6f7a8b9c", "title": "Updated Title", "slug": "my-first-blog-post", "content": "This is the content of my first blog post.", "status": "published", "appName": "MyApp", "publishedAt": "2023-01-01T12:00:00.000Z", "createdAt": "2023-01-01T11:00:00.000Z", "updatedAt": "2023-01-01T13:00:00.000Z" } }Example (cURL):
curl -X POST https://api.example.com/api/rpc \ -H "Content-Type: application/json" \ -H "X-API-Key: YOUR_API_KEY" \ -d '{ "method": "BlogRpc.update", "params": { "_id": "65e23f1a0b3c4d5e6f7a8b9c", "status": "archived" } }'
POST /api/rpc (Method: BlogRpc.delete)
Description: Deletes a blog post by its ID.
Request Body:
{ "method": "BlogRpc.delete", "params": { "_id": "65e23f1a0b3c4d5e6f7a8b9c" } }Parameters:
Name Type Required Description _idStringYes The unique identifier of the blog post to delete. Response:
{ "success": true, "data": { "success": true } }Example (cURL):
curl -X POST https://api.example.com/api/rpc \ -H "Content-Type: application/json" \ -H "X-API-Key: YOUR_API_KEY" \ -d '{ "method": "BlogRpc.delete", "params": { "_id": "65e23f1a0b3c4d5e6f7a8b9c" } }'