Hive API

Workspace Stats

Get statistics about your Hive workspace

The Stats API provides aggregate statistics about your workspace. Use this to display counters, dashboard metrics, or workspace overview information.

Endpoint

GET https://api.hivecms.online/api/public/{API_KEY}/stats

Example Request

curl "https://api.hivecms.online/api/public/{API_KEY}/stats"

Example Response

{
  "totalPosts": 42,
  "totalAuthors": 5,
  "totalCategories": 6,
  "totalTags": 18
}

Response Fields

The stats object contains:

  • totalPosts (number): Total number of published posts
  • totalAuthors (number): Total number of authors in the workspace
  • totalCategories (number): Total number of categories
  • totalTags (number): Total number of tags

Use Cases

  • Dashboard Counters: Display workspace metrics on a dashboard
  • Landing Page Stats: Show impressive numbers on a marketing page
  • Workspace Overview: Provide a quick summary of content volume
  • Analytics: Track content growth over time

Example Usage

Displaying Stats on a Dashboard

// Fetch stats
const response = await fetch(
  'https://api.hivecms.online/api/public/{API_KEY}/stats'
);
const stats = await response.json();

// Display metrics
console.log(`Total Posts: ${stats.totalPosts}`);
console.log(`Total Authors: ${stats.totalAuthors}`);
console.log(`Total Categories: ${stats.totalCategories}`);
console.log(`Total Tags: ${stats.totalTags}`);

Building a Stats Component

// React example
function WorkspaceStats() {
  const [stats, setStats] = useState(null);

  useEffect(() => {
    fetch('https://api.hivecms.online/api/public/{API_KEY}/stats')
      .then(res => res.json())
      .then(setStats);
  }, []);

  if (!stats) return <div>Loading...</div>;

  return (
    <div className="stats-grid">
      <div className="stat">
        <h3>{stats.totalPosts}</h3>
        <p>Posts Published</p>
      </div>
      <div className="stat">
        <h3>{stats.totalAuthors}</h3>
        <p>Authors</p>
      </div>
      <div className="stat">
        <h3>{stats.totalCategories}</h3>
        <p>Categories</p>
      </div>
      <div className="stat">
        <h3>{stats.totalTags}</h3>
        <p>Tags</p>
      </div>
    </div>
  );
}
  • Posts - Get detailed post information
  • Authors - Get author details
  • Categories - Get category information
  • Tags - Get tag information