# AI Page Builder API API Reference

> **Version:** 1.0.0 | **Base URL:** `https://hifisys.com/api/v1/ai/page-builder` | **Provider:** Hifisys

## Overview
High-conversion website architecture API that generates semantic page sections, hero banners, and service copy.

## Authentication
All requests require a valid API key passed in the request header:
```http
X-API-Key: YOUR_API_KEY
Accept: application/json
```
Alternatively, pass as a standard Bearer token:
```http
Authorization: Bearer YOUR_API_KEY
```

## Available Subscription Plans
| Plan | Price | Rate Limit | Monthly Quota | Trial |
|---|---|---|---|---|
| Free Trial | Free Trial | 15 req/min | 200 | 7 Days |
| Starter | USD 49.00/month | 40 req/min | 5,000 | No |
| Business | USD 139.00/month | 120 req/min | 25,000 | No |
| Enterprise | USD 349.00/month | 400 req/min | 100,000 | No |

## API Endpoints
### `POST` /api/v1/ai/page-builder/generate-page
**Generate High-Fidelity Page (Prompt + References)**
> **Scope:** `page:generate` | **Content-Type:** `multipart/form-data or application/json`

Architects and generates complete, responsive landing pages adhering to prompt specifications, uploaded design references (screenshots, HTML/CSS files), and base theme contexts with up to 99% structural fidelity.

#### Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| `prompt` | `string` | **Yes** | Detailed textual prompt describing target layout, sections, spacing, styling, copy, and specific constraints. |
| `base_theme` | `string` | No | Base theme context to inherit: hifisys-current, modern-dark, minimal-light, corporate. Default: hifisys-current. |
| `output_format` | `string` | No | Target code formats: html, css, js, blade, all. Default: all. |
| `responsive` | `boolean` | No | Optimize layout for mobile (390px), tablet (768px), and desktop (1366px). Default: true. |
| `references[]` | `file(s)` | No | Multiple design references: Screenshots (PNG/JPG/WebP/SVG), HTML files, CSS files, or ZIP frontend bundles. |
| `reference_url` | `string` | No | Optional public URL of reference webpage for structural and layout inspiration analysis. |

#### Example Requests
**cURL:**
```bash
curl -X POST "https://hifisys.com/api/v1/ai/page-builder/generate-page" \
  -H "X-API-Key: YOUR_API_KEY" \
  -F "prompt=Create a premium AI SaaS landing page with dark hero, gold accents, 3 feature cards, pricing, and FAQ. Keep Hifisys header." \
  -F "base_theme=hifisys-current" \
  -F "output_format=all" \
  -F "references[]=@/path/to/screenshot.png" \
  -F "references[]=@/path/to/reference.html"
```
**JavaScript:**
```javascript
const formData = new FormData();
formData.append('prompt', 'Create a premium AI SaaS landing page with dark hero and gold accents.');
formData.append('base_theme', 'hifisys-current');
// Attach reference file if available:
// formData.append('references[]', fileInput.files[0]);

const response = await fetch('https://hifisys.com/api/v1/ai/page-builder/generate-page', {
  method: 'POST',
  headers: {
    'X-API-Key': 'YOUR_API_KEY',
    'Accept': 'application/json'
  },
  body: formData
});
const data = await response.json();
console.log(data);
```
**PHP:**
```php
$ch = curl_init('https://hifisys.com/api/v1/ai/page-builder/generate-page');
$postData = [
    'prompt' => 'Create a premium AI SaaS landing page with dark hero and gold accents.',
    'base_theme' => 'hifisys-current',
    'output_format' => 'all',
    // 'references[0]' => new CURLFile('/path/to/reference.png')
];
curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'X-API-Key: YOUR_API_KEY',
    'Accept: application/json'
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);
print_r($response);
```
**Python:**
```python
import requests

url = 'https://hifisys.com/api/v1/ai/page-builder/generate-page'
headers = {'X-API-Key': 'YOUR_API_KEY', 'Accept': 'application/json'}
data = {
    'prompt': 'Create a premium AI SaaS landing page with dark hero and gold accents.',
    'base_theme': 'hifisys-current',
    'output_format': 'all'
}
# files = {'references[]': open('reference.png', 'rb')}
response = requests.post(url, headers=headers, data=data)
print(response.json())
```

#### Sample Response (200 OK)
```json
{
    "success": true,
    "generation_id": "gen_9f82d19e0b1274a10c92",
    "message": "Page generated successfully with high fidelity.",
    "output": {
        "html": "<section class=\"pt-32 pb-20 bg-slate-950 text-white\">\n  <div class=\"max-w-7xl mx-auto px-6 text-center\">\n    <h1 class=\"text-5xl font-black text-amber-400\">Next-Gen AI Platform</h1>\n    <p class=\"mt-4 text-slate-300\">Architect scalable workflows effortlessly.</p>\n  </div>\n</section>",
        "css": "/* Custom High-Fidelity Design Tokens */\n.btn-gold { background: #E6A622; color: #111; font-weight: 700; border-radius: 12px; }",
        "js": "document.addEventListener('DOMContentLoaded', () => { console.log('Page interactive'); });",
        "blade": "@extends('layouts.app')\n@section('content')\n  <!-- Generated Content -->\n@endsection"
    },
    "reference_analysis": {
        "references_used": 2,
        "references_analyzed": [
            "screenshot.png",
            "reference.html"
        ],
        "layout_detected": "Dark Hero with 3-Column Feature Cards and Pricing Matrix",
        "fidelity_adherence": "Aggressive multi-reference matching applied."
    },
    "meta": {
        "base_theme": "hifisys-current",
        "generation_time_ms": 420,
        "quota_deducted": 1
    }
}
```

