API Documentation

StarLaker's REST API lets you publish, fetch, and manage content programmatically. Base URL: https://starlaker.com/api/v1

Authentication

Protected endpoints require a Bearer token in the Authorization header:

Authorization: Bearer sl_live_YOUR_API_KEY

Generate API keys from Dashboard → API Keys. Keys are prefixed with sl_live_.

Endpoints

GET/api/v1/posts

Fetch published articles with optional tag filtering and pagination.

Query Parameters:

ParamTypeDefaultDescription
tagstringFilter by tag
limitnumber20Results per page (max 100)
offsetnumber0Pagination offset

Example:

curl https://starlaker.com/api/v1/posts?tag=AI&limit=5
GET/api/v1/posts/:slug

Fetch a single published article by its URL slug.

Example:

curl https://starlaker.com/api/v1/posts/hello-world
POST/api/v1/posts

Create a new post. Requires Bearer token authentication.

Request Body (JSON):

FieldTypeRequired
titlestring
contentstring (markdown)
tagsstring[]
excerptstring
statusdraft | publisheddefault: draft
cover_imagestring (URL)
slugstringauto-generated

Example:

curl -X POST https://starlaker.com/api/v1/posts \
  -H "Authorization: Bearer sl_live_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "title": "Hello World",
    "content": "# My First Post\n\nThis is **bold**.",
    "tags": ["tech", "intro"],
    "status": "published"
  }'
GET/api/v1/posts/:slug/comments

Fetch all comments for a post.

Example:

curl https://starlaker.com/api/v1/posts/hello-world/comments
POST/api/v1/posts/:slug/comments

Add a comment to a post. No authentication required.

Request Body (JSON):

FieldTypeRequired
author_namestring
author_emailstring
bodystring
curl -X POST https://starlaker.com/api/v1/posts/hello-world/comments \
  -H "Content-Type: application/json" \
  -d '{
    "author_name": "Jane",
    "author_email": "jane@example.com",
    "body": "Great article!"
  }'
POST/api/v1/keys/generate

Generate a new API key. The raw key is returned ONCE — store it safely.

Request Body (JSON):

FieldTypeRequired
namestring
company_idstring
curl -X POST https://starlaker.com/api/v1/keys/generate \
  -H "Content-Type: application/json" \
  -d '{"name":"VS Code","company_id":"YOUR_COMPANY_ID"}'
POST/api/v1/views/track

Track a page view for analytics. Called automatically by the frontend.

curl -X POST https://starlaker.com/api/v1/views/track \
  -H "Content-Type: application/json" \
  -d '{"postId":"POST_ID"}'

Response Format

All endpoints return JSON:

{
  "success": true,
  "data": { ... },
  "pagination": { "total": 50, "limit": 20, "offset": 0, "hasMore": true }
}

Rate Limiting

Rate limiting is applied per API key. If you exceed the limit, you'll receive a429 Too Many Requests response. Contact us for higher limits.