LxBlog
/Docs

Quick Start

4. Fetch Articles

Fetch Articles

With an access token in hand, you can now make authenticated requests to the LxBlog API. Include the token in the Authorization header of every request:

Authorization: Bearer lxb_at_xxxxxxxxxxxxxxxxxxxxxxxxxxxx

List Articles

GET/api/v1/articles?page=1&limit=20

Retrieve a paginated list of published articles for the authorized blog.

fetch-articles.js
const response = await fetch('https://lxblog.app/api/v1/articles?page=1&limit=20', {
  headers: {
    'Authorization': `Bearer ${accessToken}`,
  },
});

const data = await response.json();
console.log(data);

Response

The endpoint returns an array of articles along with pagination metadata:

response.json
{
  "articles": [
    {
      "id": "art_abc123",
      "slug": "getting-started-with-nextjs",
      "title": "Getting Started with Next.js",
      "description": "A beginner-friendly guide to building apps with Next.js",
      "content": "# Getting Started with Next.js\n\nNext.js is a React framework...",
      "coverImageUrl": "https://cdn.lxblog.app/images/cover-nextjs.jpg",
      "tags": ["nextjs", "react", "tutorial"],
      "publishedAt": "2025-12-15T10:30:00.000Z",
      "contentHash": "a1b2c3d4e5f6..."
    }
  ],
  "pagination": {
    "page": 1,
    "limit": 20,
    "total": 42,
    "totalPages": 3
  }
}

Fetch a Single Article

To retrieve a specific article, use its ID or slug:

GET/api/v1/articles/{idOrSlug}

Retrieve a single article by its ID or URL slug.

fetch-single-article.js
// Fetch by slug
const response = await fetch(
  'https://lxblog.app/api/v1/articles/getting-started-with-nextjs',
  {
    headers: {
      'Authorization': `Bearer ${accessToken}`,
    },
  }
);

const article = await response.json();
console.log(article.title);   // "Getting Started with Next.js"
console.log(article.content);  // Markdown content

Use the contentHash field to efficiently detect changes without comparing full article content. Store the hash alongside your local copy and compare it on subsequent fetches to determine if the article has been updated.

Next Steps

Now that you can fetch articles from the LxBlog API, explore these features to build a more robust integration:

  • Sync endpoint — efficiently synchronize content by fetching only articles that have changed since your last sync.
  • MCP server — connect AI assistants to your blog content via the Model Context Protocol.