File size: 14,177 Bytes
b72178b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
<!DOCTYPE html>
<html lang="en" class="dark">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>LogFlow API Documentation</title>
    <script src="https://cdn.tailwindcss.com"></script>
    <script src="https://unpkg.com/feather-icons"></script>
    <script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
    <script>
        tailwind.config = {
            darkMode: 'class',
            theme: {
                extend: {
                    colors: {
                        primary: '#3b82f6',
                        secondary: '#6366f1',
                    }
                }
            }
        }
    </script>
    <style>
        @import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');
        body {
            font-family: 'Inter', sans-serif;
        }
        .method-get {
            background-color: rgba(74, 222, 128, 0.1);
            color: #4ade80;
        }
        .method-post {
            background-color: rgba(96, 165, 250, 0.1);
            color: #3b82f6;
        }
        .method-put {
            background-color: rgba(250, 204, 21, 0.1);
            color: #facc15;
        }
        .method-delete {
            background-color: rgba(248, 113, 113, 0.1);
            color: #f87171;
        }
        code {
            background-color: rgba(55, 65, 81, 0.5);
            padding: 0.2rem 0.4rem;
            border-radius: 0.25rem;
            font-family: 'Courier New', monospace;
        }
        pre {
            background-color: rgba(55, 65, 81, 0.5);
            padding: 1rem;
            border-radius: 0.5rem;
            overflow-x: auto;
        }
    </style>
</head>
<body class="bg-gray-900 text-gray-200 min-h-screen">
    <div class="container mx-auto px-6 py-12">
        <div class="flex items-center space-x-2 mb-12">
            <i data-feather="activity" class="text-primary w-8 h-8"></i>
            <span class="text-3xl font-bold bg-gradient-to-r from-primary to-secondary bg-clip-text text-transparent">LogFlow API</span>
        </div>

        <div class="grid grid-cols-1 lg:grid-cols-4 gap-8">
            <!-- Sidebar -->
            <div class="lg:col-span-1">
                <div class="bg-gray-800 rounded-xl p-6 sticky top-6">
                    <h3 class="text-lg font-semibold mb-4">API Endpoints</h3>
                    <ul class="space-y-2">
                        <li><a href="#authentication" class="block px-3 py-2 rounded-md hover:bg-gray-700 transition">Authentication</a></li>
                        <li><a href="#logs" class="block px-3 py-2 rounded-md hover:bg-gray-700 transition">Log Management</a></li>
                        <li><a href="#sources" class="block px-3 py-2 rounded-md hover:bg-gray-700 transition">Log Sources</a></li>
                        <li><a href="#alerts" class="block px-3 py-2 rounded-md hover:bg-gray-700 transition">Alerts</a></li>
                        <li><a href="#stats" class="block px-3 py-2 rounded-md hover:bg-gray-700 transition">Statistics</a></li>
                    </ul>
                    
                    <h3 class="text-lg font-semibold mt-8 mb-4">Quick Start</h3>
                    <div class="bg-gray-900 p-4 rounded-lg">
                        <p class="text-sm text-gray-400 mb-2">Install with curl:</p>
                        <pre class="text-sm">curl -X POST https://api.logflow.io/v1/install</pre>
                    </div>
                </div>
            </div>

            <!-- Main Content -->
            <div class="lg:col-span-3 space-y-12">
                <!-- Authentication Section -->
                <section id="authentication">
                    <h2 class="text-2xl font-bold mb-6">Authentication</h2>
                    <p class="text-gray-400 mb-6">All API requests require authentication using an API key. Include your key in the <code>Authorization</code> header.</p>
                    
                    <div class="bg-gray-800 rounded-xl overflow-hidden border border-gray-700 mb-8">
                        <div class="px-6 py-4 border-b border-gray-700 flex items-center">
                            <span class="method-get px-3 py-1 rounded-full text-xs font-bold mr-3">GET</span>
                            <span class="font-mono">/v1/auth/verify</span>
                        </div>
                        <div class="p-6">
                            <p class="text-gray-400 mb-4">Verify your API key is valid.</p>
                            <h4 class="font-semibold mb-2">Example Request</h4>
                            <pre class="mb-4">curl -X GET https://api.logflow.io/v1/auth/verify \
