-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapi-docs.html
More file actions
368 lines (315 loc) · 10.8 KB
/
api-docs.html
File metadata and controls
368 lines (315 loc) · 10.8 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
---
layout: default
title: API Documentation
permalink: /api-docs/
---
<div class="container">
<h1>AIUL API Documentation</h1>
<p class="lead">
The AIUL API provides programmatic access to all license information, modifiers, combinations, and associated images for easy integration into external websites and applications.
</p>
<section id="quick-start" class="section">
<h2>Quick Start</h2>
<h3>Option 1: JavaScript Widget (Easiest)</h3>
<p>Add this script to your HTML and use simple data attributes:</p>
<pre><code><!-- Recommended: Use jsDelivr CDN for faster global loading -->
<script src="https://cdn.jsdelivr.net/gh/dmd-program/aiul@main/assets/js/aiul-widget.js"></script>
<div class="aiul-badge" data-license="NA"></div>
<div class="aiul-badge" data-license="CD" data-modifier="3D"></div>
<!-- Alternative: Direct from GitHub Pages -->
<script src="https://dmd-program.github.io/aiul/assets/js/aiul-widget.js"></script></code></pre>
<p><a href="{{ site.baseurl }}/assets/js/widget-examples.html">View live widget examples →</a></p>
<h3>Option 2: Direct API Access</h3>
<p>Fetch JSON data directly from the API endpoints:</p>
<pre><code>fetch('https://dmd-program.github.io/aiul/api/licenses.json')
.then(response => response.json())
.then(data => console.log(data));</code></pre>
</section>
<section id="endpoints" class="section">
<h2>API Endpoints</h2>
<div class="endpoint">
<h3>Main API</h3>
<code>GET https://dmd-program.github.io/aiul/api/v1.json</code>
<p>Returns complete AIUL data including licenses, modifiers, combinations, and usage levels.</p>
<a href="{{ site.baseurl }}/api/v1.json" target="_blank">View endpoint →</a>
</div>
<div class="endpoint">
<h3>Licenses</h3>
<code>GET https://dmd-program.github.io/aiul/api/licenses.json</code>
<p>Returns all available licenses with metadata and image URLs.</p>
<a href="{{ site.baseurl }}/api/licenses.json" target="_blank">View endpoint →</a>
</div>
<div class="endpoint">
<h3>Modifiers</h3>
<code>GET https://dmd-program.github.io/aiul/api/modifiers.json</code>
<p>Returns all available domain modifiers.</p>
<a href="{{ site.baseurl }}/api/modifiers.json" target="_blank">View endpoint →</a>
</div>
<div class="endpoint">
<h3>Combinations</h3>
<code>GET https://dmd-program.github.io/aiul/api/combinations.json</code>
<p>Returns all license + modifier combinations (48 total).</p>
<a href="{{ site.baseurl }}/api/combinations.json" target="_blank">View endpoint →</a>
</div>
</section>
<section id="examples" class="section">
<h2>Usage Examples</h2>
<h3>Display License Badge</h3>
<pre><code>async function displayLicenseBadge(licenseCode) {
const response = await fetch('https://dmd-program.github.io/aiul/api/licenses.json');
const data = await response.json();
const license = data.data.find(l => l.code === licenseCode);
if (license) {
document.body.innerHTML += `
<a href="${license.url}" target="_blank">
<img src="${license.image}" alt="${license.title}" />
</a>
`;
}
}
displayLicenseBadge('NA');</code></pre>
<h3>Display Combination Badge</h3>
<pre><code>async function displayCombination(licenseCode, modifierCode) {
const response = await fetch('https://dmd-program.github.io/aiul/api/combinations.json');
const data = await response.json();
const code = `${licenseCode}-${modifierCode}`;
const combination = data.data.find(c => c.code === code);
if (combination) {
document.body.innerHTML += `
<a href="${combination.url}" target="_blank">
<img src="${combination.image}"
alt="${combination.code}"
title="${combination.license.title} - ${combination.modifier.title}" />
</a>
`;
}
}
displayCombination('CD', '3D');</code></pre>
<h3>React Component</h3>
<pre><code>import React, { useState, useEffect } from 'react';
function AIULBadge({ licenseCode, modifierCode = null }) {
const [data, setData] = useState(null);
useEffect(() => {
const endpoint = modifierCode
? 'https://dmd-program.github.io/aiul/api/combinations.json'
: 'https://dmd-program.github.io/aiul/api/licenses.json';
fetch(endpoint)
.then(res => res.json())
.then(result => {
let item;
if (modifierCode) {
const code = `${licenseCode}-${modifierCode}`;
item = result.data.find(c => c.code === code);
} else {
item = result.data.find(l => l.code === licenseCode);
}
setData(item);
});
}, [licenseCode, modifierCode]);
if (!data) return <div>Loading...</div>;
return (
<a href={data.url} target="_blank" rel="noopener noreferrer">
<img src={data.image} alt={data.code || data.title} />
</a>
);
}
export default AIULBadge;</code></pre>
<h3>Nuxt 4 / Vue 3 Component</h3>
<pre><code><template>
<a
v-if="badge"
:href="badge.url"
target="_blank"
rel="noopener noreferrer"
class="aiul-badge-link"
>
<img
:src="badge.image"
:alt="badge.code || badge.title"
:title="badgeTitle"
:style="{ height: height, width: 'auto' }"
/>
</a>
<div v-else-if="loading">Loading...</div>
<div v-else-if="error" class="error">{{ error }}</div>
</template>
<script setup lang="ts">
import { ref, computed, onMounted } from 'vue'
interface Props {
licenseCode: string
modifierCode?: string
height?: string
}
const props = withDefaults(defineProps<Props>(), {
modifierCode: undefined,
height: '28px'
})
const badge = ref(null)
const loading = ref(true)
const error = ref('')
const badgeTitle = computed(() => {
if (!badge.value) return ''
if (props.modifierCode) {
return `${badge.value.license.title} - ${badge.value.modifier.title}`
}
return `${badge.value.title} - ${badge.value.fullName}`
})
const loadBadge = async () => {
try {
const endpoint = props.modifierCode
? 'https://dmd-program.github.io/aiul/api/combinations.json'
: 'https://dmd-program.github.io/aiul/api/licenses.json'
const response = await fetch(endpoint)
if (!response.ok) throw new Error('Failed to fetch badge data')
const data = await response.json()
if (props.modifierCode) {
const code = `${props.licenseCode}-${props.modifierCode}`
badge.value = data.data.find((c: any) => c.code === code)
if (!badge.value) {
error.value = `Combination not found: ${code}`
}
} else {
badge.value = data.data.find((l: any) => l.code === props.licenseCode)
if (!badge.value) {
error.value = `License not found: ${props.licenseCode}`
}
}
} catch (e) {
error.value = e instanceof Error ? e.message : 'Failed to load badge'
} finally {
loading.value = false
}
}
onMounted(() => {
loadBadge()
})
</script>
<style scoped>
.aiul-badge-link {
display: inline-block;
text-decoration: none;
}
.error {
color: #dc3545;
font-size: 0.9em;
}
</style></code></pre>
<p><strong>Usage in Nuxt 4:</strong></p>
<pre><code><!-- components/AIULBadge.vue (save the component above) -->
<!-- In your page or component -->
<template>
<div>
<AIULBadge license-code="NA" />
<AIULBadge license-code="CD" modifier-code="3D" />
<AIULBadge license-code="IU" modifier-code="WR" height="70px" />
</div>
</template></code></pre>
<p><strong>With Composable (for reusability):</strong></p>
<pre><code>// composables/useAIULBadge.ts
export const useAIULBadge = () => {
const fetchBadge = async (licenseCode: string, modifierCode?: string) => {
const endpoint = modifierCode
? 'https://dmd-program.github.io/aiul/api/combinations.json'
: 'https://dmd-program.github.io/aiul/api/licenses.json'
const { data } = await useFetch(endpoint)
if (!data.value) throw new Error('Failed to fetch badge data')
if (modifierCode) {
const code = `${licenseCode}-${modifierCode}`
return data.value.data.find((c: any) => c.code === code)
}
return data.value.data.find((l: any) => l.code === licenseCode)
}
return {
fetchBadge
}
}
// Usage in component
<script setup>
const { fetchBadge } = useAIULBadge()
const badge = await fetchBadge('CD', '3D')
</script></code></pre>
</section>
<section id="response-format" class="section">
<h2>Response Format</h2>
<h3>License Object</h3>
<pre><code>{
"id": "na",
"code": "NA",
"title": "AIUL-NA",
"fullName": "Not Allowed",
"version": "1.0.0",
"url": "https://dmd-program.github.io/aiul/licenses/na/1.0.0/",
"image": "https://dmd-program.github.io/aiul/assets/images/licenses/aiul-na.png",
"released": "2025-12-09"
}</code></pre>
<h3>Combination Object</h3>
<pre><code>{
"id": "na-3d",
"code": "NA-3D",
"license": {
"id": "na",
"code": "NA",
"title": "AIUL-NA"
},
"modifier": {
"id": "3d",
"code": "3D",
"title": "3D Design"
},
"url": "https://dmd-program.github.io/aiul/combinations/na-3d.html",
"image": "https://dmd-program.github.io/aiul/assets/images/licenses/aiul-na-3d.png"
}</code></pre>
</section>
<section id="cors" class="section">
<h2>CORS & Usage</h2>
<p>All API endpoints support CORS and can be accessed from any domain. There are no rate limits, but please cache responses appropriately.</p>
<p>The API data is regenerated on every site build. Check the <code>generated</code> timestamp in responses to see when data was last updated.</p>
</section>
<section id="resources" class="section">
<h2>Additional Resources</h2>
<ul>
<li><a href="{{ site.baseurl }}/assets/js/widget-examples.html">Interactive Widget Examples</a></li>
<li><a href="{{ site.baseurl }}/api/README.md">Complete API Documentation (Markdown)</a></li>
<li><a href="{{ site.baseurl }}/guide.html">AIUL Usage Guide</a></li>
<li><a href="https://github.com/dmd-program/aiul">GitHub Repository</a></li>
</ul>
</section>
</div>
<style>
.section {
margin: 40px 0;
}
.endpoint {
background: #f8f9fa;
padding: 20px;
margin: 20px 0;
border-left: 4px solid #007bff;
border-radius: 4px;
}
.endpoint code {
background: #e9ecef;
padding: 8px 12px;
display: inline-block;
margin: 10px 0;
border-radius: 4px;
font-size: 0.9em;
}
pre {
background: #2d2d2d;
color: #f8f8f2;
padding: 20px;
border-radius: 4px;
overflow-x: auto;
margin: 20px 0;
}
pre code {
background: none;
padding: 0;
color: inherit;
}
.lead {
font-size: 1.2em;
color: #666;
margin-bottom: 30px;
}
</style>