AstraCMS
Posts

List posts

Get a paginated list of published posts with filtering and search capabilities

GET
/v2/posts

Authorization

ApiKeyAuth

AuthorizationBearer <token>

API key for V2 endpoints. Use format: Bearer {your_api_key}. Get your key from the AstraCMS dashboard.

In: header

Query Parameters

limit?string

Number of posts per page or 'all' for no pagination

Default"10"
page?string

Page number for pagination

Default"1"
order?string

Sort order by published date

Default"desc"
Value in"asc" | "desc"
categories?string

Comma-separated category slugs to filter by

excludeCategories?string

Comma-separated category slugs to exclude

tags?string

Comma-separated tag slugs to filter by

excludeTags?string

Comma-separated tag slugs to exclude

query?string

Search query to filter posts by title or content

format?string

Content format (html or markdown)

Value in"html" | "markdown"
excludeContent?string

When true, omits the content field from posts to reduce payload size. Useful for list views where only metadata is needed.

Value in"true" | "false"

Response Body

application/json

application/json

application/json

application/json

application/json

application/json

curl -X GET "https://api.astracms.dev/v2/posts"
{
  "posts": [
    {
      "id": "clx4b6d8f0h2j4l6n8p0r",
      "slug": "my-first-post",
      "title": "My First Blog Post",
      "content": "<p>This is the content of my first blog post.</p>",
      "featured": true,
      "coverImage": "https://example.com/cover.jpg",
      "description": "A brief description of the post",
      "publishedAt": "2024-01-01T12:00:00Z",
      "updatedAt": "2024-01-02T12:00:00Z",
      "attribution": "Originally published on Medium",
      "authors": [
        {
          "id": "clx1a2b3c4d5e6f7g8h9i",
          "name": "John Doe",
          "image": "https://example.com/avatar.jpg",
          "bio": "Tech writer and developer",
          "role": "Senior Developer",
          "slug": "john-doe",
          "socials": [
            {
              "url": "https://twitter.com/johndoe",
              "platform": "twitter"
            }
          ]
        }
      ],
      "category": {
        "id": "clx2k4m6n8p0r2t4v6x8z",
        "name": "Technology",
        "slug": "technology",
        "description": "Tech articles and news"
      },
      "tags": [
        {
          "id": "clx3y5a7c9e1g3i5k7m9o",
          "name": "JavaScript",
          "slug": "javascript",
          "description": "JavaScript programming"
        }
      ]
    }
  ],
  "pagination": {
    "limit": 10,
    "currentPage": 1,
    "nextPage": 2,
    "previousPage": null,
    "totalPages": 5,
    "totalItems": 48
  }
}
{
  "error": "Bad Request",
  "details": null,
  "message": "Additional error context"
}
{
  "error": "Unauthorized",
  "message": "Missing or invalid API key"
}
{
  "error": "Forbidden",
  "message": "Insufficient permissions for this resource"
}
{
  "error": "Too Many Requests",
  "message": "Rate limit exceeded. Please try again later.",
  "retryAfter": 60
}
{
  "error": "Bad Request",
  "details": null,
  "message": "Additional error context"
}

Last updated on