TypeScript 合约
TypeScript 合约
GET /api/entity/:slug 响应合约——API 的唯一真相来源。
interface EntityResponse {
identity: { id: string; type: string; slug: string; title: string };
summary: string | null;
score: { authority_score: number; content_level: string } | null;
relations: { outgoing: Relation[]; incoming: Relation[] };
compare: CompareEntry[];
sources: Source[];
timeline: TimelineEvent[];
faq: { question: string; answer: string }[];
evidence: { claim: string; sources: Source[]; confidence: string }[];
trust: { evidenceCoverage: number; sourceCount: number; confidenceSummary: Record<string, number> };
freshness: { lastUpdated: string | null; sourceFreshness: { latestSource: string | null; sourceCount: number }; freshnessLevel: string };
meta: { lang: string; canonical: string; apiVersion: string; generatedAt: string; entity: string; fields: string[] };
}
type Relation = { relation_type: string; target_slug: string; target_title?: string };
type CompareEntry = { slug: string; title: string };
type Source = { title: string; url: string; publisher: string; type: string; date: string | null };
type TimelineEvent = { event_date: string; event_title: string };TrustResponse
evidenceCoverage · sourceCount · confidenceSummary (high/medium/low)
EvidenceResponse
claims[] → { claim, sources[], confidence }
FreshnessResponse
lastUpdated · sourceFreshness · freshnessLevel (fresh/current/stale)
投影
?fields=identity,summary,relations,compare,trust,freshness,developer
默认响应不变;fields= 精确控制输出。