-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
710 lines (638 loc) · 40.3 KB
/
Copy pathindex.html
File metadata and controls
710 lines (638 loc) · 40.3 KB
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
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
<!DOCTYPE html>
<html lang="zh-TW">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>免費公開 API 資源互動指南 | Public API Interactive Report</title>
<!-- Tailwind CSS -->
<script src="https://cdn.tailwindcss.com"></script>
<!-- Chart.js -->
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<!-- Font Awesome -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<!-- Google Fonts -->
<link href="https://fonts.googleapis.com/css2?family=Noto+Sans+TC:wght@300;400;500;700&display=swap" rel="stylesheet">
<style>
/* Custom Styling overrides & utilities */
body {
font-family: 'Noto Sans TC', sans-serif;
background-color: #fdfbf7; /* Warm neutral background */
color: #334155;
}
/* Chart Container Strict Rules */
.chart-container {
position: relative;
width: 100%;
max-width: 100%;
margin-left: auto;
margin-right: auto;
height: 300px;
}
@media (min-width: 768px) {
.chart-container {
height: 350px;
}
}
/* Custom Scrollbar for the table container */
.table-scroller::-webkit-scrollbar {
width: 8px;
height: 8px;
}
.table-scroller::-webkit-scrollbar-track {
background: #f1f1f1;
}
.table-scroller::-webkit-scrollbar-thumb {
background: #cbd5e1;
border-radius: 4px;
}
.table-scroller::-webkit-scrollbar-thumb:hover {
background: #94a3b8;
}
.glass-panel {
background: rgba(255, 255, 255, 0.9);
border: 1px solid rgba(226, 232, 240, 0.8);
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
backdrop-filter: blur(4px);
}
/* Badge Styles */
.badge-auth-none {
background-color: #dcfce7;
color: #166534;
}
.badge-auth-key {
background-color: #fff7ed;
color: #9a3412;
}
.badge-auth-oauth {
background-color: #eff6ff;
color: #1e40af;
}
/* Smooth transitions */
* {
transition: all 0.2s ease;
}
</style>
</head>
<body class="antialiased selection:bg-indigo-100 selection:text-indigo-800">
<!-- Header Section -->
<header class="bg-white border-b border-gray-200 sticky top-0 z-40 shadow-sm">
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-4 flex flex-col md:flex-row justify-between items-center gap-4">
<div class="flex items-center gap-3">
<i class="fa-solid fa-layer-group text-indigo-600 text-2xl"></i>
<div>
<h1 class="text-xl font-bold text-slate-800" data-i18n="header.title">API 資源探勘報告</h1>
<p class="text-xs text-slate-500" data-i18n="header.subtitle">免費公開 API 整合清單 (Top 80+ Selection)</p>
</div>
</div>
<div class="flex gap-4 text-sm items-center">
<div class="text-center px-4 py-2 bg-slate-50 rounded-lg">
<span class="block text-xl font-bold text-indigo-600" id="total-apis-count">0</span>
<span class="text-xs text-slate-500" data-i18n="header.totalApis">收錄 API</span>
</div>
<div class="text-center px-4 py-2 bg-slate-50 rounded-lg">
<span class="block text-xl font-bold text-emerald-600" id="free-apis-count">0</span>
<span class="text-xs text-slate-500" data-i18n="header.freeApis">完全免費</span>
</div>
<!-- Language Switcher -->
<div class="flex gap-2">
<button onclick="switchLanguage('zh-TW')" id="lang-zh" class="px-3 py-1.5 rounded-md bg-indigo-600 text-white text-xs font-medium transition-colors">
<i class="fa-solid fa-language mr-1"></i> 中文
</button>
<button onclick="switchLanguage('en')" id="lang-en" class="px-3 py-1.5 rounded-md bg-gray-200 text-gray-700 text-xs font-medium hover:bg-gray-300 transition-colors">
<i class="fa-solid fa-language mr-1"></i> EN
</button>
</div>
</div>
</div>
</header>
<main class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8 space-y-8">
<!-- Introduction & Context -->
<section class="prose max-w-none text-slate-600">
<h2 class="text-lg font-semibold text-slate-800 mb-2" data-i18n="intro.title">關於此報告</h2>
<p class="mb-4" data-i18n="intro.description">
本應用程式將「免費公共 API 資源報告」轉化為互動式儀表板。針對開發者、數據分析師與創意編碼者,我們整理了目前網路上最實用、穩定且易於串接的 API 接口。
與其閱讀冗長的靜態文件,您可以透過下方的視覺化圖表了解目前的 API 生態分佈,並使用「智慧清單」功能快速篩選出符合您專案需求的資源。
所有資料皆已結構化處理,方便您進行比較與查找。
</p>
</section>
<!-- Analytics Dashboard Section -->
<section>
<div class="mb-4">
<h3 class="text-lg font-bold text-slate-800 flex items-center gap-2">
<i class="fa-solid fa-chart-pie text-indigo-500"></i> <span data-i18n="analytics.title">API 生態數據分析</span>
</h3>
<p class="text-sm text-slate-500" data-i18n="analytics.description">視覺化呈現各類型 API 的佔比與認證門檻,協助您快速掌握資源概況。</p>
</div>
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
<!-- Category Chart -->
<div class="glass-panel p-4 rounded-xl">
<h4 class="text-sm font-semibold text-slate-700 mb-4 text-center" data-i18n="analytics.categoryTitle">資源類別分佈</h4>
<div class="chart-container">
<canvas id="categoryChart"></canvas>
</div>
<div class="mt-2 text-xs text-center text-slate-400" data-i18n="analytics.categoryDesc">顯示各領域 API 的數量佔比</div>
</div>
<!-- Auth Chart -->
<div class="glass-panel p-4 rounded-xl">
<h4 class="text-sm font-semibold text-slate-700 mb-4 text-center" data-i18n="analytics.authTitle">認證機制統計</h4>
<div class="chart-container">
<canvas id="authChart"></canvas>
</div>
<div class="mt-2 text-xs text-center text-slate-400" data-i18n="analytics.authDesc">分析 API 的接入難度 (No Auth 最易接入)</div>
</div>
</div>
</section>
<!-- Interactive Sheet Section -->
<section id="explorer" class="scroll-mt-20">
<div class="mb-4 flex flex-col md:flex-row justify-between items-end md:items-center gap-4">
<div>
<h3 class="text-lg font-bold text-slate-800 flex items-center gap-2">
<i class="fa-solid fa-table-list text-indigo-500"></i> <span data-i18n="table.title">資源智慧清單</span>
</h3>
<p class="text-sm text-slate-500" data-i18n="table.description">類似 Google 試算表的結構化檢視,支援即時搜尋與多維度篩選。</p>
</div>
<!-- Controls -->
<div class="flex flex-col sm:flex-row gap-3 w-full md:w-auto">
<div class="relative">
<i class="fa-solid fa-search absolute left-3 top-3 text-slate-400"></i>
<input type="text" id="searchInput" data-i18n-placeholder="table.searchPlaceholder" placeholder="搜尋名稱、描述或關鍵字..."
class="pl-10 pr-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 outline-none w-full sm:w-64 text-sm transition-shadow shadow-sm">
</div>
<select id="categoryFilter" class="px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-indigo-500 text-sm bg-white shadow-sm cursor-pointer">
<option value="All" data-i18n="table.allCategories">所有分類</option>
<!-- Options populated by JS -->
</select>
</div>
</div>
<!-- The Grid/Table -->
<div class="glass-panel rounded-xl overflow-hidden flex flex-col">
<div class="overflow-x-auto table-scroller">
<table class="w-full text-left text-sm whitespace-nowrap">
<thead class="bg-slate-100 border-b border-gray-200">
<tr>
<th class="px-6 py-3 font-semibold text-slate-700 w-1/4" data-i18n="table.headers.name">API 名稱</th>
<th class="px-6 py-3 font-semibold text-slate-700 w-1/6" data-i18n="table.headers.category">分類</th>
<th class="px-6 py-3 font-semibold text-slate-700 w-1/3" data-i18n="table.headers.description">功能簡述</th>
<th class="px-6 py-3 font-semibold text-slate-700 w-1/12" data-i18n="table.headers.auth">認證</th>
<th class="px-6 py-3 font-semibold text-slate-700 w-1/12">HTTPS</th>
<th class="px-6 py-3 font-semibold text-slate-700 w-1/12 text-right" data-i18n="table.headers.actions">操作</th>
</tr>
</thead>
<tbody id="apiTableBody" class="divide-y divide-gray-100 bg-white">
<!-- Rows populated by JS -->
</tbody>
</table>
</div>
<!-- Pagination / Count Footer -->
<div class="px-6 py-3 bg-slate-50 border-t border-gray-200 text-xs text-slate-500 flex justify-between items-center">
<span id="showing-count" data-i18n="table.showingCount">顯示 0 / 0 筆資料</span>
<button onclick="exportCSV()" class="text-indigo-600 hover:text-indigo-800 font-medium transition-colors">
<i class="fa-solid fa-file-csv mr-1"></i> <span data-i18n="table.downloadCSV">下載 CSV</span>
</button>
</div>
</div>
</section>
</main>
<!-- Modal for Details -->
<div id="detailModal" class="fixed inset-0 z-50 hidden" aria-labelledby="modal-title" role="dialog" aria-modal="true">
<!-- Backdrop -->
<div class="fixed inset-0 bg-gray-900 bg-opacity-50 transition-opacity backdrop-blur-sm" onclick="closeModal()"></div>
<!-- Panel -->
<div class="fixed inset-0 z-10 overflow-y-auto">
<div class="flex min-h-full items-center justify-center p-4 text-center sm:p-0">
<div class="relative transform overflow-hidden rounded-lg bg-white text-left shadow-xl transition-all sm:my-8 sm:w-full sm:max-w-lg">
<div class="bg-white px-4 pb-4 pt-5 sm:p-6 sm:pb-4">
<div class="sm:flex sm:items-start">
<div class="mx-auto flex h-12 w-12 flex-shrink-0 items-center justify-center rounded-full bg-indigo-100 sm:mx-0 sm:h-10 sm:w-10">
<i class="fa-solid fa-bolt text-indigo-600"></i>
</div>
<div class="mt-3 text-center sm:ml-4 sm:mt-0 sm:text-left w-full">
<h3 class="text-xl font-semibold leading-6 text-gray-900" id="modalTitle">API Name</h3>
<div class="mt-1">
<span id="modalCategory" class="inline-flex items-center rounded-md bg-gray-50 px-2 py-1 text-xs font-medium text-gray-600 ring-1 ring-inset ring-gray-500/10">Category</span>
</div>
<div class="mt-4">
<p class="text-sm text-gray-500" id="modalDesc">Detailed description goes here.</p>
</div>
<div class="mt-6 grid grid-cols-2 gap-4 border-t border-gray-100 pt-4">
<div>
<span class="text-xs text-gray-400 block uppercase">Auth</span>
<span id="modalAuth" class="text-sm font-medium text-gray-800">None</span>
</div>
<div>
<span class="text-xs text-gray-400 block uppercase">HTTPS</span>
<span id="modalHttps" class="text-sm font-medium text-gray-800">Yes</span>
</div>
<div>
<span class="text-xs text-gray-400 block uppercase">CORS</span>
<span id="modalCors" class="text-sm font-medium text-gray-800">Unknown</span>
</div>
</div>
</div>
</div>
</div>
<div class="bg-gray-50 px-4 py-3 sm:flex sm:flex-row-reverse sm:px-6">
<a id="modalLink" href="#" target="_blank" class="inline-flex w-full justify-center rounded-md bg-indigo-600 px-3 py-2 text-sm font-semibold text-white shadow-sm hover:bg-indigo-500 sm:ml-3 sm:w-auto transition-colors">
<i class="fa-solid fa-external-link-alt mr-2 mt-1"></i> <span data-i18n="modal.viewDocs">前往文件</span>
</a>
<button type="button" class="mt-3 inline-flex w-full justify-center rounded-md bg-white px-3 py-2 text-sm font-semibold text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 hover:bg-gray-50 sm:mt-0 sm:w-auto transition-colors" onclick="closeModal()">
<span data-i18n="modal.close">關閉</span>
</button>
</div>
</div>
</div>
</div>
</div>
<!-- Notification Toast -->
<div id="toast" class="fixed bottom-5 right-5 bg-slate-800 text-white px-4 py-2 rounded shadow-lg transform translate-y-20 transition-transform duration-300 z-50 text-sm flex items-center gap-2">
<i class="fa-solid fa-check-circle text-green-400"></i>
<span data-i18n="toast.linkCopied">連結已複製</span>
</div>
<script>
// --- 0. Internationalization (i18n) ---
let currentLang = localStorage.getItem('preferredLang') || 'zh-TW';
const translations = {
'zh-TW': {
'header.title': 'API 資源探勘報告',
'header.subtitle': '免費公開 API 整合清單 (Top 80+ Selection)',
'header.totalApis': '收錄 API',
'header.freeApis': '完全免費',
'intro.title': '關於此報告',
'intro.description': '本應用程式將「免費公共 API 資源報告」轉化為互動式儀表板。針對開發者、數據分析師與創意編碼者,我們整理了目前網路上最實用、穩定且易於串接的 API 接口。與其閱讀冗長的靜態文件,您可以透過下方的視覺化圖表了解目前的 API 生態分佈,並使用「智慧清單」功能快速篩選出符合您專案需求的資源。所有資料皆已結構化處理,方便您進行比較與查找。',
'analytics.title': 'API 生態數據分析',
'analytics.description': '視覺化呈現各類型 API 的佔比與認證門檻,協助您快速掌握資源概況。',
'analytics.categoryTitle': '資源類別分佈',
'analytics.categoryDesc': '顯示各領域 API 的數量佔比',
'analytics.authTitle': '認證機制統計',
'analytics.authDesc': '分析 API 的接入難度 (No Auth 最易接入)',
'table.title': '資源智慧清單',
'table.description': '類似 Google 試算表的結構化檢視,支援即時搜尋與多維度篩選。',
'table.searchPlaceholder': '搜尋名稱、描述或關鍵字...',
'table.allCategories': '所有分類',
'table.headers.name': 'API 名稱',
'table.headers.category': '分類',
'table.headers.description': '功能簡述',
'table.headers.auth': '認證',
'table.headers.actions': '操作',
'table.showingCount': '顯示 0 / 0 筆資料',
'table.downloadCSV': '下載 CSV',
'table.noResults': '找不到符合的 API 資源',
'table.copyLink': '複製連結',
'table.openLink': '開啟連結',
'modal.viewDocs': '前往文件',
'modal.close': '關閉',
'modal.httpsYes': '支援',
'modal.httpsNo': '不支援',
'toast.linkCopied': '連結已複製',
'auth.none': '無須認證',
'auth.apikey': 'API Key',
'auth.oauth': 'OAuth'
},
'en': {
'header.title': 'Public API Resource Explorer',
'header.subtitle': 'Free Public API Integration List (Top 80+ Selection)',
'header.totalApis': 'Total APIs',
'header.freeApis': 'Completely Free',
'intro.title': 'About This Report',
'intro.description': 'This application transforms the "Free Public API Resource Report" into an interactive dashboard. For developers, data analysts, and creative coders, we have curated the most practical, stable, and easy-to-integrate API interfaces currently available online. Instead of reading lengthy static documents, you can understand the current API ecosystem distribution through the visualizations below and use the "Smart List" feature to quickly filter resources that meet your project needs. All data has been structured for easy comparison and lookup.',
'analytics.title': 'API Ecosystem Analytics',
'analytics.description': 'Visualize the distribution and authentication requirements of various API types to help you quickly understand the resource landscape.',
'analytics.categoryTitle': 'Category Distribution',
'analytics.categoryDesc': 'Shows the quantity ratio of APIs across different fields',
'analytics.authTitle': 'Authentication Statistics',
'analytics.authDesc': 'Analyze API access difficulty (No Auth is easiest to access)',
'table.title': 'Smart Resource List',
'table.description': 'A structured view similar to Google Sheets, supporting real-time search and multi-dimensional filtering.',
'table.searchPlaceholder': 'Search name, description or keywords...',
'table.allCategories': 'All Categories',
'table.headers.name': 'API Name',
'table.headers.category': 'Category',
'table.headers.description': 'Description',
'table.headers.auth': 'Auth',
'table.headers.actions': 'Actions',
'table.showingCount': 'Showing 0 / 0 entries',
'table.downloadCSV': 'Download CSV',
'table.noResults': 'No matching API resources found',
'table.copyLink': 'Copy link',
'table.openLink': 'Open link',
'modal.viewDocs': 'View Documentation',
'modal.close': 'Close',
'modal.httpsYes': 'Supported',
'modal.httpsNo': 'Not Supported',
'toast.linkCopied': 'Link copied',
'auth.none': 'No Auth',
'auth.apikey': 'API Key',
'auth.oauth': 'OAuth'
}
};
function t(key) {
return translations[currentLang][key] || translations['zh-TW'][key] || key;
}
function switchLanguage(lang) {
currentLang = lang;
localStorage.setItem('preferredLang', lang);
document.documentElement.lang = lang;
// Update language buttons
document.getElementById('lang-zh').className = lang === 'zh-TW'
? 'px-3 py-1.5 rounded-md bg-indigo-600 text-white text-xs font-medium transition-colors'
: 'px-3 py-1.5 rounded-md bg-gray-200 text-gray-700 text-xs font-medium hover:bg-gray-300 transition-colors';
document.getElementById('lang-en').className = lang === 'en'
? 'px-3 py-1.5 rounded-md bg-indigo-600 text-white text-xs font-medium transition-colors'
: 'px-3 py-1.5 rounded-md bg-gray-200 text-gray-700 text-xs font-medium hover:bg-gray-300 transition-colors';
// Update all elements with data-i18n attribute
document.querySelectorAll('[data-i18n]').forEach(el => {
const key = el.getAttribute('data-i18n');
el.textContent = t(key);
});
// Update placeholders
document.querySelectorAll('[data-i18n-placeholder]').forEach(el => {
const key = el.getAttribute('data-i18n-placeholder');
el.placeholder = t(key);
});
// Update API descriptions if needed
if (currentData.length > 0) {
renderTable(currentData);
}
// Re-render stats to update chart labels
renderStats();
}
// --- 1. Data Source ---
const apiData = [
{ name: "Cat Facts", category: "Animals", auth: "No Auth", https: true, cors: "Yes", desc: { 'zh-TW': "每日隨機貓咪冷知識", 'en': "Daily random cat facts" }, link: "https://alexwohlbruck.github.io/cat-facts/" },
{ name: "Dog CEO", category: "Animals", auth: "No Auth", https: true, cors: "Yes", desc: { 'zh-TW': "根據品種獲取狗狗圖片集", 'en': "Get dog images by breed" }, link: "https://dog.ceo/dog-api/" },
{ name: "PetFinder", category: "Animals", auth: "ApiKey", https: true, cors: "Yes", desc: { 'zh-TW': "寵物領養數據庫 (需要申請)", 'en': "Pet adoption database (registration required)" }, link: "https://www.petfinder.com/developers/" },
{ name: "AnimeChan", category: "Anime", auth: "No Auth", https: true, cors: "Yes", desc: { 'zh-TW': "隨機動漫語錄", 'en': "Random anime quotes" }, link: "https://github.com/rocktimsaikia/anime-chan" },
{ name: "Jikan", category: "Anime", auth: "No Auth", https: true, cors: "Yes", desc: { 'zh-TW': "非官方 MyAnimeList API", 'en': "Unofficial MyAnimeList API" }, link: "https://jikan.moe/" },
{ name: "Studio Ghibli", category: "Anime", auth: "No Auth", https: true, cors: "Yes", desc: { 'zh-TW': "吉卜力工作室電影與角色資料", 'en': "Studio Ghibli films and characters data" }, link: "https://ghibliapi.vercel.app/" },
{ name: "VirusTotal", category: "Security", auth: "ApiKey", https: true, cors: "Unknown", desc: { 'zh-TW': "分析可疑文件與網址", 'en': "Analyze suspicious files and URLs" }, link: "https://www.virustotal.com/" },
{ name: "HaveIBeenPwned", category: "Security", auth: "ApiKey", https: true, cors: "Yes", desc: { 'zh-TW': "檢查 Email 是否在洩露名單", 'en': "Check if email is in data breach list" }, link: "https://haveibeenpwned.com/API/v3" },
{ name: "Open Library", category: "Books", auth: "No Auth", https: true, cors: "Yes", desc: { 'zh-TW': "圖書、封面與作者數據庫", 'en': "Books, covers and authors database" }, link: "https://openlibrary.org/developers/api" },
{ name: "Gutendex", category: "Books", auth: "No Auth", https: true, cors: "Yes", desc: { 'zh-TW': "古騰堡計畫電子書索引", 'en': "Project Gutenberg ebook index" }, link: "https://gutendex.com/" },
{ name: "CoinGecko", category: "Finance", auth: "No Auth", https: true, cors: "Yes", desc: { 'zh-TW': "加密貨幣價格與市場數據", 'en': "Cryptocurrency prices and market data" }, link: "https://www.coingecko.com/en/api" },
{ name: "Binance", category: "Finance", auth: "No Auth", https: true, cors: "Yes", desc: { 'zh-TW': "幣安交易所公共數據", 'en': "Binance exchange public data" }, link: "https://github.com/binance/binance-spot-api-docs" },
{ name: "ExchangeRate-API", category: "Finance", auth: "ApiKey", https: true, cors: "Yes", desc: { 'zh-TW': "法幣匯率轉換", 'en': "Fiat currency exchange rates" }, link: "https://www.exchangerate-api.com/" },
{ name: "WallstreetBets", category: "Finance", auth: "No Auth", https: true, cors: "Yes", desc: { 'zh-TW': "WSB Reddit 討論趨勢", 'en': "WallStreetBets Reddit discussion trends" }, link: "https://wsb-api.onrender.com/" },
{ name: "Public Holidays", category: "Calendar", auth: "No Auth", https: true, cors: "Yes", desc: { 'zh-TW': "全球各國國定假日查詢", 'en': "Public holidays worldwide" }, link: "https://date.nager.at/" },
{ name: "Google Fonts", category: "Design", auth: "ApiKey", https: true, cors: "Yes", desc: { 'zh-TW': "Google 字體元數據", 'en': "Google Fonts metadata" }, link: "https://developers.google.com/fonts/docs/developer_api" },
{ name: "Unsplash", category: "Photography", auth: "ApiKey", https: true, cors: "Yes", desc: { 'zh-TW': "高畫質免版權圖片搜尋", 'en': "High-quality royalty-free image search" }, link: "https://unsplash.com/developers" },
{ name: "JSONPlaceholder", category: "Development", auth: "No Auth", https: true, cors: "Yes", desc: { 'zh-TW': "測試用的假資料 (Posts, Users)", 'en': "Fake data for testing (Posts, Users)" }, link: "https://jsonplaceholder.typicode.com/" },
{ name: "ReqRes", category: "Development", auth: "No Auth", https: true, cors: "Yes", desc: { 'zh-TW': "模擬 REST API 回應", 'en': "Mock REST API responses" }, link: "https://reqres.in/" },
{ name: "HttpBin", category: "Development", auth: "No Auth", https: true, cors: "Yes", desc: { 'zh-TW': "HTTP 請求與回應測試工具", 'en': "HTTP request and response testing tool" }, link: "https://httpbin.org/" },
{ name: "IPify", category: "Development", auth: "No Auth", https: true, cors: "Yes", desc: { 'zh-TW': "簡單獲取公共 IP 地址", 'en': "Simple public IP address lookup" }, link: "https://www.ipify.org/" },
{ name: "Genderize.io", category: "Demographics", auth: "No Auth", https: true, cors: "Yes", desc: { 'zh-TW': "根據名字預測性別", 'en': "Predict gender by name" }, link: "https://genderize.io/" },
{ name: "Agify.io", category: "Demographics", auth: "No Auth", https: true, cors: "Yes", desc: { 'zh-TW': "根據名字預測年齡", 'en': "Predict age by name" }, link: "https://agify.io/" },
{ name: "OpenWeather", category: "Weather", auth: "ApiKey", https: true, cors: "Yes", desc: { 'zh-TW': "全球天氣預報與歷史數據", 'en': "Global weather forecasts and historical data" }, link: "https://openweathermap.org/api" },
{ name: "7Timer!", category: "Weather", auth: "No Auth", https: true, cors: "Yes", desc: { 'zh-TW': "天文氣象預報", 'en': "Astronomical weather forecast" }, link: "http://www.7timer.info/doc.php" },
{ name: "NASA", category: "Science", auth: "ApiKey", https: true, cors: "Yes", desc: { 'zh-TW': "天文圖片、小行星數據等", 'en': "Astronomy images, asteroid data, and more" }, link: "https://api.nasa.gov/" },
{ name: "SpaceX", category: "Science", auth: "No Auth", https: true, cors: "Yes", desc: { 'zh-TW': "SpaceX 發射任務數據", 'en': "SpaceX launch mission data" }, link: "https://github.com/r-spacex/SpaceX-API" },
{ name: "Rest Countries", category: "Geocoding", auth: "No Auth", https: true, cors: "Yes", desc: { 'zh-TW': "國家資訊 (人口、貨幣、國旗)", 'en': "Country information (population, currency, flag)" }, link: "https://restcountries.com/" },
{ name: "Zipcopotamus", category: "Geocoding", auth: "No Auth", https: true, cors: "Yes", desc: { 'zh-TW': "郵遞區號查詢城市", 'en': "ZIP code to city lookup" }, link: "https://www.zippopotam.us/" },
{ name: "Spotify", category: "Music", auth: "OAuth", https: true, cors: "Yes", desc: { 'zh-TW': "音樂元數據、播放清單", 'en': "Music metadata and playlists" }, link: "https://developer.spotify.com/documentation/web-api/" },
{ name: "Last.fm", category: "Music", auth: "ApiKey", https: true, cors: "Yes", desc: { 'zh-TW': "音樂資料庫與聽歌紀錄", 'en': "Music database and listening history" }, link: "https://www.last.fm/api" },
{ name: "Lyrics.ovh", category: "Music", auth: "No Auth", https: true, cors: "Yes", desc: { 'zh-TW': "簡單歌詞查詢", 'en': "Simple lyrics lookup" }, link: "https://lyrics.ovh/" },
{ name: "OpenFoodFacts", category: "Food", auth: "No Auth", https: true, cors: "Yes", desc: { 'zh-TW': "全球食品成分數據庫", 'en': "Global food ingredients database" }, link: "https://world.openfoodfacts.org/data" },
{ name: "TheCocktailDB", category: "Food", auth: "ApiKey", https: true, cors: "Yes", desc: { 'zh-TW': "雞尾酒配方資料庫", 'en': "Cocktail recipe database" }, link: "https://www.thecocktaildb.com/api.php" },
{ name: "PunkAPI", category: "Food", auth: "No Auth", https: true, cors: "Yes", desc: { 'zh-TW': "BrewDog 啤酒配方", 'en': "BrewDog beer recipes" }, link: "https://punkapi.com/" },
{ name: "NewsAPI", category: "News", auth: "ApiKey", https: true, cors: "Yes", desc: { 'zh-TW': "全球新聞標題索引", 'en': "Global news headlines index" }, link: "https://newsapi.org/" },
{ name: "HackerNews", category: "News", auth: "No Auth", https: true, cors: "Yes", desc: { 'zh-TW': "官方 Firebase API", 'en': "Official Firebase API" }, link: "https://github.com/HackerNews/API" },
{ name: "Advice Slip", category: "Fun", auth: "No Auth", https: true, cors: "Yes", desc: { 'zh-TW': "隨機產生一條建議", 'en': "Generate random advice" }, link: "https://api.adviceslip.com/" },
{ name: "Bored API", category: "Fun", auth: "No Auth", https: true, cors: "Yes", desc: { 'zh-TW': "當你無聊時的活動建議", 'en': "Activity suggestions when you're bored" }, link: "https://www.boredapi.com/" },
{ name: "FunTranslations", category: "Fun", auth: "ApiKey", https: true, cors: "Yes", desc: { 'zh-TW': "尤達大師、精靈語翻譯", 'en': "Yoda, Elvish and other fun translations" }, link: "https://funtranslations.com/api" },
{ name: "Pokemon TCG", category: "Games", auth: "ApiKey", https: true, cors: "Yes", desc: { 'zh-TW': "寶可夢集換式卡牌資料", 'en': "Pokemon Trading Card Game data" }, link: "https://pokemontcg.io/" },
{ name: "OpenDota", category: "Games", auth: "No Auth", https: true, cors: "Yes", desc: { 'zh-TW': "Dota 2 比賽數據", 'en': "Dota 2 match data" }, link: "https://docs.opendota.com/" },
{ name: "CheapShark", category: "Games", auth: "No Auth", https: true, cors: "Yes", desc: { 'zh-TW': "PC 遊戲特價追蹤", 'en': "PC game deals tracker" }, link: "https://www.cheapshark.com/api/1.0/" },
{ name: "DictionaryAPI", category: "Utility", auth: "No Auth", https: true, cors: "Yes", desc: { 'zh-TW': "免費英語字典", 'en': "Free English dictionary" }, link: "https://dictionaryapi.dev/" },
{ name: "Urban Dictionary", category: "Utility", auth: "ApiKey", https: true, cors: "Yes", desc: { 'zh-TW': "俚語字典", 'en': "Slang dictionary" }, link: "https://rapidapi.com/community/api/urban-dictionary" },
{ name: "QR Code Generator", category: "Utility", auth: "No Auth", https: true, cors: "Yes", desc: { 'zh-TW': "生成 QR Code 圖片", 'en': "Generate QR code images" }, link: "https://goqr.me/api/" },
{ name: "Random User", category: "Development", auth: "No Auth", https: true, cors: "Yes", desc: { 'zh-TW': "產生隨機用戶個資", 'en': "Generate random user profiles" }, link: "https://randomuser.me/" },
{ name: "DiceBear", category: "Development", auth: "No Auth", https: true, cors: "Yes", desc: { 'zh-TW': "生成 SVG 頭像", 'en': "Generate SVG avatars" }, link: "https://dicebear.com/" },
{ name: "Mapbox", category: "Geocoding", auth: "ApiKey", https: true, cors: "Yes", desc: { 'zh-TW': "地圖與導航服務", 'en': "Maps and navigation services" }, link: "https://docs.mapbox.com/api/" },
{ name: "Discord", category: "Social", auth: "OAuth", https: true, cors: "Yes", desc: { 'zh-TW': "Discord 機器人與互動", 'en': "Discord bots and interactions" }, link: "https://discord.com/developers/docs/intro" },
{ name: "Telegram", category: "Social", auth: "ApiKey", https: true, cors: "Yes", desc: { 'zh-TW': "Telegram Bot API", 'en': "Telegram Bot API" }, link: "https://core.telegram.org/bots/api" }
];
// State Management
let currentData = [...apiData];
let categoryChart = null;
let authChart = null;
// --- 2. Chart Configuration & Rendering ---
// Helper to get color palette
const getColors = (count) => {
const colors = [
'#6366f1', '#10b981', '#f59e0b', '#ef4444', '#8b5cf6',
'#ec4899', '#06b6d4', '#84cc16', '#f97316', '#3b82f6'
];
return Array(count).fill().map((_, i) => colors[i % colors.length]);
};
function renderStats() {
// Update Text Counters
document.getElementById('total-apis-count').innerText = apiData.length;
document.getElementById('free-apis-count').innerText = apiData.filter(d => d.auth === 'No Auth').length;
// Prepare Data for Charts
// 1. Categories
const catCounts = {};
apiData.forEach(item => {
catCounts[item.category] = (catCounts[item.category] || 0) + 1;
});
const sortedCats = Object.entries(catCounts).sort((a,b) => b[1] - a[1]);
const catLabels = sortedCats.map(x => x[0]);
const catValues = sortedCats.map(x => x[1]);
// 2. Auth Types
const authCounts = {};
apiData.forEach(item => {
authCounts[item.auth] = (authCounts[item.auth] || 0) + 1;
});
// Chart 1: Categories (Doughnut)
const ctxCat = document.getElementById('categoryChart').getContext('2d');
if (categoryChart) categoryChart.destroy();
categoryChart = new Chart(ctxCat, {
type: 'doughnut',
data: {
labels: catLabels,
datasets: [{
data: catValues,
backgroundColor: getColors(catLabels.length),
borderWidth: 0,
hoverOffset: 4
}]
},
options: {
responsive: true,
maintainAspectRatio: false,
plugins: {
legend: { position: 'right', labels: { boxWidth: 10, font: { size: 10 } } },
tooltip: {
callbacks: {
label: function(context) {
let label = context.label || '';
if (label) label += ': ';
let value = context.parsed;
let total = context.dataset.data.reduce((a, b) => a + b, 0);
let percentage = Math.round((value / total) * 100) + '%';
return label + value + ' (' + percentage + ')';
}
}
}
},
layout: { padding: 10 }
}
});
// Chart 2: Auth Types (Bar)
const ctxAuth = document.getElementById('authChart').getContext('2d');
if (authChart) authChart.destroy();
authChart = new Chart(ctxAuth, {
type: 'bar',
data: {
labels: Object.keys(authCounts),
datasets: [{
label: currentLang === 'zh-TW' ? '數量' : 'Count',
data: Object.values(authCounts),
backgroundColor: ['#dcfce7', '#fff7ed', '#eff6ff'],
borderColor: ['#166534', '#9a3412', '#1e40af'],
borderWidth: 1,
borderRadius: 4
}]
},
options: {
responsive: true,
maintainAspectRatio: false,
indexAxis: 'y',
plugins: {
legend: { display: false }
},
scales: {
x: { beginAtZero: true, grid: { display: false } },
y: { grid: { display: false } }
}
}
});
// Populate Filter Dropdown
const selectInfo = document.getElementById('categoryFilter');
catLabels.sort().forEach(cat => {
const opt = document.createElement('option');
opt.value = cat;
opt.innerText = cat;
selectInfo.appendChild(opt);
});
}
// --- 3. Table/Grid Rendering & Logic ---
function getAuthBadge(authType) {
if (authType === 'No Auth') return `<span class="inline-flex items-center rounded-md px-2 py-1 text-xs font-medium badge-auth-none ring-1 ring-inset ring-green-600/20">${t('auth.none')}</span>`;
if (authType === 'ApiKey') return `<span class="inline-flex items-center rounded-md px-2 py-1 text-xs font-medium badge-auth-key ring-1 ring-inset ring-orange-600/20">${t('auth.apikey')}</span>`;
if (authType === 'OAuth') return `<span class="inline-flex items-center rounded-md px-2 py-1 text-xs font-medium badge-auth-oauth ring-1 ring-inset ring-blue-700/10">${t('auth.oauth')}</span>`;
return `<span class="inline-flex items-center rounded-md bg-gray-50 px-2 py-1 text-xs font-medium text-gray-600 ring-1 ring-inset ring-gray-500/10">${authType}</span>`;
}
function getHttpsIcon(isHttps) {
return isHttps
? `<i class="fa-solid fa-lock text-emerald-500" title="HTTPS Supported"></i>`
: `<i class="fa-solid fa-lock-open text-gray-400" title="HTTP Only"></i>`;
}
function renderTable(data) {
const tbody = document.getElementById('apiTableBody');
tbody.innerHTML = '';
const showingText = t('table.showingCount').replace('0 / 0', `${data.length} / ${apiData.length}`);
document.getElementById('showing-count').innerText = showingText;
if (data.length === 0) {
tbody.innerHTML = `<tr><td colspan="6" class="px-6 py-8 text-center text-slate-400 italic">${t('table.noResults')}</td></tr>`;
return;
}
data.forEach((item, index) => {
const tr = document.createElement('tr');
tr.className = "hover:bg-slate-50 transition-colors cursor-pointer group";
tr.onclick = (e) => {
if (e.target.closest('button') || e.target.closest('a')) return;
openModal(item);
};
const desc = typeof item.desc === 'object' ? item.desc[currentLang] || item.desc['zh-TW'] : item.desc;
tr.innerHTML = `
<td class="px-6 py-4">
<div class="font-medium text-slate-900 group-hover:text-indigo-600 transition-colors">${item.name}</div>
</td>
<td class="px-6 py-4">
<span class="inline-flex items-center rounded-full bg-slate-100 px-2.5 py-0.5 text-xs font-medium text-slate-800">
${item.category}
</span>
</td>
<td class="px-6 py-4 text-slate-500 truncate max-w-xs" title="${desc}">
${desc}
</td>
<td class="px-6 py-4">
${getAuthBadge(item.auth)}
</td>
<td class="px-6 py-4 text-center">
${getHttpsIcon(item.https)}
</td>
<td class="px-6 py-4 text-right">
<button onclick="copyLink('${item.link}')" class="text-slate-400 hover:text-indigo-600 p-2" title="${t('table.copyLink')}">
<i class="fa-regular fa-copy"></i>
</button>
<a href="${item.link}" target="_blank" class="text-slate-400 hover:text-indigo-600 p-2 ml-1" title="${t('table.openLink')}">
<i class="fa-solid fa-arrow-up-right-from-square"></i>
</a>
</td>
`;
tbody.appendChild(tr);
});
}
// --- 4. Filtering Logic ---
function filterData() {
const searchTerm = document.getElementById('searchInput').value.toLowerCase();
const category = document.getElementById('categoryFilter').value;
currentData = apiData.filter(item => {
const matchesSearch = item.name.toLowerCase().includes(searchTerm) ||
item.desc.toLowerCase().includes(searchTerm) ||
item.category.toLowerCase().includes(searchTerm);
const matchesCategory = category === 'All' || item.category === category;
return matchesSearch && matchesCategory;
});
renderTable(currentData);
}
// Event Listeners
document.getElementById('searchInput').addEventListener('input', filterData);
document.getElementById('categoryFilter').addEventListener('change', filterData);
// --- 5. Modal & Utilities ---
function openModal(item) {
document.getElementById('modalTitle').innerText = item.name;
document.getElementById('modalCategory').innerText = item.category;
const desc = typeof item.desc === 'object' ? item.desc[currentLang] || item.desc['zh-TW'] : item.desc;
document.getElementById('modalDesc').innerText = desc;
document.getElementById('modalAuth').innerHTML = getAuthBadge(item.auth);
document.getElementById('modalHttps').innerText = item.https ? t('modal.httpsYes') : t('modal.httpsNo');
document.getElementById('modalCors').innerText = item.cors;
document.getElementById('modalLink').href = item.link;
document.getElementById('detailModal').classList.remove('hidden');
}
function closeModal() {
document.getElementById('detailModal').classList.add('hidden');
}
function copyLink(url) {
navigator.clipboard.writeText(url).then(() => {
const toast = document.getElementById('toast');
toast.classList.remove('translate-y-20');
setTimeout(() => {
toast.classList.add('translate-y-20');
}, 2000);
});
}
function exportCSV() {
const headers = ["Name", "Category", "Description", "Auth", "HTTPS", "Link"];
const csvContent = "data:text/csv;charset=utf-8,\uFEFF"
+ headers.join(",") + "\n"
+ currentData.map(e => `"${e.name}","${e.category}","${e.desc}","${e.auth}","${e.https}","${e.link}"`).join("\n");
const encodedUri = encodeURI(csvContent);
const link = document.createElement("a");
link.setAttribute("href", encodedUri);
link.setAttribute("download", "public_apis_report.csv");
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
}
// --- Initialization ---
window.onload = function() {
// Apply saved language preference
switchLanguage(currentLang);
renderStats();
renderTable(apiData);
};
</script>
</body>
</html>