Introduction

This API provides endpoints for managing a blog system with an admin panel. The API supports user authentication, blog post management, category organization, and contact form submissions.

Base URL

http://localhost:5000/api

Authentication

Most endpoints require JWT authentication. Include the token in the Authorization header:

Authorization: Bearer your-token-here

Authentication

POST

/auth/register

Public

Register a new user account.

Request Body

{
  "username": "john_doe",
  "email": "john@example.com",
  "password": "secure_password123"
}

Response (201)

{
  "message": "User registered successfully"
}
POST

/auth/login

Public

Authenticate user and get access token.

Request Body

{
  "email": "john@example.com",
  "password": "secure_password123"
}

Response (200)

{
  "message": "Login successful",
  "token": "eyJhbGciOiJIUzI1...",
  "user": {
    "id": 1,
    "email": "john@example.com",
    "username": "john_doe"
  }
}

Categories

GET

/category/list

Public

Get list of all categories.

Response (200)

{
  "message": "Categories retrieved successfully",
  "data": [
    {
      "id": 1,
      "name": "Technology",
      "type": "blog",
      "featured_post_id": null,
      "created_at": "2024-01-01 12:00:00"
    }
  ]
}
POST

/category/create

Requires Auth

Create a new category.

Request Body

{
  "name": "Technology",
  "type": "blog"
}

Response (201)

{
  "message": "Category created successfully",
  "id": 1
}

Users

GET

/user/profile

Requires Auth

Get the current user's profile information.

Response (200)

{
  "message": "Profile retrieved successfully",
  "data": {
    "id": 1,
    "username": "john_doe",
    "email": "john@example.com",
    "created_at": "2024-01-01 12:00:00"
  }
}

Posts

GET

/post/list

Public

Get list of blog posts with pagination and filters.

Query Parameters

  • page (optional) - Page number (default: 1)
  • limit (optional) - Items per page (default: 10)
  • category (optional) - Filter by category ID
  • status (optional) - Filter by status (draft/published/archived)

Response (200)

{
  "message": "Posts retrieved successfully",
  "data": [
    {
      "id": 1,
      "title": "Sample Post",
      "subtitle": "A brief introduction",
      "content": "Post content here...",
      "status": "published",
      "category_id": 1,
      "category_name": "Technology",
      "author_id": 1,
      "author_name": "john_doe",
      "read_time": 5,
      "tags": ["tech", "intro"],
      "created_at": "2024-01-01 12:00:00"
    }
  ],
  "pagination": {
    "total": 10,
    "page": 1,
    "limit": 10,
    "total_pages": 1
  }
}
POST

/post/create

Requires Auth

Create a new blog post.

Request Body

{
  "title": "My New Post",
  "subtitle": "An interesting subtitle",
  "content": "Post content here...",
  "category_id": 1,
  "status": "draft",
  "tags": ["tech", "tutorial"]
}

Response (201)

{
  "message": "Post created successfully",
  "id": 1
}
PUT

/post/update

Requires Auth

Update an existing blog post.

Request Body

{
  "id": 1,
  "title": "Updated Title",
  "content": "Updated content...",
  "status": "published"
}

Response (200)

{
  "message": "Post updated successfully",
  "id": 1
}
DELETE

/post/delete

Requires Auth

Delete a blog post.

Request Body

{
  "id": 1
}

Response (200)

{
  "message": "Post deleted successfully",
  "id": 1
}

Contact

POST

/contact/create

Public

Submit a contact form message.

Request Body

{
  "name": "John Doe",
  "email": "john@example.com",
  "message": "Hello, I have a question..."
}

Response (201)

{
  "message": "Message sent successfully",
  "id": 1
}
GET

/contact/list

Requires Auth

Get list of contact form submissions (Admin only).

Query Parameters

  • page (optional) - Page number (default: 1)
  • limit (optional) - Items per page (default: 10)
  • status (optional) - Filter by status (new/read/replied)

Response (200)

{
  "message": "Messages retrieved successfully",
  "data": [
    {
      "id": 1,
      "name": "John Doe",
      "email": "john@example.com",
      "message": "Hello, I have a question...",
      "status": "new",
      "created_at": "2024-01-01 12:00:00"
    }
  ],
  "pagination": {
    "total": 1,
    "page": 1,
    "limit": 10,
    "total_pages": 1
  }
}