218 lines
6.0 KiB
HTML
218 lines
6.0 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>API Reference - DearDiary</title>
|
|
<link rel="stylesheet" href="../css/styles.css">
|
|
<link rel="stylesheet" href="../css/docs.css">
|
|
</head>
|
|
<body>
|
|
<nav class="navbar">
|
|
<div class="nav-container">
|
|
<a href="../" class="logo">
|
|
<svg width="32" height="32" viewBox="0 0 100 100"><defs><linearGradient id="g" x1="0%" y1="0%" x2="100%" y2="100%"><stop offset="0%" style="stop-color:#6d28d9"/><stop offset="100%" style="stop-color:#4c1d95"/></linearGradient></defs><rect width="100" height="100" rx="20" fill="url(#g)"/><path d="M25 25 L75 25 L75 80 L25 80 Z" fill="none" stroke="white" stroke-width="3"/><path d="M35 40 L65 40 M35 50 L65 50 M35 60 L55 60" stroke="white" stroke-width="2"/></svg>
|
|
DearDiary
|
|
</a>
|
|
<div class="nav-links">
|
|
<a href="../">Home</a>
|
|
<a href="../docs/" class="active">Docs</a>
|
|
<a href="../blog/">Blog</a>
|
|
<a href="${GIT_URL}" target="_blank">Git Repository</a>
|
|
</div>
|
|
</div>
|
|
</nav>
|
|
|
|
<div class="docs-layout">
|
|
<aside class="docs-sidebar">
|
|
<div class="sidebar-section">
|
|
<h3>Getting Started</h3>
|
|
<a href="installation.html">Installation</a>
|
|
<a href="quick-start.html">Quick Start</a>
|
|
</div>
|
|
<div class="sidebar-section">
|
|
<h3>Configuration</h3>
|
|
<a href="configuration.html">Environment</a>
|
|
<a href="api.html" class="active">API Reference</a>
|
|
</div>
|
|
<div class="sidebar-section">
|
|
<h3>Features</h3>
|
|
<a href="ai-providers.html">AI Providers</a>
|
|
<a href="events.html">Events</a>
|
|
<a href="export-import.html">Export & Import</a>
|
|
</div>
|
|
</aside>
|
|
|
|
<main class="docs-content">
|
|
<h1>API Reference</h1>
|
|
|
|
<p>The DearDiary API is REST-based with JSON responses. All endpoints return a consistent format.</p>
|
|
|
|
<h2>Response Format</h2>
|
|
<p>All responses follow this structure:</p>
|
|
<pre><code>{
|
|
"data": { ... } | null,
|
|
"error": { "code": "ERROR_CODE", "message": "..." } | null
|
|
}</code></pre>
|
|
|
|
<h2>Authentication</h2>
|
|
<p>Include your API key in the Authorization header:</p>
|
|
<pre><code>Authorization: Bearer <your-api-key></code></pre>
|
|
|
|
<h2>Endpoints</h2>
|
|
|
|
<h3>Events</h3>
|
|
|
|
<h4>GET /api/v1/events?date=YYYY-MM-DD</h4>
|
|
<p>List events for a specific date.</p>
|
|
<pre><code>// Response
|
|
{
|
|
"data": [
|
|
{
|
|
"id": "evt_xxx",
|
|
"date": "2026-03-27",
|
|
"type": "text",
|
|
"content": "Had coffee with Sarah",
|
|
"latitude": 40.7128,
|
|
"longitude": -74.0060,
|
|
"placeName": "New York, NY",
|
|
"createdAt": "2026-03-27T08:30:00Z"
|
|
}
|
|
]
|
|
}</code></pre>
|
|
|
|
<h4>POST /api/v1/events</h4>
|
|
<p>Create a new event.</p>
|
|
<pre><code>// Request body
|
|
{
|
|
"date": "2026-03-27",
|
|
"type": "text", // text, photo, voice, health
|
|
"content": "Event content"
|
|
}
|
|
|
|
// Response
|
|
{
|
|
"data": {
|
|
"id": "evt_xxx",
|
|
"date": "2026-03-27",
|
|
"type": "text",
|
|
"content": "Event content",
|
|
"createdAt": "2026-03-27T10:00:00Z"
|
|
}
|
|
}</code></pre>
|
|
|
|
<h4>DELETE /api/v1/events/:id</h4>
|
|
<p>Delete an event. Only works if no journal exists for that date.</p>
|
|
|
|
<h3>Journals</h3>
|
|
|
|
<h4>GET /api/v1/journal/:date</h4>
|
|
<p>Get diary page for a specific date.</p>
|
|
<pre><code>{
|
|
"data": {
|
|
"id": "jrn_xxx",
|
|
"date": "2026-03-27",
|
|
"title": "A Productive Tuesday",
|
|
"content": "Today was filled with...",
|
|
"eventCount": 8,
|
|
"generatedAt": "2026-03-27T20:00:00Z"
|
|
}
|
|
}</code></pre>
|
|
|
|
<h4>POST /api/v1/journal/generate/:date</h4>
|
|
<p>Generate a diary page from events. Starts an async task.</p>
|
|
<pre><code>// Request body (optional)
|
|
{
|
|
"instructions": "Focus on the meeting with the client"
|
|
}
|
|
|
|
// Response
|
|
{
|
|
"data": {
|
|
"taskId": "tsk_xxx",
|
|
"status": "pending"
|
|
}
|
|
}</code></pre>
|
|
|
|
<h4>PUT /api/v1/journal/:date</h4>
|
|
<p>Update journal title and content.</p>
|
|
<pre><code>// Request body
|
|
{
|
|
"title": "New Title",
|
|
"content": "Updated content..."
|
|
}</code></pre>
|
|
|
|
<h4>DELETE /api/v1/journal/:date</h4>
|
|
<p>Delete journal. This unlocks events so they can be modified.</p>
|
|
|
|
<h3>Tasks</h3>
|
|
|
|
<h4>GET /api/v1/journal/:date/tasks</h4>
|
|
<p>Get generation tasks for a journal.</p>
|
|
<pre><code>{
|
|
"data": [
|
|
{
|
|
"id": "tsk_xxx",
|
|
"type": "generate",
|
|
"status": "completed", // pending, processing, completed, failed
|
|
"title": "A Great Day",
|
|
"provider": "groq",
|
|
"model": "llama-3.3-70b-versatile",
|
|
"createdAt": "2026-03-27T20:00:00Z",
|
|
"completedAt": "2026-03-27T20:00:30Z"
|
|
}
|
|
]
|
|
}</code></pre>
|
|
|
|
<h3>Journals List</h3>
|
|
|
|
<h4>GET /api/v1/journals?page=1&limit=10</h4>
|
|
<p>List all diary pages with pagination.</p>
|
|
|
|
<h4>GET /api/v1/days</h4>
|
|
<p>List days with journal info and excerpts.</p>
|
|
|
|
<h3>Settings</h3>
|
|
|
|
<h4>GET /api/v1/settings</h4>
|
|
<p>Get current user settings.</p>
|
|
|
|
<h4>PUT /api/v1/settings</h4>
|
|
<p>Update user settings.</p>
|
|
<pre><code>{
|
|
"aiProvider": "groq",
|
|
"aiApiKey": "gsk_xxx",
|
|
"aiModel": "llama-3.3-70b-versatile",
|
|
"useSystemDefault": false
|
|
}</code></pre>
|
|
|
|
<h3>Data Management</h3>
|
|
|
|
<h4>GET /api/v1/export</h4>
|
|
<p>Export all user data as JSON.</p>
|
|
<pre><code>{
|
|
"data": {
|
|
"version": "0.1.0",
|
|
"exportedAt": "2026-03-27T12:00:00Z",
|
|
"events": [...],
|
|
"journals": [...],
|
|
"tasks": [...],
|
|
"settings": {...}
|
|
}
|
|
}</code></pre>
|
|
|
|
<h4>POST /api/v1/import</h4>
|
|
<p>Import data from export file.</p>
|
|
|
|
<h4>GET /api/v1/health</h4>
|
|
<p>Health check endpoint (no auth required).</p>
|
|
<pre><code>{ "status": "ok" }</code></pre>
|
|
|
|
<div class="next-steps">
|
|
<a href="configuration.html" class="btn">← Configuration</a>
|
|
<a href="events.html" class="btn btn-primary">Next: Events →</a>
|
|
</div>
|
|
</main>
|
|
</div>
|
|
</body>
|
|
</html> |