The Articles API provides methods to fetch, filter, search, and list articles from your Simplist project.
| Method | Description | Returns |
|---|---|---|
| List articles with pagination and filters | ArticleListItem[] | |
| Get a single article by slug | Article | |
| Search articles by query | ArticleListItem[] | |
| Get only published articles | ArticleListItem[] | |
| Get latest articles | ArticleListItem[] | |
| Get popular articles | ArticleListItem[] | |
| Generate RSS feed XML | string |
Fetch a complete article by its unique slug, including full content.
get-article.tsimport { SimplistClient } from "@simplist.blog/sdk"
// Uses SIMPLIST_API_KEY from environment variables
const client = new SimplistClient()
const response = await client.articles.get('my-article-slug')
if (response.data) {
const article = response.data
console.log(article.title)
console.log(article.content)
console.log(article.author.name)
console.log(`${article.readTimeMinutes} min read`)
}| Property | Type | Description | Default |
|---|---|---|---|
id* | string | Unique article ID | - |
title* | string | Article title | - |
slug* | string | URL-friendly identifier | - |
content* | string | Full article content in Markdown | - |
excerpt | string | null | Short summary | - |
coverImage | string | null | Cover image URL | - |
published* | boolean | Publication status | - |
status* | string | Current status | - |
viewCount* | number | Total views | - |
wordCount* | number | Word count | - |
characterCount* | number | Character count | - |
lineCount* | number | Line count | - |
readTimeMinutes* | number | Estimated reading time | - |
author* | Author | Author information | - |
lastUpdatedBy | Author | null | Last editor | - |
createdAt* | string | Creation timestamp (ISO 8601) | - |
updatedAt* | string | Last update timestamp | - |
publishedAt | string | null | Publication timestamp | - |
variants | Record<LanguageCode, ArticleVariant> | Multilingual variants | - |
Fetch multiple articles with pagination, sorting, and filtering.
list-articles.tsconst response = await client.articles.list({
page: 1,
limit: 20,
sort: 'createdAt',
order: 'desc',
published: true
})
if (response.data) {
const articles = response.data
const { page, limit, total, totalPages } = response.meta
console.log(`Page ${page} of ${totalPages}`)
console.log(`Showing ${articles.length} of ${total} articles`)
}| Property | Type | Description | Default |
|---|---|---|---|
page | number | Page number for pagination | 1 |
limit | number | Items per page | 10 |
sort | 'createdAt' | 'updatedAt' | 'title' | Field to sort by | 'createdAt' |
order | 'asc' | 'desc' | Sort order | 'desc' |
published | boolean | Filter by publication status | - |
status | 'draft' | 'published' | Filter by specific status | - |
search | string | Search query | - |
List methods return a meta object with pagination information:
pagination.ts{
page: 1, // Current page
limit: 20, // Items per page
total: 157, // Total items
totalPages: 8 // Total pages
}Get the most recent published articles.
latest.ts// Get 10 latest articles
const response = await client.articles.latest(10)
// Custom limit
const response = await client.articles.latest(25)This method automatically:
- Filters to published articles only
- Sorts by creation date (newest first)
- Applies the specified limit
Fetch only published articles with custom filters.
published.tsconst response = await client.articles.published({
page: 1,
limit: 20,
sort: 'title',
order: 'asc'
})
// All parameters are optional
const response = await client.articles.published()This method is equivalent to list() with published: true.
Get the most viewed articles.
popular.ts// Get 10 most popular articles
const response = await client.articles.popular(10)
// Custom limit
const response = await client.articles.popular(20)Note: This currently returns published articles. Sorting by view count may be added in a future API update.
Search articles by title, content, or excerpt.
search.ts// Simple search
const results = await client.articles.search('React hooks')
// Search with filters
const results = await client.articles.search('React hooks', {
page: 1,
limit: 10,
sort: 'createdAt',
order: 'desc'
})The search query matches against:
- Article title
- Article excerpt
- Article content
Create an RSS 2.0 XML feed from your articles.
rss.tsconst xml = await client.articles.rss({
hostname: 'https://myblog.com',
title: 'My Blog',
description: 'Latest articles from my blog',
limit: 50
})
// In Next.js API route
export async function GET() {
const xml = await client.articles.rss({
hostname: process.env.NEXT_PUBLIC_URL
})
return new Response(xml, {
headers: {
'Content-Type': 'application/xml',
'Cache-Control': 'public, max-age=3600'
}
})
}| Property | Type | Description | Default |
|---|---|---|---|
hostname* | string | Base URL for article links | - |
title | string | Feed title | "Blog Feed" |
description | string | Feed description | "Latest articles" |
limit | number | Max articles | 50 |
All methods return an ApiResponse<T> with error handling built in.
error-handling.tstry {
const response = await client.articles.get('article-slug')
if (response.data) {
console.log(response.data.title)
}
} catch (error) {
if (error instanceof SimplistApiError) {
console.error(`API Error [${error.statusCode}]: ${error.message}`)
} else {
console.error('Unexpected error:', error)
}
}| Status | Error | Solution |
|---|---|---|
| 404 | Article not found | Check the slug is correct |
| 401 | Unauthorized | Verify your API key |
| 403 | Forbidden | Check API key permissions |
| 429 | Rate limit exceeded | Wait before retrying |
| 500 | Server error | Retry with exponential backoff |
complete-example.tsimport { SimplistClient } from "@simplist.blog/sdk"
const client = new SimplistClient({
apiKey: process.env.SIMPLIST_API_KEY
})
// Fetch latest articles for homepage
async function getHomepageArticles() {
const response = await client.articles.latest(6)
return response.data || []
}
// Fetch article for blog post page
async function getArticle(slug: string) {
const response = await client.articles.get(slug)
if (!response.data) {
return null
}
return response.data
}
// Paginated article list
async function getArticlePage(page: number = 1) {
const response = await client.articles.published({
page,
limit: 12,
sort: 'publishedAt',
order: 'desc'
})
return {
articles: response.data || [],
pagination: response.meta
}
}
// Search functionality
async function searchArticles(query: string) {
if (!query.trim()) {
return []
}
const response = await client.articles.search(query, {
limit: 20
})
return response.data || []
}Analytics
Track page views and engagement
Multilingual Support
Handle translated content
SEO Utilities
Generate sitemaps and meta tags