Skip to content

Refactor and implement RESTful Blog Management APIs (v2 style) #278

@GorillaGigabytes

Description

@GorillaGigabytes

Feature Request:
Refactor existing blog-related APIs and add new endpoints to follow a RESTful, organized structure as described below. This will improve maintainability, scalability, and clarity of the API design for blog management, user-specific blogs, categories, tags, posts, analytics, and admin operations.

Recommended API Structure:

Blog Management APIs (v2)

/api/v2/blogs
├── GET / # Get all public blogs (paginated)
├── POST / # Create new blog (draft)
├── GET /search?q={query} # Search blogs
├── POST /search/advanced # Advanced search with filters
├── GET /trending # Get trending blogs
├── GET /latest # Get latest blogs
├── GET /featured # Get featured blogs
├── GET /{blog_id} # Get specific blog (public)
├── PUT /{blog_id} # Update blog (full)
├── PATCH /{blog_id} # Partial update blog
├── DELETE /{blog_id} # Delete blog
├── POST /{blog_id}/publish # Publish blog
├── POST /{blog_id}/unpublish # Unpublish blog (move to draft)
├── POST /{blog_id}/archive # Archive blog
├── POST /{blog_id}/restore # Restore archived blog
├── GET /{blog_id}/versions # Get blog version history
├── POST /{blog_id}/clone # Clone blog as draft
├── GET /{blog_id}/analytics # Get blog analytics
├── GET /{blog_id}/collaborators # Get blog collaborators
├── POST /{blog_id}/collaborators # Add collaborator
├── DELETE /{blog_id}/collaborators/{user_id} # Remove collaborator

User-specific Blog APIs

/api/v2/users/{user_id}/blogs
├── GET / # Get user's public blogs
├── GET /drafts # Get user's draft blogs (private)
├── GET /published # Get user's published blogs
├── GET /archived # Get user's archived blogs
├── GET /collaborations # Get blogs user collaborates on

Current User Blog APIs

/api/v2/me/blogs
├── GET / # Get my blogs (all statuses)
├── GET /drafts # Get my draft blogs
├── GET /published # Get my published blogs
├── GET /archived # Get my archived blogs
├── GET /collaborations # Get blogs I collaborate on
├── GET /bookmarks # Get my bookmarked blogs
├── POST /bookmarks/{blog_id} # Bookmark a blog
├── DELETE /bookmarks/{blog_id} # Remove bookmark
├── GET /feed # Get personalized feed
├── GET /following-feed # Get feed from followed users

Category and Tag Management

/api/v2/categories
├── GET / # Get all categories
├── GET /{category}/blogs # Get blogs by category
├── GET /{category}/blogs/trending # Get trending blogs in category

/api/v2/tags
├── GET / # Get popular tags
├── GET /{tag}/blogs # Get blogs by tag
├── POST /blogs # Get blogs by multiple tags (body: {tags: []})

News/Posts Section APIs

/api/v2/posts
├── GET /latest # Latest across all categories
├── GET /trending # Trending posts
├── GET /categories/{category} # Posts by category
├── GET /sections # Get all available sections
├── POST /sections/mixed # Get mixed posts from multiple sections

Analytics and Metrics

/api/v2/blogs/{blog_id}/metrics
├── GET /views # View analytics
├── GET /engagement # Engagement metrics
├── GET /demographics # Reader demographics

Admin APIs

/api/v2/admin/blogs
├── GET / # Get all blogs (admin view)
├── GET /reported # Get reported blogs
├── POST /{blog_id}/feature # Feature a blog
├── DELETE /{blog_id}/feature # Unfeature a blog
├── POST /{blog_id}/moderate # Moderate blog content

Tasks:

  • Refactor current blog APIs to match this structure (versioned under /api/v2/)
  • Implement missing endpoints as described
  • Ensure consistency, security, and documentation
  • Add pagination, filtering, and advanced search where relevant
  • Test endpoints with various scenarios

Benefits:

  • Cleaner and more predictable API design
  • Easier integration for frontend and third-party developers
  • Scalability for future features

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions