File size: 15,128 Bytes
a417501 | 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 | <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>API Reference | Unity NLP Architect</title>
<link rel="icon" type="image/x-icon" href="/static/favicon.ico">
<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>
<style>
.code-block {
font-family: 'Courier New', monospace;
background: rgba(0,0,0,0.7);
}
.endpoint-method {
width: 100px;
}
.endpoint-get {
background-color: rgba(56, 178, 172, 0.2);
color: #38b2ac;
}
.endpoint-post {
background-color: rgba(104, 211, 145, 0.2);
color: #68d391;
}
.param-required {
color: #f56565;
}
.param-optional {
color: #ecc94b;
}
</style>
</head>
<body class="bg-gray-900 text-white min-h-screen">
<!-- Navigation -->
<nav class="bg-gray-800 bg-opacity-80 backdrop-blur-md fixed w-full z-50">
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
<div class="flex items-center justify-between h-16">
<div class="flex items-center">
<div class="flex-shrink-0">
<i data-feather="code" class="text-purple-400 h-6 w-6"></i>
</div>
<div class="hidden md:block">
<div class="ml-10 flex items-baseline space-x-4">
<a href="index.html" class="text-gray-300 hover:bg-gray-700 hover:text-white px-3 py-2 rounded-md text-sm font-medium">Home</a>
<a href="docs.html" class="text-gray-300 hover:bg-gray-700 hover:text-white px-3 py-2 rounded-md text-sm font-medium">Docs</a>
<a href="api.html" class="bg-purple-800 text-white px-3 py-2 rounded-md text-sm font-medium">API</a>
<a href="#" class="text-gray-300 hover:bg-gray-700 hover:text-white px-3 py-2 rounded-md text-sm font-medium">Unity Bridge</a>
</div>
</div>
</div>
<div class="hidden md:block">
<div class="ml-4 flex items-center md:ml-6">
<button class="bg-purple-600 hover:bg-purple-700 text-white px-4 py-2 rounded-md text-sm font-medium flex items-center">
<i data-feather="key" class="mr-2 h-4 w-4"></i> Get API Key
</button>
</div>
</div>
<div class="-mr-2 flex md:hidden">
<button type="button" class="inline-flex items-center justify-center p-2 rounded-md text-gray-400 hover:text-white hover:bg-gray-700 focus:outline-none">
<i data-feather="menu"></i>
</button>
</div>
</div>
</div>
</nav>
<div class="pt-20 pb-12 px-4 sm:px-6 lg:px-8">
<div class="max-w-5xl mx-auto">
<h1 class="text-3xl font-bold mb-2">API Reference</h1>
<p class="text-xl text-gray-300 mb-8">
Integrate Unity NLP Architect directly into your development workflow with our REST API.
</p>
<div class="mb-12">
<h2 class="text-2xl font-bold mb-6 text-purple-400 border-b border-gray-700 pb-2">Authentication</h2>
<p class="text-gray-300 mb-4">
All API requests must include your API key in the Authorization header:
</p>
<div class="code-block p-4 rounded-lg mb-6">
<p class="text-gray-400">Authorization: Bearer YOUR_API_KEY</p>
</div>
<div class="bg-purple-900 bg-opacity-20 rounded-lg p-6 border border-purple-700 mb-8">
<div class="flex">
<div class="flex-shrink-0">
<i data-feather="alert-triangle" class="h-6 w-6 text-purple-400"></i>
</div>
<div class="ml-3">
<h3 class="text-lg font-medium text-white mb-2">Important</h3>
<p class="text-gray-300">
Keep your API key secure. Do not expose it in client-side code or public repositories.
</p>
</div>
</div>
</div>
</div>
<div class="mb-12">
<h2 class="text-2xl font-bold mb-6 text-purple-400 border-b border-gray-700 pb-2">Endpoints</h2>
<div class="bg-gray-800 rounded-lg overflow-hidden mb-8">
<div class="p-6 border-b border-gray-700">
<div class="flex items-start">
<div class="endpoint-method endpoint-post px-3 py-1 rounded text-sm font-medium mr-4">POST</div>
<div class="flex-1">
<h3 class="text-lg font-medium text-white">/v1/generate</h3>
<p class="text-gray-300 mt-1">Generate Unity code from natural language description</p>
</div>
</div>
</div>
<div class="p-6">
<h4 class="font-medium text-white mb-3">Request</h4>
<div class="code-block p-4 rounded-lg mb-6">
<p class="text-blue-300">POST https://api.unitynlparchitect.com/v1/generate</p>
<p class="text-gray-400">Headers:</p>
<p class="text-gray-400 ml-4">Content-Type: application/json</p>
<p class="text-gray-400 ml-4">Authorization: Bearer YOUR_API_KEY</p>
<p class="text-gray-400 mt-2">Body:</p>
<p class="text-white">{</p>
<p class="text-white ml-4">"description": "Create a 2D platformer character with jump and movement controls",</p>
<p class="text-white ml-4">"language": "csharp",</p>
<p class="text-white ml-4">"format": "unity"</p>
<p class="text-white">}</p>
</div>
<h4 class="font-medium text-white mb-3">Response</h4>
<div class="code-block p-4 rounded-lg">
<p class="text-green-400">200 OK</p>
<p class="text-white">{</p>
<p class="text-white ml-4">"code": "using UnityEngine;...",</p>
<p class="text-white ml-4">"suggestions": ["Consider adding double jump", "Add camera follow for better gameplay"],</p>
<p class="text-white ml-4">"warnings": []</p>
<p class="text-white">}</p>
</div>
</div>
</div>
<div class="bg-gray-800 rounded-lg overflow-hidden mb-8">
<div class="p-6 border-b border-gray-700">
<div class="flex items-start">
<div class="endpoint-method endpoint-get px-3 py-1 rounded text-sm font-medium mr-4">GET</div>
<div class="flex-1">
<h3 class="text-lg font-medium text-white">/v1/templates</h3>
<p class="text-gray-300 mt-1">List available code templates</p>
</div>
</div>
</div>
<div class="p-6">
<h4 class="font-medium text-white mb-3">Request</h4>
<div class="code-block p-4 rounded-lg mb-6">
<p class="text-blue-300">GET https://api.unitynlparchitect.com/v1/templates</p>
<p class="text-gray-400">Headers:</p>
<p class="text-gray-400 ml-4">Authorization: Bearer YOUR_API_KEY</p>
</div>
<h4 class="font-medium text-white mb-3">Response</h4>
<div class="code-block p-4 rounded-lg">
<p class="text-green-400">200 OK</p>
<p class="text-white">{</p>
<p class="text-white ml-4">"templates": [</p>
<p class="text-white ml-8">{</p>
<p class="text-white ml-12">"id": "platformer-2d",</p>
<p class="text-white ml-12">"name": "2D Platformer",</p>
<p class="text-white ml-12">"description": "Basic 2D platformer template with movement and jumping"</p>
<p class="text-white ml-8">},</p>
<p class="text-white ml-8">{ ... }</p>
<p class="text-white ml-4">]</p>
<p class="text-white">}</p>
</div>
</div>
</div>
</div>
<div class="mb-12">
<h2 class="text-2xl font-bold mb-6 text-purple-400 border-b border-gray-700 pb-2">Parameters</h2>
<div class="overflow-x-auto">
<table class="min-w-full divide-y divide-gray-700">
<thead class="bg-gray-800">
<tr>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-purple-400 uppercase tracking-wider">Parameter</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-purple-400 uppercase tracking-wider">Type</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-purple-400 uppercase tracking-wider">Required</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-purple-400 uppercase tracking-wider">Description</th>
</tr>
</thead>
<tbody class="bg-gray-800 bg-opacity-50 divide-y divide-gray-700">
<tr>
<td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-white">description</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-300">string</td>
<td class="px-6 py-4 whitespace-nowrap text-sm"><span class="param-required">Required</span></td>
<td class="px-6 py-4 text-sm text-gray-300">Natural language description of the game component</td>
</tr>
<tr>
<td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-white">language</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-300">string</td>
<td class="px-6 py-4 whitespace-nowrap text-sm"><span class="param-required">Required</span></td>
<td class="px-6 py-4 text-sm text-gray-300">Output language (e.g. "csharp")</td>
</tr>
<tr>
<td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-white">format</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-300">string</td>
<td class="px-6 py-4 whitespace-nowrap text-sm"><span class="param-optional">Optional</span></td>
<td class="px-6 py-4 text-sm text-gray-300">Output format (e.g. "unity", "pure")</td>
</tr>
<tr>
<td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-white">template</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-300">string</td>
<td class="px-6 py-4 whitespace-nowrap text-sm"><span class="param-optional">Optional</span></td>
<td class="px-6 py-4 text-sm text-gray-300">Template ID to use as base</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="bg-gray-800 rounded-lg p-6">
<h2 class="text-2xl font-bold mb-4 text-purple-400">Example Integration</h2>
<p class="text-gray-300 mb-4">Here's how you might call the API from a C# script in Unity:</p>
<div class="code-block p-4 rounded-lg mb-6">
<p class="text-blue-300">IEnumerator GenerateCode(string description) {</p>
<p class="text-blue-300 ml-4">UnityWebRequest request = new UnityWebRequest("https://api.unitynlparchitect.com/v1/generate", "POST");</p>
<p class="text-blue-300 ml-4">byte[] bodyRaw = Encoding.UTF8.GetBytes(JsonUtility.ToJson(new {</p>
<p class="text-blue-300 ml-8">description = description,</p>
<p class="text-blue-300 ml-8">language = "csharp",</p>
<p class="text-blue-300 ml-8">format = "unity"</p>
<p class="text-blue-300 ml-4">}));</p>
<p class="text-blue-300 ml-4">request.uploadHandler = new UploadHandlerRaw(bodyRaw);</p>
<p class="text-blue-300 ml-4">request.downloadHandler = new DownloadHandlerBuffer();</p>
<p class="text-blue-300 ml-4">request.SetRequestHeader("Content-Type", "application/json");</p>
<p class="text-blue-300 ml-4">request.SetRequestHeader("Authorization", "Bearer YOUR_API_KEY");</p>
<p class="text-blue-300 ml-4">yield return request.SendWebRequest();</p>
<p class="text-blue-300 ml-4">if (request.result != UnityWebRequest.Result.Success) {</p>
<p class="text-blue-300 ml-8">Debug.LogError(request.error);</p>
<p class="text-blue-300 ml-4">} else {</p>
<p class="text-blue-300 ml-8">var response = JsonUtility.FromJson<GenerationResponse>(request.downloadHandler.text);</p>
<p class="text-blue-300 ml-8">// Use response.code in your project</p>
<p class="text-blue-300 ml-4">}</p>
<p class="text-blue-300">}</p>
</div>
</div>
</div>
</div>
<script>
feather.replace();
</script>
</body>
</html>
|