-H "Authorization: Bearer YOUR_API_KEY"</pre>
                            <h4 class="font-semibold mb-2">Response</h4>
                            <pre>{
  "valid": true,
  "expires_at": "2023-12-31T23:59:59Z"
}</pre>
                        </div>
                    </div>
                </section>

                <!-- Log Management Section -->
                <section id="logs">
                    <h2 class="text-2xl font-bold mb-6">Log Management</h2>
                    
                    <div class="bg-gray-800 rounded-xl overflow-hidden border border-gray-700 mb-8">
                        <div class="px-6 py-4 border-b border-gray-700 flex items-center">
                            <span class="method-post px-3 py-1 rounded-full text-xs font-bold mr-3">POST</span>
                            <span class="font-mono">/v1/logs</span>
                        </div>
                        <div class="p-6">
                            <p class="text-gray-400 mb-4">Ingest new log entries into the system.</p>
                            <h4 class="font-semibold mb-2">Request Body</h4>
                            <pre class="mb-4">{
  "source": "web-server-1",
  "level": "error",
  "message": "Database connection failed",
  "timestamp": "2023-06-15T14:30:00Z",
  "metadata": {
    "service": "auth-service",
    "ip": "192.168.1.1"
  }
}</pre>
                            <h4 class="font-semibold mb-2">Example Request</h4>
                            <pre class="mb-4">curl -X POST https://api.logflow.io/v1/logs \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"source":"web-server-1","level":"error","message":"Database connection failed"}'</pre>
                            <h4 class="font-semibold mb-2">Response</h4>
                            <pre>{
  "id": "log_123456789",
  "status": "processed"
}</pre>
                        </div>
                    </div>

                    <div class="bg-gray-800 rounded-xl overflow-hidden border border-gray-700 mb-8">
                        <div class="px-6 py-4 border-b border-gray-700 flex items-center">
                            <span class="method-get px-3 py-1 rounded-full text-xs font-bold mr-3">GET</span>
                            <span class="font-mono">/v1/logs</span>
                        </div>
                        <div class="p-6">
                            <p class="text-gray-400 mb-4">Query logs with filters and pagination.</p>
                            <h4 class="font-semibold mb-2">Query Parameters</h4>
                            <div class="grid grid-cols-1 md:grid-cols-2 gap-4 mb-4">
                                <div>
                                    <p><code>level</code> <span class="text-gray-500">string</span></p>
                                    <p class="text-sm text-gray-400">Filter by log level (error, warning, info)</p>
                                </div>
                                <div>
                                    <p><code>source</code> <span class="text-gray-500">string</span></p>
                                    <p class="text-sm text-gray-400">Filter by source identifier</p>
                                </div>
                                <div>
                                    <p><code>limit</code> <span class="text-gray-500">integer</span></p>
                                    <p class="text-sm text-gray-400">Number of results per page (default: 50)</p>
                                </div>
                                <div>
                                    <p><code>page</code> <span class="text-gray-500">integer</span></p>
                                    <p class="text-sm text-gray-400">Page number (default: 1)</p>
                                </div>
                            </div>
                            <h4 class="font-semibold mb-2">Example Request</h4>
                            <pre class="mb-4">curl -X GET "https://api.logflow.io/v1/logs?level=error&limit=10" \
-H "Authorization: Bearer YOUR_API_KEY"</pre>
                            <h4 class="font-semibold mb-2">Response</h4>
                            <pre>{
  "data": [
    {
      "id": "log_123456789",
      "source": "web-server-1",
      "level": "error",
      "message": "Database connection failed",
      "timestamp": "2023-06-15T14:30:00Z",
      "metadata": {
        "service": "auth-service"
      }
    }
  ],
  "total": 1245,
  "page": 1,
  "pages": 125
}</pre>
                        </div>
                    </div>
                </section>

                <!-- Sources Section -->
                <section id="sources">
                    <h2 class="text-2xl font-bold mb-6">Log Sources</h2>
                    
                    <div class="bg-gray-800 rounded-xl overflow-hidden border border-gray-700 mb-8">
                        <div class="px-6 py-4 border-b border-gray-700 flex items-center">
                            <span class="method-get px-3 py-1 rounded-full text-xs font-bold mr-3">GET</span>
                            <span class="font-mono">/v1/sources</span>
                        </div>
                        <div class="p-6">
                            <p class="text-gray-400 mb-4">List all configured log sources.</p>
                            <h4 class="font-semibold mb-2">Example Request</h4>
                            <pre class="mb-4">curl -X GET https://api.logflow.io/v1/sources \
-H "Authorization: Bearer YOUR_API_KEY"</pre>
                            <h4 class="font-semibold mb-2">Response</h4>
                            <pre>{
  "sources": [
    {
      "id": "src_123456789",
      "name": "web-server-1",
      "type": "file",
      "path": "/var/log/nginx/access.log",
      "status": "active",
      "last_activity": "2023-06-15T14:32:00Z"
    }
  ]
}</pre>
                        </div>
                    </div>
                </section>

                <!-- Alerts Section -->
                <section id="alerts">
                    <h2 class="text-2xl font-bold mb-6">Alerts</h2>
                    
                    <div class="bg-gray-800 rounded-xl overflow-hidden border border-gray-700 mb-8">
                        <div class="px-6 py-4 border-b border-gray-700 flex items-center">
                            <span class="method-post px-3 py-1 rounded-full text-xs font-bold mr-3">POST</span>
                            <span class="font-mono">/v1/alerts</span>
                        </div>
                        <div class="p-6">
                            <p class="text-gray-400 mb-4">Create a new alert rule.</p>
                            <h4 class="font-semibold mb-2">Request Body</h4>
                            <pre class="mb-4">{
  "name": "High Error Rate",
  "condition": "error_count > 10",
  "time_window": "5m",
  "actions": [
    {
      "type": "webhook",
      "target": "https://hooks.slack.com/services/..."
    }
  ]
}</pre>
                            <h4 class="font-semibold mb-2">Example Request</h4>
                            <pre class="mb-4">curl -X POST https://api.logflow.io/v1/alerts \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"name":"High Error Rate","condition":"error_count > 10"}'</pre>
                            <h4 class="font-semibold mb-2">Response</h4>
                            <pre>{
  "id": "alert_123456789",
  "status": "active"
}</pre>
                        </div>
                    </div>
                </section>

                <!-- Statistics Section -->
                <section id="stats">
                    <h2 class="text-2xl font-bold mb-6">Statistics</h2>
                    
                    <div class="bg-gray-800 rounded-xl overflow-hidden border border-gray-700 mb-8">
                        <div class="px-6 py-4 border-b border-gray-700 flex items-center">
                            <span class="method-get px-3 py-1 rounded-full text-xs font-bold mr-3">GET</span>
                            <span class="font-mono">/v1/stats</span>
                        </div>
                        <div class="p-6">
                            <p class="text-gray-400 mb-4">Get system statistics.</p>
                            <h4 class="font-semibold mb-2">Example Request</h4>
                            <pre class="mb-4">curl -X GET https://api.logflow.io/v1/stats \
-H "Authorization: Bearer YOUR_API_KEY"</pre>
                            <h4 class="font-semibold mb-2">Response</h4>
                            <pre>{
  "logs": {
    "total": 24568,
    "errors": 1245,
    "warnings": 876,
    "info": 22447
  },
  "sources": {
    "active": 19,
    "inactive": 2
  },
  "storage": {
    "used": "45GB",
    "available": "155GB"
  }
}</pre>
                        </div>
                    </div>
                </section>
            </div>
        </div>
    </div>

    <script>
        // Initialize feather icons
        feather.replace();

        // Smooth scrolling for anchor links
        document.querySelectorAll('a[href^="#"]').forEach(anchor => {
            anchor.addEventListener('click', function (e) {
                e.preventDefault();
                document.querySelector(this.getAttribute('href')).scrollIntoView({
                    behavior: 'smooth'
                });
            });
        });
    </script>
</body>
</html>