/** * Component: Interactive API Documentation Page * Documentation: documentation/backend/services/api-tokens.md * * Lists all API token-accessible endpoints with "Try it out" functionality. * Users can test with a custom API token or their current browser session. */ 'use client'; import { useState } from 'react'; import { Header } from '@/components/layout/Header'; import { ProtectedRoute } from '@/components/auth/ProtectedRoute'; import { TokenInput } from '@/components/api-docs/TokenInput'; import { EndpointCard } from '@/components/api-docs/EndpointCard'; import { API_TOKEN_ENDPOINT_DOCS } from '@/lib/constants/api-tokens'; import { useAuth } from '@/contexts/AuthContext'; import Link from 'next/link'; export default function ApiDocsPage() { const { user } = useAuth(); const [token, setToken] = useState(''); const [useSession, setUseSession] = useState(false); const isAdmin = user?.role === 'admin'; return (
{/* Page header */}
Profile API Documentation

API Reference

Interact with ReadMeABook programmatically using API tokens. These endpoints are available for external integrations, dashboards, and automation tools.

{/* Quick links */}
Manage your tokens {isAdmin && ( <> | Admin token management )}
{/* Authentication section */}
{/* Usage instructions card */}

Quick Start

Include your API token in the Authorization header as a Bearer token:

{`curl -H "Authorization: Bearer rmab_your_token_here" \\
  ${typeof window !== 'undefined' ? window.location.origin : 'https://your-instance'}/api/requests`}
            
{/* Endpoints section header */}

Available Endpoints

{API_TOKEN_ENDPOINT_DOCS.length} endpoints
{/* Endpoint cards */}
{API_TOKEN_ENDPOINT_DOCS.map((endpoint) => ( ))}
{/* Footer note */}

API tokens are restricted to the endpoints listed above. JWT session authentication has access to all endpoints.

); }