# Blog Display API

> Part of the [NextBlog documentation](https://nextblog.ai/docs.md). Live page: [https://nextblog.ai/docs/endpoints](https://nextblog.ai/docs/endpoints)

> **Legacy alias.** These endpoints keep working with the same request and response shapes, but new integrations should use the [Full REST API](/docs/api-v1.md): `GET /api/v1/projects/{projectId}/posts` for the same published list and `GET /api/v1/projects/{projectId}/posts/{postId}` for a single post. v1 adds the remaining dashboard actions (projects, generation, integrations, billing) and the same error codes everywhere.

These endpoints are for **displaying published content** on your own site: they return only posts that are published in NextBlog. The same project API key is used for authentication.

To create posts, change status, or edit drafts via HTTP, use the optional [Post Management API](/docs/api-manage-posts.md) (`/api/manage/...`).

**Looking for detailed REST API integration guide?** See our [REST API Integration](/docs/integration-rest-api.md) page for step-by-step setup instructions and examples.

### Base URL

```bash
https://nextblog.ai/api/blog
```

### Endpoints

#### Get All Blog Posts

**Endpoint:** `GET /api/blog/{projectId}`

**Description:** Retrieves all published blog posts for a specific project.

**Headers:**

```bash
Authorization: Bearer your_api_key_here
```

**Example Request:**

```bash
curl -H "Authorization: Bearer your_api_key_here" \
    https://nextblog.ai/api/blog/project_123
```

**Response:**

```json
{
  "project": {
    "id": "project_123",
    "name": "My Blog"
  },
  "blogs": [
    {
      "id": "blog_456",
      "title": "How to Optimize Your Website",
      "slug": "how-to-optimize-website",
      "description": "Learn the best practices for website optimization...",
      "cover_image_url": "https://example.com/image.jpg",
      "cover_image_alt": "How to Optimize Your Website",
      "published": true,
      "created_at": "2024-01-01T00:00:00Z",
      "updated_at": "2024-01-01T00:00:00Z"
    }
  ]
}
```

#### Get Single Blog Post

**Endpoint:** `GET /api/blog/{projectId}/{slug}`

**Description:** Retrieves a specific blog post with full content using the post's slug.

**Headers:**

```bash
Authorization: Bearer your_api_key_here
```

**Example Request:**

```bash
curl -H "Authorization: Bearer your_api_key_here" \
    https://nextblog.ai/api/blog/project_123/how-to-optimize-website
```

**Response:**

```json
{
  "project": {
    "id": "project_123",
    "name": "My Blog"
  },
  "blog": {
    "id": "blog_456",
    "title": "How to Optimize Your Website",
    "slug": "how-to-optimize-website",
    "description": "Learn the best practices for website optimization...",
    "markdown": "# How to Optimize Your Website\n\nThis is the full blog post content in markdown format...",
    "cover_image_url": "https://example.com/image.jpg",
    "published": true,
    "created_at": "2024-01-01T00:00:00Z",
    "updated_at": "2024-01-01T00:00:00Z"
  }
}
```

### Error Responses

The API returns standard HTTP status codes and error messages:

- **400 Bad Request:** Missing required parameters
- **401 Unauthorized:** Invalid or missing API key
- **404 Not Found:** Project or blog post not found
- **429 Too Many Requests:** Rate limit exceeded
- **500 Internal Server Error:** Server error

### Rate Limits

Requests are limited to **120 per minute and 1,000 per hour per credential** (shared with the [Full REST API](/docs/api-v1.md) and the [MCP Server](/docs/mcp.md)). Exceeding a limit returns `429` with a `Retry-After` header and `X-RateLimit-*` headers. See [Full REST API → Rate limits](/docs/api-v1.md#rate-limits) for the exact headers and the stricter generation limits.
