praspey's picture
create a Unity NLP Architect
a417501 verified
Raw History Blame Contribute Delete
15.1 kB
<!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&lt;GenerationResponse&gt;(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>