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-code

Generate kode website dari deskripsi natural language

Request Body

ParameterTypeRequiredDescription
promptstringRequiredDeskripsi website atau komponen yang ingin di-generate
apiKeystringRequiredAPI Key dari ai.google.dev

Response Body

FieldTypeDescription
codestringKode lengkap yang dihasilkan (raw response dari AI)
htmlCodestringKode 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

TierRequestsTokens
Free60 per menitSesuai 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);