Skip to main content

Overview

The Posts Statistics API provides powerful analytics endpoints to track post performance, identify trending content, and understand audience engagement. Get the most viewed posts.
export async function getPostsPopulares(limit: number = 10): Promise<Post[]>

Parameters

limit
number
default:"10"
Number of posts to return (max 100)

Response

Returns an array of Post objects sorted by view count (descending).
[
  {
    "id": 45,
    "title": "10 Marketing Strategies That Actually Work",
    "slug": "10-marketing-strategies-that-work",
    "views": 5247,
    "likes": 312,
    "comments": 89,
    "shares": 156
  }
]

Get posts that are currently trending based on recent engagement.
export async function getPostsTrending(limit: number = 10): Promise<Post[]>

Parameters

limit
number
default:"10"
Number of trending posts to return

Response

Returns an array of Post objects sorted by trending score (considers recent views, likes, and shares).
Trending algorithm weighs recent engagement more heavily than total engagement, helping surface timely content.

Posts with Engagement

Get posts with detailed engagement metrics.
export async function getPostsConEngagement(limit: number = 20): Promise<Post[]>

Parameters

limit
number
default:"20"
Number of posts to return

Response

Returns posts with all engagement metrics populated (views, likes, comments, shares).

Most Shared Posts

Get posts with the highest share counts.
export async function getPostsMasCompartidos(limit: number = 10): Promise<Post[]>

Parameters

limit
number
default:"10"
Number of posts to return

Response

Returns an array of Post objects sorted by share count (descending).

Posts Without Comments

Find posts that haven’t received any comments.
export async function getPostsSinComentarios(): Promise<Post[]>

Response

Returns an array of Post objects with comments equal to 0.
Use this endpoint to identify content that needs more promotion or engagement tactics.

Old Drafts

Find draft posts that haven’t been updated recently.
export async function getBorradoresAntiguos(): Promise<Post[]>

Response

Returns an array of draft Post objects that haven’t been updated in a defined period (typically 30+ days).

Dashboard Overview

Get summary statistics for the dashboard.
export async function getDashboardOverview(): Promise<any>

Response

totalPosts
number
Total number of posts
published
number
Number of published posts
draft
number
Number of draft posts
pending
number
Number of posts pending review
rejected
number
Number of rejected posts
totalViews
number
Sum of all post views
totalLikes
number
Sum of all post likes
totalComments
number
Sum of all post comments
totalShares
number
Sum of all post shares
totalEngagement
number
Combined engagement metric (likes + comments + shares)

Statistics by Month

Get monthly statistics for trend analysis.
export async function getEstadisticasPorMes(meses: number = 12): Promise<any>

Parameters

meses
number
default:"12"
Number of months of data to retrieve

Response

{
  "data": [
    {
      "month": "2024-01",
      "postsPublished": 24,
      "totalViews": 15420,
      "totalLikes": 892,
      "totalComments": 234,
      "totalShares": 156,
      "avgReadTime": 8.5
    }
  ]
}

Best Performing Posts by Author

Get top performing posts for a specific author.
export async function getMejorRendimientoPorAutor(
  autorId: number,
  limit: number = 5
): Promise<Post[]>

Parameters

autorId
number
required
User ID of the author
limit
number
default:"5"
Number of top posts to return

Response

Returns an array of the author’s best performing Post objects, sorted by engagement metrics.

Analytics Best Practices

Use the incrementarVista endpoint (see Interactions) to track each page view. Include userId when available and ipAddress to prevent duplicate counting.
Engagement rate = (likes + comments + shares) / views × 100A good engagement rate is typically 2-5% for blog content.
Regularly check:
  • Posts without comments (engagement opportunities)
  • Old drafts (content pipeline bottlenecks)
  • Monthly trends (growth trajectory)

Example: Analytics Dashboard

Here’s how to build a comprehensive analytics dashboard:
async function buildAnalyticsDashboard() {
  // Fetch all analytics data in parallel
  const [
    overview,
    popular,
    trending,
    monthlyStats,
    noComments
  ] = await Promise.all([
    getDashboardOverview(),
    getPostsPopulares(5),
    getPostsTrending(5),
    getEstadisticasPorMes(6),
    getPostsSinComentarios()
  ]);

  return {
    overview: {
      totalPosts: overview.totalPosts,
      avgEngagementRate: (
        (overview.totalLikes + overview.totalComments) / 
        overview.totalViews * 100
      ).toFixed(2),
      postsNeedingAttention: noComments.length
    },
    topContent: {
      popular: popular.map(p => ({
        title: p.title,
        views: p.views,
        url: `/posts/${p.slug}`
      })),
      trending: trending.map(p => ({
        title: p.title,
        views: p.views,
        url: `/posts/${p.slug}`
      }))
    },
    trends: monthlyStats.data,
    actionItems: noComments.map(p => ({
      postId: p.id,
      title: p.title,
      issue: 'No comments - needs engagement'
    }))
  };
}

Build docs developers (and LLMs) love