📚 Blog CMS API Documentation

REST API for the Lemmy-authenticated blog CMS

Version 1.0.0

Overview

Base URL: https://b.afsapp.lol/.netlify/functions

Format: JSON

Authentication: Bearer Token (JWT)

This API allows you to manage blog posts with Lemmy authentication. All requests and responses use JSON format.

Authentication

Most endpoints require authentication using a Bearer token obtained from the login endpoint.

Header Format: Authorization: Bearer <your_token>

POST /api-auth-login

Login with Lemmy credentials to obtain an access token.

Request Body

Field Type Description
instance string Lemmy instance domain (e.g., "lemmy.ml")
username string Your Lemmy username
password string Your Lemmy password

Response

200 Login successful - returns access_token and user profile
401 Invalid credentials
400 Missing required fields

Example Response

{ "success": true, "data": { "access_token": "eyJhbGciOiJIUzI1NiIs...", "token_type": "Bearer", "expires_in": 86400, "user": { "username": "johndoe", "instance": "lemmy.ml", "display_name": "John Doe" } } }
GET /api-auth-me 🔐 Auth Required

Get current user information and session details.

Response

200 User information retrieved successfully
401 Invalid or expired token

Posts

Endpoints for managing blog posts.

GET /api-posts-db

List all published posts with pagination and filtering.

Query Parameters

Parameter Type Description
page number Page number (default: 1)
limit number Posts per page (default: 10, max: 50)
search string Search in title and description
tag string Filter by tag
author string Filter by author
GET /api-posts-slug-db?slug={slug}

Get a specific post by its slug.

Query Parameters

Parameter Type Description
slug string The post slug identifier
POST /api-posts-db 🔐 Auth Required

Create a new blog post.

Request Body

Field Type Description
title string Post title (required)
content string Post content in Markdown (required)
description string Brief description (optional)
tags array/string Tags for categorization (optional)
isDraft boolean Save as draft (default: false)
PUT /api-posts-slug-db?slug={slug} 🔐 Auth Required

Update an existing post. Only the author can update their own posts.

DELETE /api-posts-slug-db?slug={slug} 🔐 Auth Required

Delete a post. Only the author can delete their own posts.

User

Endpoints for user profile and statistics.

GET /api-user-profile 🔐 Auth Required

Get user profile with blog statistics.

GET /api-user-posts 🔐 Auth Required

Get all posts by the authenticated user.

Examples

Login Example

curl -X POST https://your-site.netlify.app/.netlify/functions/api-auth-login \ -H "Content-Type: application/json" \ -d '{ "instance": "lemmy.ml", "username": "your_username", "password": "your_password" }'
const response = await fetch('/.netlify/functions/api-auth-login', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ instance: 'lemmy.ml', username: 'your_username', password: 'your_password' }) }); const data = await response.json(); const token = data.data.access_token;

Create Post Example

curl -X POST https://your-site.netlify.app/.netlify/functions/api-posts-db \ -H "Content-Type: application/json" \ -H "Authorization: Bearer YOUR_TOKEN" \ -d '{ "title": "My New Post", "content": "# Hello World\n\nThis is my blog post content...", "description": "A sample blog post", "tags": ["tutorial", "api"], "isDraft": false }'
const response = await fetch('/.netlify/functions/api-posts-db', { method: 'POST', headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${token}` }, body: JSON.stringify({ title: 'My New Post', content: '# Hello World\n\nThis is my blog post content...', description: 'A sample blog post', tags: ['tutorial', 'api'], isDraft: false }) }); const result = await response.json(); console.log('Post created:', result);

Rate Limits

Authenticated requests: 100 requests per hour

Unauthenticated requests: 20 requests per hour

Rate limit headers are included in all responses.