GET /api/content/{slug}

Retrieve the full content and metadata of a specific page.

Description

This endpoint returns the complete content of any page in the CMS, including:

  • Full markdown/HTML content
  • Frontmatter metadata
  • Processing settings
  • Taxonomy information

This is the core of the headless CMS functionality - content is separated from presentation.

Request

GET https://api.infinity.b0x.store/api/content/{slug}.json

Parameters

Parameter Type Required Description
slug string Yes The page slug or route path

Response Format

Success (200 OK)

{
  "route": "/api",
  "title": "GROOV API - Self-Documenting Grav CMS",
  "slug": "api",
  "content": "<h1>GROOV API: The Self-Documenting Content Management System</h1>\n<p>Welcome to...</p>",
  "raw_content": "# GROOV API: The Self-Documenting Content Management System\n\nWelcome to...",
  "metadata": {
    "title": "GROOV API - Self-Documenting Grav CMS",
    "process": {
      "markdown": true,
      "twig": true
    },
    "visible": true,
    "routable": true,
    "cache_enable": true
  },
  "date": "2025-12-04T00:00:00Z",
  "modified": "2025-12-04T20:33:00Z",
  "taxonomy": {},
  "checksum": "sha256:abc123..."
}

Error Responses

404 Not Found

{
  "error": "Page not found",
  "slug": "nonexistent-page",
  "message": "The requested page does not exist"
}

Use Cases

Headless CMS

Fetch content from Grav and render it in any frontend framework (React, Vue, Angular, etc.)

Content Syndication

Retrieve content for republishing on other platforms or in different formats

Documentation Browser

Display API documentation dynamically by fetching content pages

Integration Testing

Validate content structure and formatting in automated tests

Example Usage

JavaScript (React)

import { useState, useEffect } from 'react';

function ApiDocPage({ slug }) {
  const [content, setContent] = useState(null);

  useEffect(() => {
    fetch(`https://api.infinity.b0x.store/api/content/${slug}.json`)
      .then(res => res.json())
      .then(data => setContent(data));
  }, [slug]);

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

  return (
    <article>
      <h1>{content.title}</h1>
      <div dangerouslySetInnerHTML={{ __html: content.content }} />
    </article>
  );
}

curl

# Get content for a specific page
curl https://api.infinity.b0x.store/api/content/api.json | jq '.title, .content'

# Get raw markdown
curl https://api.infinity.b0x.store/api/content/api.json | jq -r '.raw_content'

Python

import requests

def get_page_content(slug):
    url = f'https://api.infinity.b0x.store/api/content/{slug}.json'
    response = requests.get(url)

    if response.status_code == 200:
        return response.json()
    else:
        return None

# Fetch and display content
page = get_page_content('api')
if page:
    print(f"Title: {page['title']}")
    print(f"Content: {page['raw_content'][:200]}...")

Security Considerations

  • Only published pages are accessible via the API
  • Draft and unpublished pages return 404
  • Authentication required for admin-only content
  • Rate limiting applied to prevent abuse

The Ouroboros Pattern

This endpoint creates perfect self-reference:

  • Fetch /api/content/content to read this page's documentation
  • The documentation describes how to fetch itself
  • Creates infinite recursion of self-knowledge

Related Endpoints


Last updated: 2025-12-10 13:14:22