Back to Documentation
API Reference

Get Single Post

Retrieve a single blog post by its slug with full content and metadata.

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 slug identifier of the post to retrieve.

Response

{
  "id": string,                      // Unique identifier (UUID)
  "slug": string,                    // URL-friendly post identifier
  "headline": string,                // Post title
  "metaDescription": string,         // SEO meta description
  "publishedAt": string,             // ISO 8601 timestamp
  "createdAt": string,               // ISO 8601 timestamp
  "readingTime": number,             // Estimated reading time in minutes
  "image": string,                   // Featured image URL
  "html": string,                    // Full post content as HTML
  "category": {
    "title": string,                 // Category display name
    "slug": string                   // Category URL identifier
  },
  "tags": string[],                  // Array of tag strings
  "relatedPosts": array,             // Array of related post objects
  "heroSection": string,             // Pre-rendered HTML for hero section
  "author": {
    "name": string,                  // Author's display name
    "title": string,                 // Author's title/role
    "image": string                  // Author's avatar URL
  },
  "navigationMenu": [
    {
      "id": string,                  // Section anchor ID
      "text": string,                // Section heading text
      "level": number                // Heading level (1-6)
    },
    // ... more navigation items
  ]
}

Response Schema

idstring

Unique identifier for the post

slugstring

URL-friendly version of the headline

headlinestring

The main title of the blog post

htmlstring

The complete HTML content of the post, ready for rendering

publishedAtstring (ISO 8601)

Timestamp when the post was published

readingTimenumber

Estimated reading time in minutes

imagestring

URL of the featured image

categoryobject

Category information with title and slug

authorobject

Author details including name, title, and image

navigationMenuarray

Table of contents with section IDs, text, and heading levels for navigation

Notes
  • The html field contains the complete rendered HTML content, including headings with IDs for navigation
  • The heroSection field contains pre-rendered HTML for the post header/hero area
  • Navigation menu items correspond to headings in the HTML content and include the heading level (1-6)
  • If a post is not found, the API returns a 404 error with an appropriate error message
  • Images in the HTML content are already optimized and served from CDN