'use client'; import { useEffect, useRef } from 'react'; import Link from 'next/link'; import SiteNav from '../components/SiteNav'; const API_BASE = process.env.NEXT_PUBLIC_API_BASE ?? 'https://cypher.arcrun.dev'; export default function ApiDocsPage() { const containerRef = useRef(null); const initialized = useRef(false); useEffect(() => { if (initialized.current || !containerRef.current) return; initialized.current = true; // Dynamically load Swagger UI from CDN const link = document.createElement('link'); link.rel = 'stylesheet'; link.href = 'https://unpkg.com/swagger-ui-dist@5/swagger-ui.css'; document.head.appendChild(link); const script = document.createElement('script'); script.src = 'https://unpkg.com/swagger-ui-dist@5/swagger-ui-bundle.js'; script.onload = () => { const SwaggerUIBundle = (window as unknown as { SwaggerUIBundle: (opts: unknown) => void }).SwaggerUIBundle; if (!SwaggerUIBundle || !containerRef.current) return; SwaggerUIBundle({ url: `${API_BASE}/openapi.json`, dom_id: '#swagger-ui', presets: [(window as unknown as { SwaggerUIBundle: { presets: { apis: unknown } } }).SwaggerUIBundle.presets.apis], layout: 'BaseLayout', defaultModelsExpandDepth: -1, docExpansion: 'list', filter: true, tryItOutEnabled: true, supportedSubmitMethods: ['get', 'post', 'put', 'delete', 'patch'], requestInterceptor: (request: { headers: Record }) => { // Inject API key from localStorage if present const key = localStorage.getItem('arcrun_api_key'); if (key) request.headers['X-Arcrun-API-Key'] = key; return request; }, }); }; document.head.appendChild(script); return () => { // cleanup not strictly needed for page navigation }; }, []); return (
{/* Header */}

API Reference

這是 arcrun 的原始 API。Python / JS lib 是它的包裝,任何能發 HTTP request 的工具都能直接用。

Endpoint: {API_BASE}

{/* API Key hint */}

若要在此頁面試打 API,請先設定 API Key:

{/* Swagger UI */}
); } function ApiKeyInput() { return (
{ if (e.target.value.startsWith('ak_')) { localStorage.setItem('arcrun_api_key', e.target.value); } }} /> 自動注入到 requests
); }