---

### `POST` /api/v1/ai/page-builder/generate-section
**Generate Modular Page Section**
> **Scope:** `page:section` | **Content-Type:** `application/json`

Generates an individual modular component block (Hero, Features, Pricing, Testimonials, FAQ) for seamless embedding into existing pages.

#### Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| `section_name` | `string` | **Yes** | Type of section: hero, features, pricing, testimonials, faq, cta. |
| `title` | `string` | **Yes** | Section heading title. |
| `brief` | `string` | No | Specific content requirements and bullet points. |
| `layout_style` | `string` | No | cards, grid, split, hero, testimonial. Default: cards. |

#### Example Requests
**cURL:**
```bash
curl -X POST "https://hifisys.com/api/v1/ai/page-builder/generate-section" \
  -H "X-API-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"section_name":"pricing","title":"Flexible Pricing Plans","layout_style":"cards"}'
```
**JavaScript:**
```javascript
const res = await fetch('https://hifisys.com/api/v1/ai/page-builder/generate-section', {
  method: 'POST',
  headers: { 'X-API-Key': 'YOUR_API_KEY', 'Content-Type': 'application/json' },
  body: JSON.stringify({ section_name: 'pricing', title: 'Flexible Pricing Plans' })
});
const data = await res.json();
```
**PHP:**
```php
$ch = curl_init('https://hifisys.com/api/v1/ai/page-builder/generate-section');
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode(['section_name' => 'pricing', 'title' => 'Flexible Pricing Plans']));
curl_setopt($ch, CURLOPT_HTTPHEADER, ['X-API-Key: YOUR_API_KEY', 'Content-Type: application/json']);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$data = json_decode(curl_exec($ch), true);
curl_close($ch);
```
**Python:**
```python
import requests
res = requests.post('https://hifisys.com/api/v1/ai/page-builder/generate-section', json={'section_name': 'pricing', 'title': 'Flexible Pricing Plans'}, headers={'X-API-Key': 'YOUR_API_KEY'})
print(res.json())
```

#### Sample Response (200 OK)
```json
{
    "success": true,
    "data": {
        "section_name": "pricing",
        "title": "Flexible Pricing Plans",
        "html_content": "<div class=\"py-16 bg-white\"><div class=\"grid md:grid-cols-3 gap-8\">...</div></div>",
        "meta": {
            "layout_style": "cards",
            "word_count": 140
        }
    }
}
```

---

### `POST` /api/v1/ai/page-builder/clean-html
**Sanitize & Clean HTML Markup**
> **Scope:** `page:section` | **Content-Type:** `application/json`

Sanitizes raw markup, strips malicious inline event listeners and script tags, and normalizes semantic element indentation.

#### Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| `html` | `string` | **Yes** | Raw HTML markup string to sanitize. |

#### Example Requests
**cURL:**
```bash
curl -X POST "https://hifisys.com/api/v1/ai/page-builder/clean-html" \
  -H "X-API-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"html":"<div onclick=\"alert(1)\">Safe Content</div>"}'
```
**JavaScript:**
```javascript
const res = await fetch('https://hifisys.com/api/v1/ai/page-builder/clean-html', {
  method: 'POST',
  headers: { 'X-API-Key': 'YOUR_API_KEY', 'Content-Type': 'application/json' },
  body: JSON.stringify({ html: '<div>Clean Content</div>' })
});
```
**PHP:**
```php
$ch = curl_init('https://hifisys.com/api/v1/ai/page-builder/clean-html');
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode(['html' => '<div>Clean Content</div>']));
curl_setopt($ch, CURLOPT_HTTPHEADER, ['X-API-Key: YOUR_API_KEY', 'Content-Type: application/json']);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$data = json_decode(curl_exec($ch), true);
curl_close($ch);
```
**Python:**
```python
import requests
res = requests.post('https://hifisys.com/api/v1/ai/page-builder/clean-html', json={'html': '<div>Clean Content</div>'}, headers={'X-API-Key': 'YOUR_API_KEY'})
print(res.json())
```

#### Sample Response (200 OK)
```json
{
    "success": true,
    "data": {
        "cleaned_html": "<div>Safe Content</div>",
        "sanitized": true
    }
}
```

---

## Security Best Practices
- Store API keys in environment variables; never commit to public VCS repositories.
- Enforce TLS 1.3 across all client integrations.
- Implement exponential backoff algorithms for rate-limit handling (HTTP 429).

## Support & Contact
- **Email:** info@hifisys.com
- **Phone:** +91 8890897064
- **Website:** [Hifisys](https://hifisys.com)