Back to Documentation
API Reference
Get Single Post
Retrieve a single blog post by its slug, including full HTML content.
GET
client.getPost(slug)import { LightweightClient } from 'lightweight-client';
async function getPost(slug: string) {
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.getPost(slug);
}Parameters
slug
string
required
The URL-friendly identifier of the post (e.g., "getting-started-with-nextjs").
Response
{
"id": "abc123",
"slug": "getting-started-with-nextjs",
"headline": "Getting Started with Next.js",
"metaDescription": "Learn how to build modern web apps with Next.js",
"publishedAt": "2024-01-15T10:30:00.000Z",
"createdAt": "2024-01-14T08:00:00.000Z",
"updatedAt": "2024-01-15T10:30:00.000Z",
"readingTime": 5,
"image": "https://images.lightweight.so/...",
"html": "<article>...</article>",
"category": {
"title": "Development",
"slug": "development"
},
"tags": [],
"relatedPosts": [],
"author": {
"name": "John Doe",
"title": "Senior Developer",
"image": "https://..."
},
"navigationMenu": [
{ "id": "introduction", "text": "Introduction", "level": 1 },
{ "id": "setup", "text": "Setup", "level": 2 }
]
}Response Schema
idstringUnique identifier for the post
slugstringURL-friendly version of the headline
headlinestringThe main title of the blog post
htmlstringClean, semantic HTML content ready to render. Includes proper heading tags, lists, blockquotes, code blocks, and images.
publishedAtstring (ISO 8601)Timestamp when the post was published
imagestringURL of the featured image
categoryobjectCategory information with title and slug
authorobject | nullAuthor details including name, title, and image
navigationMenuarrayTable of contents with heading IDs and levels
Notes
- •Returns
nullif the post is not found or not published - •The
htmlfield contains clean, semantic HTML that you can render directly - •Use the
navigationMenuto build a table of contents sidebar - •You are responsible for styling the HTML (headings, paragraphs, lists, code blocks, etc.)