Back to Documentation
API Reference
Get All Posts
Retrieve a paginated list of all published blog posts.
GET
client.getPosts(page, limit)
import { LightweightClient } from 'lightweight-client';
async function getPosts(page: number) {
const key = process.env.LIGHTWEIGHT_API_KEY;
if (!key) throw Error('LIGHTWEIGHT_API_KEY environment variable must be set');
const client = new LightweightClient(key);
return client.getPosts(page, 10);
}
Parameters
page
number
required
The page number to retrieve. Starts from 1.
limit
number
optional
Number of posts to retrieve per page. Default is 10, maximum is 50.
Response
[
{
"id": "82c68fd5-48e9-48d8-ac50-a3272150e5c8",
"slug": "testing-functionality-in-real-world",
"headline": "Hello world",
"metaDescription": "Learn about testing functionality in real world scenarios",
"publishedAt": "2025-09-15T16:48:06.448Z",
"createdAt": "2025-09-15T16:48:06.563Z",
"readingTime": 1,
"image": "https://seoai-blog.s3.amazonaws.com/...",
"category": {
"title": "Tech",
"slug": "tech"
},
"tags": [],
"relatedPosts": [],
"heroSection": "<!-- HTML content for hero section -->",
"author": {
"name": "Jack Friks",
"title": "Founder",
"image": "https://seoai-blog.s3.amazonaws.com/..."
},
"navigationMenu": [
{
"id": "section-1",
"title": "Introduction",
"level": 1
}
]
},
{
"id": "c9609bf0-3a6a-4849-a18a-bd2fed8f9c0e",
"slug": "test-as-contributor",
"headline": "Test as Contributor",
"metaDescription": "Testing the contributor functionality",
"publishedAt": "2025-09-13T13:28:42.796Z",
"createdAt": "2025-09-13T13:28:42.901Z",
"readingTime": 1,
"image": "https://seoai-blog.s3.amazonaws.com/...",
"category": {
"title": "Testing",
"slug": "testing"
},
"tags": [],
"relatedPosts": [],
"heroSection": "<!-- HTML content for hero section -->",
"author": {
"name": "Jack Friks",
"title": "Founder",
"image": "https://seoai-blog.s3.amazonaws.com/..."
},
"navigationMenu": []
}
]
Response Schema
id
stringUnique identifier for the post
slug
stringURL-friendly version of the headline
headline
stringThe main title of the blog post
publishedAt
string (ISO 8601)Timestamp when the post was published
image
stringURL of the featured image
category
objectCategory information with title and slug
author
objectAuthor details including name, title, and image
navigationMenu
arrayTable of contents for the post
Notes
- •The response includes a
heroSection
field containing pre-rendered HTML for the post header - •Posts are returned in descending order by publication date (newest first)
- •Empty arrays are returned for
tags
,relatedPosts
, andnavigationMenu
if not set