API Reference
API Documentation
Dokumentasi lengkap API AI Buildify untuk integrasi dengan aplikasi Anda.
Base URL
https://your-domain.com🔐 Authentication
AI Buildify menggunakan API Key dari Google AI Studio untuk autentikasi. API Key dikirim dalam body request, bukan header.
⚠️
Penting
Jangan expose API Key Anda di client-side code produksi. Gunakan environment variables dan backend proxy untuk keamanan.
📡 Endpoints
POST
/api/generate-codeGenerate kode website dari deskripsi natural language
Request Body
| Parameter | Type | Required | Description |
|---|---|---|---|
| prompt | string | Required | Deskripsi website atau komponen yang ingin di-generate |
| apiKey | string | Required | API Key dari ai.google.dev |
Response Body
| Field | Type | Description |
|---|---|---|
| code | string | Kode lengkap yang dihasilkan (raw response dari AI) |
| htmlCode | string | Kode HTML yang sudah di-extract untuk preview |
Example Request
{
"prompt": "Buat landing page startup dengan hero section gradient, fitur cards, dan footer",
"apiKey": "your-api-key-here"
}Example Response
{
"code": "<!DOCTYPE html>\n<html lang=\"id\">\n<head>...",
"htmlCode": "<!DOCTYPE html>\n<html lang=\"id\">\n<head>..."
}Status Codes
200Success - Kode berhasil di-generate
400Bad Request - Prompt atau API Key tidak valid
401Unauthorized - API Key tidak valid atau expired
500Internal Server Error - Terjadi kesalahan server
⏱️ Rate Limits
| Tier | Requests | Tokens |
|---|---|---|
| Free | 60 per menit | Sesuai limit Google AI |
🔧 Quick Integration
JavaScript / Fetch Example
const generateCode = async (prompt, apiKey) => {
const response = await fetch('/api/generate-code', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ prompt, apiKey }),
});
if (!response.ok) {
throw new Error('Failed to generate code');
}
return response.json();
};
// Usage
const result = await generateCode(
'Buat landing page dengan hero section',
'your-api-key'
);
console.log(result.htmlCode);