AppMage

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
    limit Number No 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
    filter Object No An object to filter the blog posts. appName is a required field within the filter.
    sort Object No An object specifying the sort order (e.g., { createdAt: -1 } for descending creation date).
    page Number No The page number to retrieve. Defaults to 1.
    pageSize Number No 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
    title String Yes The title of the blog post.
    slug String Yes A URL-friendly identifier for the blog post.
    content String Yes The main content of the blog post.
    status String Yes The publication status of the post (e.g., 'draft', 'published').
    appName String Yes The name of the application this blog post belongs to.
    publishedAt String | null No 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
    _id String Yes The unique identifier of the blog post to update.
    title String No The new title for the blog post.
    slug String No The new slug for the blog post.
    content String No The new content for the blog post.
    status String No The new publication status for the post.
    appName String No The new application name for the post.
    publishedAt String | null No 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
    _id String Yes 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"
        }
      }'