API Documentation Writer
Run ID: 69ccd96a3e7fb09ff16a5a062026-04-01Development
PantheraHive BOS
BOS Dashboard

API Documentation: Product Management API v1.0

Welcome to the comprehensive documentation for the PantheraHive Product Management API! This guide provides everything you need to integrate your applications with our powerful backend, enabling seamless management of products, categories, and inventory. Our API is designed for developers, offering a robust, secure, and easy-to-use interface to build dynamic and scalable product-centric solutions.


Overview

The Product Management API allows you to programmatically interact with your product catalog, including creating, retrieving, updating, and deleting product information, managing categories, and monitoring inventory levels. Whether you're building an e-commerce platform, an internal product management tool, or integrating with third-party services, this API provides the flexibility and power you need.

Key Features:


Getting Started

To begin using the PantheraHive Product Management API, follow these simple steps:

  1. Obtain Your API Key: Register an application in your PantheraHive Developer Dashboard to generate your unique API key.
  2. Authenticate Your Requests: Include your API key in all requests as described in the [Authentication](#authentication) section.
  3. Explore Endpoints: Dive into the [API Endpoints](#api-endpoints) section to understand available resources and operations.
  4. Start Building: Use your preferred HTTP client or one of our SDKs to make your first API call!

Ready to innovate?

[Sign Up for an API Key Today!](#)


Authentication

All requests to the Product Management API must be authenticated using an API Key. This key identifies your application and ensures secure access to your data.

API Key via Header

Include your API Key in the X-API-Key HTTP header for every request.

Header Name: X-API-Key

Header Value: YOUR_API_KEY

Example:

text • 1,807 chars
---

### **Rate Limiting**

To ensure fair usage and maintain API stability, requests are subject to rate limiting.
Currently, the limit is **100 requests per minute per API Key**.

If you exceed the rate limit, you will receive a `429 Too Many Requests` HTTP status code. The response headers will also provide information about your current rate limit status:

*   `X-RateLimit-Limit`: The maximum number of requests allowed in the current window.
*   `X-RateLimit-Remaining`: The number of requests remaining in the current window.
*   `X-RateLimit-Reset`: The UTC epoch timestamp when the current rate limit window resets.

We recommend implementing exponential backoff in your application to gracefully handle rate limit errors.

---

### **API Endpoints**

This section details all available API endpoints, their HTTP methods, parameters, and expected responses.

#### **Products**

##### **1. List All Products**

Retrieves a paginated list of all products in your catalog.

*   **Endpoint:** `/products`
*   **Method:** `GET`
*   **Description:** Returns an array of product objects. Supports filtering and pagination.

**Query Parameters:**

| Parameter | Type   | Description                                            | Required | Default |
| :-------- | :----- | :----------------------------------------------------- | :------- | :------ |
| `limit`   | `integer` | Maximum number of products to return per page (max 100). | No       | `10`    |
| `offset`  | `integer` | Number of products to skip for pagination.             | No       | `0`     |
| `category_id` | `string` | Filter products by a specific category ID.             | No       |         |
| `status`  | `string` | Filter products by their status (`active`, `draft`, `archived`). | No       |         |

**Example Request:**

Sandboxed live preview

Research Output: The API Documentation Writer's Guide

This document provides a comprehensive overview and research output for the role and essential components of an API Documentation Writer. It details the core responsibilities, best practices, key elements, and tools necessary to produce high-quality, effective API documentation.


1. Introduction to the API Documentation Writer Role

The API Documentation Writer plays a crucial role in the successful adoption and utilization of Application Programming Interfaces (APIs). Their primary objective is to bridge the gap between complex technical functionalities and the developers who will consume them, ensuring clarity, accuracy, and ease of use. This role requires a unique blend of technical understanding, strong writing skills, and an empathetic perspective towards the target audience.

2. Core Responsibilities & Essential Skills

An API Documentation Writer is responsible for creating, maintaining, and improving all documentation related to an API.

2.1. Core Responsibilities

  • Understanding APIs: Deeply comprehending the functionality, architecture, and use cases of the APIs being documented. This often involves interacting with engineers, product managers, and QA teams.
  • Content Creation: Writing clear, concise, accurate, and comprehensive documentation, including conceptual guides, tutorials, API references, quickstart guides, and troubleshooting sections.
  • Audience Analysis: Identifying and understanding the target audience (e.g., backend developers, frontend developers, mobile developers, data scientists) and tailoring content to their specific needs and technical proficiency.
  • Information Architecture: Structuring documentation logically for easy navigation and discoverability.
  • Tooling & Standards Adherence: Utilizing documentation tools (e.g., Swagger/OpenAPI, Postman, static site generators) and adhering to industry standards and internal style guides.
  • Maintenance & Updates: Regularly reviewing and updating existing documentation to reflect API changes, new features, and user feedback.
  • Collaboration: Working closely with engineering, product, and support teams to ensure documentation accuracy and completeness.
  • Testing & Validation: Verifying that code examples, API calls, and setup instructions are functional and correct.

2.2. Essential Skills

  • Technical Aptitude: Ability to quickly grasp complex technical concepts, read code (e.g., JSON, XML, basic programming languages), and understand API request/response cycles.
  • Exceptional Writing & Editing: Producing clear, grammatically correct, and engaging content. Strong command of English (or the primary language of documentation).
  • Empathy & User-Centric Thinking: Ability to put oneself in the user's shoes, anticipate their questions, and guide them through complex processes.
  • Attention to Detail: Ensuring accuracy in technical specifications, code examples, and procedural steps.
  • Communication & Interpersonal Skills: Effectively interviewing subject matter experts and collaborating with cross-functional teams.
  • Problem-Solving: Identifying gaps in documentation, troubleshooting issues, and finding effective ways to explain complex topics.
  • Tool Proficiency: Familiarity with documentation platforms, version control systems (e.g., Git), and API testing tools.

3. Principles of Effective API Documentation

High-quality API documentation adheres to several core principles to maximize its utility and user satisfaction.

  • Accuracy: All technical details, code examples, and instructions must be correct and up-to-date. Inaccuracies erode trust and waste developer time.
  • Clarity & Conciseness: Use simple, direct language. Avoid jargon where possible, or clearly define it. Get straight to the point without sacrificing necessary detail.
  • Completeness: Cover all necessary aspects of the API, from setup and authentication to error handling and advanced use cases.
  • Consistency: Maintain a consistent voice, tone, terminology, and formatting throughout the documentation. Use a style guide.
  • Discoverability & Navigability: Ensure users can easily find the information they need through clear navigation, search functionality, and logical organization.
  • Actionability: Provide practical, runnable code examples and clear instructions that users can follow to achieve their goals.
  • User-Centricity: Design the documentation with the user's journey in mind, anticipating their questions and providing answers proactively.
  • Up-to-Date: Documentation must evolve with the API. Implement processes for continuous review and updates.

4. Key Components of Comprehensive API Documentation

Effective API documentation typically includes a structured set of components designed to serve different user needs.

4.1. Getting Started / Quickstart Guide

  • Overview: A high-level description of what the API does and its primary use cases.
  • Authentication: Clear instructions on how to obtain API keys, tokens, or credentials, and how to authenticate requests.
  • First API Call: A simple, copy-paste example demonstrating how to make a successful request to a basic endpoint.
  • Setup: Any necessary prerequisites, SDK installations, or environment configurations.

4.2. Concepts & Guides

  • Core Concepts: Explanations of fundamental terms, data models, and architectural patterns relevant to the API.
  • Use Cases / Tutorials: Step-by-step guides for common workflows and specific scenarios.
  • Best Practices: Recommendations for optimal API usage, performance, and security.

4.3. API Reference

  • Endpoints: Detailed descriptions for each available endpoint, including:

* Method: (e.g., GET, POST, PUT, DELETE)

* URL/Path: The full endpoint URL.

* Description: What the endpoint does.

* Parameters:

* Path Parameters: Required values in the URL.

* Query Parameters: Optional key-value pairs for filtering/sorting.

* Request Body: Structure and fields for POST/PUT requests (JSON/XML schema).

* Headers: Required or optional headers (e.g., Content-Type, Authorization).

* Request Examples: Code snippets in various languages (cURL, Python, Node.js, Ruby, Java, etc.) for making requests.

* Response Examples: Sample successful and error responses, including status codes and response body schemas.

* Response Status Codes: Explanation of common HTTP status codes (200 OK, 201 Created, 400 Bad Request, 401 Unauthorized, 404 Not Found, 500 Internal Server Error, etc.).

4.4. Authentication & Authorization

  • Methods Supported: (e.g., API Keys, OAuth 2.0, Bearer Tokens).
  • Detailed Flow: Step-by-step guides for implementing each authentication method.
  • Security Best Practices: Recommendations for securing credentials and requests.

4.5. Error Handling

  • Common Error Codes: A comprehensive list of API-specific error codes and their meanings.
  • Troubleshooting: Guidance on how to diagnose and resolve common issues.
  • Rate Limiting: Details on request limits and how to handle 429 Too Many Requests responses.

4.6. SDKs & Libraries

  • Available SDKs: Links to official or community-contributed Software Development Kits.
  • Installation & Usage: Instructions for integrating and using SDKs.

4.7. Webhooks

  • Overview: Explanation of webhook functionality and use cases.
  • Event Types: List of available webhook events.
  • Payload Structure: Example webhook payloads.
  • Verification: Instructions for verifying webhook signatures.

4.8. Changelog / Versioning

  • API Versioning Strategy: How the API is versioned (e.g., URL-based, header-based).
  • Changelog: A chronological list of changes, new features, deprecations, and bug fixes for each API version.
  • Deprecation Policy: Clear communication regarding the lifecycle of API versions and features.

4.9. Support & Resources

  • FAQ: Frequently Asked Questions.
  • Support Channels: How to get help (e.g., community forums, support tickets, email).
  • Terms of Service / Legal: Links to relevant legal documents.

5. Tools & Technologies for API Documentation

The landscape of API documentation tools is diverse, ranging from simple markdown editors to sophisticated interactive platforms.

  • API Specification Formats:

* OpenAPI Specification (OAS) / Swagger: The most widely adopted standard for defining RESTful APIs. It allows for machine-readable API descriptions that can generate interactive documentation, client SDKs, and server stubs.

* Postman Collections: While primarily an API development and testing tool, Postman can also generate documentation from its collections.

* AsyncAPI: For event-driven architectures and message-based APIs.

  • Documentation Generators / Platforms:

* Swagger UI / Swagger Editor: Tools that render OpenAPI specifications into interactive, human-readable documentation.

* Postman Documentation: Built-in feature for generating and hosting documentation from Postman Collections.

* Redoc: An open-source tool that generates beautiful, responsive API documentation from OpenAPI specifications.

* Stoplight: A comprehensive platform for API design, documentation, and governance, built on OpenAPI.

* ReadMe.io: A popular platform that combines interactive documentation, developer hubs, and API analytics.

* Docusaurus / Next.js / Jekyll / Hugo: Static site generators often used to build custom developer portals, integrating API references with conceptual guides.

* Markdown editors: For writing conceptual guides and tutorials (e.g., VS Code, Typora).

  • Version Control:

* Git / GitHub / GitLab / Bitbucket: Essential for collaborative writing, tracking changes, and managing documentation alongside code.

6. Workflow & Best Practices for API Documentation Creation

A structured approach ensures efficient and high-quality documentation.

  1. Understand the API:

* Attend design meetings, review API specifications, and discuss with engineers.

* Use the API yourself: make calls, test endpoints, and understand typical workflows.

  1. Define Audience & Goals:

* Who are the primary users? What are their technical skill levels?

* What do they need to achieve with the API?

* What is the desired outcome of the documentation (e.g., quick adoption, reduced support tickets)?

  1. Outline & Structure:

* Create a logical information architecture (see Section 4).

* Develop a table of contents and wireframe the documentation portal.

  1. Write Content:

* Start with the "Getting Started" guide to provide immediate value.

* Draft conceptual guides and tutorials, focusing on user journeys.

* Develop the API reference, often generated from OpenAPI specs, then enriched with explanations and examples.

* Write clear, accurate code examples in multiple relevant languages.

  1. Review & Validate:

* Technical Review: Have engineers verify accuracy and completeness.

* Editorial Review: Check for clarity, grammar, consistency, and adherence to style guides.

* User Testing: Ask target users (internal or external) to follow the documentation and provide feedback.

* Self-Testing: Run all code examples and follow all instructions personally.

  1. Publish & Deploy:

* Utilize chosen documentation platform or static site generator.

* Ensure proper versioning and accessibility.

  1. Maintain & Iterate:

* Establish a feedback loop (e.g., analytics, user comments, support tickets).

* Regularly update documentation to reflect API changes, bug fixes, and user feedback.

* Schedule periodic comprehensive reviews.

7. Measuring Success & Continuous Improvement

Effective API documentation is not a one-time project but an ongoing effort.

  • Key Performance Indicators (KPIs):

* API Adoption Rate: How quickly new users start using the API.

* Time to First Hello World: How long it takes a new developer to make their first successful API call.

* Support Ticket Volume: Reduction in API-related support requests.

* Documentation Engagement: Page views, time on page, search queries within the documentation portal.

* Feedback Scores: Ratings or comments on documentation quality.

  • Feedback Mechanisms:

* Integrate feedback widgets (e.g., "Was this helpful?") directly into the documentation.

* Monitor community forums and developer discussions.

* Conduct user surveys and interviews.

  • Regular Audits: Periodically review the entire documentation set for accuracy, completeness, and adherence to current best practices.

This research provides a foundational understanding for anyone embarking on or currently engaged in the API Documentation Writer role, emphasizing the blend of technical acumen, writing prowess, and user empathy required for success.

json

{

"code": "DUPLICATE_SKU",

"message": "A product with the SKU 'WALLET-LR-PREM' already exists.",

"details": [

{

"field": "sku",

"value": "WALLET-LR-PREM",

"issue": "must

gemini Output

API Documentation: Product Catalog Management API

This document provides comprehensive technical documentation for the Product Catalog Management API. It details how to authenticate, interact with various endpoints, understand data structures, and handle potential errors. This API is designed to allow external applications to programmatically manage product listings, including retrieval, creation, updates, and deletion.


1. Introduction

The Product Catalog Management API provides a robust and secure interface for interacting with your product database. Developers can leverage this API to build custom applications, integrate with e-commerce platforms, or automate product data workflows.

Key Features:

  • Secure Access: All requests are secured using API Keys.
  • RESTful Design: Predictable, resource-oriented URLs and standard HTTP response codes.
  • JSON Payloads: All request and response bodies are formatted as JSON.
  • Comprehensive Operations: Full CRUD (Create, Read, Update, Delete) capabilities for product resources.

2. Authentication

All requests to the Product Catalog Management API must be authenticated. We use API Key authentication.

2.1. API Key

To authenticate your requests, you must include your unique API Key in the X-API-Key HTTP header for every request.

How to obtain your API Key:

  1. Log in to your Developer Dashboard.
  2. Navigate to the "API Keys" section.
  3. Generate a new API Key if you don't have one, or use an existing active key.

Example Request Header:


GET /api/v1/products HTTP/1.1
Host: api.example.com
X-API-Key: YOUR_SECURE_API_KEY_HERE
Content-Type: application/json

Security Best Practices:

  • Keep your API Key confidential. Do not expose it in client-side code, public repositories, or unsecured environments.
  • Use environment variables or a secure configuration management system to store your API Key.
  • Rotate your API Keys regularly.

3. Base URL

All API requests should be made to the following base URL:

https://api.example.com/api/v1


4. Data Formats

  • Request Body: All POST and PUT requests require a JSON payload. The Content-Type header must be set to application/json.
  • Response Body: All successful responses will return data in JSON format. The Content-Type header will be application/json.
  • Dates: All date and time values are returned in ISO 8601 format (e.g., YYYY-MM-DDTHH:MM:SSZ).

5. Endpoints

This section details all available endpoints, their methods, parameters, request bodies, and expected responses.

5.1. Products

##### 5.1.1. List All Products

Retrieve a list of all products in the catalog, with optional filtering and pagination.

  • Method: GET
  • Path: /products

Query Parameters:

| Parameter | Type | Description | Required | Default |

| :-------- | :----- | :--------------------------------------------------------------------------- | :------- | :------ |

| limit | Integer | Maximum number of products to return (1-100). | No | 10 |

| offset | Integer | The number of products to skip before starting to collect the result set. | No | 0 |

| category| String | Filter products by category name. | No | All |

| min_price| Decimal | Filter products with a price greater than or equal to this value. | No | - |

| max_price| Decimal | Filter products with a price less than or equal to this value. | No | - |

Example Request:


GET /api/v1/products?limit=5&category=electronics HTTP/1.1
Host: api.example.com
X-API-Key: YOUR_SECURE_API_KEY_HERE

Example Response (Status: 200 OK):


{
  "total": 2,
  "limit": 5,
  "offset": 0,
  "products": [
    {
      "id": "prod_abc123",
      "name": "Wireless Bluetooth Headphones",
      "description": "High-fidelity audio with active noise cancellation.",
      "price": 199.99,
      "currency": "USD",
      "category": "Electronics",
      "sku": "WH-BT-001",
      "stock": 150,
      "created_at": "2023-10-26T10:00:00Z",
      "updated_at": "2023-10-26T10:00:00Z"
    },
    {
      "id": "prod_def456",
      "name": "Smartwatch Pro",
      "description": "Track your fitness, notifications, and more.",
      "price": 249.00,
      "currency": "USD",
      "category": "Electronics",
      "sku": "SW-PRO-001",
      "stock": 75,
      "created_at": "2023-10-25T14:30:00Z",
      "updated_at": "2023-10-26T11:15:00Z"
    }
  ]
}

##### 5.1.2. Get a Single Product by ID

Retrieve detailed information for a specific product.

  • Method: GET
  • Path: /products/{id}

Path Parameters:

| Parameter | Type | Description | Required |

| :-------- | :----- | :---------------------- | :------- |

| id | String | The unique ID of the product. | Yes |

Example Request:


GET /api/v1/products/prod_abc123 HTTP/1.1
Host: api.example.com
X-API-Key: YOUR_SECURE_API_KEY_HERE

Example Response (Status: 200 OK):


{
  "id": "prod_abc123",
  "name": "Wireless Bluetooth Headphones",
  "description": "High-fidelity audio with active noise cancellation.",
  "price": 199.99,
  "currency": "USD",
  "category": "Electronics",
  "sku": "WH-BT-001",
  "stock": 150,
  "created_at": "2023-10-26T10:00:00Z",
  "updated_at": "2023-10-26T10:00:00Z"
}

Error Response (Status: 404 Not Found):


{
  "code": "product_not_found",
  "message": "Product with ID 'prod_xyz789' not found."
}

##### 5.1.3. Create a New Product

Add a new product to the catalog.

  • Method: POST
  • Path: /products

Request Body (JSON):

| Field | Type | Description | Required |

| :----------- | :------ | :-------------------------------------------- | :------- |

| name | String | The name of the product. | Yes |

| description| String | A detailed description of the product. | No |

| price | Decimal | The price of the product. Must be positive. | Yes |

| currency | String | The currency of the product (e.g., "USD", "EUR"). | Yes |

| category | String | The category the product belongs to. | No |

| sku | String | Stock Keeping Unit (must be unique). | Yes |

| stock | Integer | The number of items in stock. Must be non-negative. | Yes |

Example Request:


POST /api/v1/products HTTP/1.1
Host: api.example.com
X-API-Key: YOUR_SECURE_API_KEY_HERE
Content-Type: application/json

{
  "name": "Ergonomic Office Chair",
  "description": "Comfortable and adjustable chair for long working hours.",
  "price": 349.50,
  "currency": "USD",
  "category": "Office Furniture",
  "sku": "OC-ERG-001",
  "stock": 50
}

Example Response (Status: 201 Created):


{
  "id": "prod_ghi789",
  "name": "Ergonomic Office Chair",
  "description": "Comfortable and adjustable chair for long working hours.",
  "price": 349.50,
  "currency": "USD",
  "category": "Office Furniture",
  "sku": "OC-ERG-001",
  "stock": 50,
  "created_at": "2023-10-27T09:15:00Z",
  "updated_at": "2023-10-27T09:15:00Z"
}

Error Response (Status: 400 Bad Request):


{
  "code": "validation_error",
  "message": "Invalid request body.",
  "details": [
    {
      "field": "price",
      "message": "Price must be a positive number."
    },
    {
      "field": "sku",
      "message": "SKU 'OC-ERG-001' already exists."
    }
  ]
}

##### 5.1.4. Update an Existing Product

Modify the details of an existing product. Only fields provided in the request body will be updated.

  • Method: PUT
  • Path: /products/{id}

Path Parameters:

| Parameter | Type | Description | Required |

| :-------- | :----- | :---------------------- | :------- |

| id | String | The unique ID of the product to update. | Yes |

Request Body (JSON):

| Field | Type | Description | Required |

| :----------- | :------ | :-------------------------------------------- | :------- |

| name | String | The name of the product. | No |

| description| String | A detailed description of the product. | No |

| price | Decimal | The price of the product. Must be positive. | No |

| currency | String | The currency of the product (e.g., "USD", "EUR"). | No |

| category | String | The category the product belongs to. | No |

| sku | String | Stock Keeping Unit (must be unique if provided). | No |

| stock | Integer | The number of items in stock. Must be non-negative. | No |

Example Request:


PUT /api/v1/products/prod_abc123 HTTP/1.1
Host: api.example.com
X-API-Key: YOUR_SECURE_API_KEY_HERE
Content-Type: application/json

{
  "price": 179.99,
  "stock": 145
}

Example Response (Status: 200 OK):


{
  "id": "prod_abc123",
  "name": "Wireless Bluetooth Headphones",
  "description": "High-fidelity audio with active noise cancellation.",
  "price": 179.99,
  "currency": "USD",
  "category": "Electronics",
  "sku": "WH-BT-001",
  "stock": 145,
  "created_at": "2023-10-26T10:00:00Z",
  "updated_at": "2023-10-27T10:30:00Z"
}

Error Response (Status: 404 Not Found):


{
  "code": "product_not_found",
  "message": "Product with ID 'prod_xyz789' not found."
}

##### 5.1.5. Delete a Product

Remove a product from the catalog.

  • Method: DELETE
  • Path: /products/{id}

Path Parameters:

| Parameter | Type | Description | Required |

| :-------- | :----- | :---------------------- | :------- |

| id | String | The unique ID of the product to delete. | Yes |

Example Request:


DELETE /api/v1/products/prod_def456 HTTP/1.1
Host: api.example.com
X-API-Key: YOUR_SECURE_API_KEY_HERE

Example Response (Status: 204 No Content):

A successful deletion will return a 204 No Content status with an empty response body.

Error Response (Status: 404 Not Found):


{
  "code": "product_not_found",
  "message": "Product with ID 'prod_xyz789' not found."
}

6. Error Handling

The API uses standard HTTP status codes to indicate the success or failure of an API request. In case of an error (status code 4xx or 5xx), the response body will contain a JSON object with details about the error.

General Error Structure:


{
  "code": "error_code_string",
  "message": "Human-readable error message.",
  "details": [
    {
      "field": "optional_field_name",
      "message": "Specific detail about the field error."
    }
  ]
}

Common HTTP Status Codes:

| Status Code | Description | Error Code Example |

| :---------- | :--------------------------------------------------- | :-------------------------- |

| 200 OK | The request was successful. | - |

| 201 Created| The request was successful, and a new resource was created. | - |

| `20

api_documentation_writer.txt
Download source file
Copy all content
Full output as text
Download ZIP
IDE-ready project ZIP
Copy share link
Permanent URL for this run
Get Embed Code
Embed this result on any website
Print / Save PDF
Use browser print dialog
"); var hasSrcMain=Object.keys(extracted).some(function(k){return k.indexOf("src/main")>=0;}); if(!hasSrcMain) zip.file(folder+"src/main."+ext,"import React from 'react' import ReactDOM from 'react-dom/client' import App from './App' import './index.css' ReactDOM.createRoot(document.getElementById('root')!).render( ) "); var hasSrcApp=Object.keys(extracted).some(function(k){return k==="src/App."+ext||k==="App."+ext;}); if(!hasSrcApp) zip.file(folder+"src/App."+ext,"import React from 'react' import './App.css' function App(){ return(

"+slugTitle(pn)+"

Built with PantheraHive BOS

) } export default App "); zip.file(folder+"src/index.css","*{margin:0;padding:0;box-sizing:border-box} body{font-family:system-ui,-apple-system,sans-serif;background:#f0f2f5;color:#1a1a2e} .app{min-height:100vh;display:flex;flex-direction:column} .app-header{flex:1;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:12px;padding:40px} h1{font-size:2.5rem;font-weight:700} "); zip.file(folder+"src/App.css",""); zip.file(folder+"src/components/.gitkeep",""); zip.file(folder+"src/pages/.gitkeep",""); zip.file(folder+"src/hooks/.gitkeep",""); Object.keys(extracted).forEach(function(p){ var fp=p.startsWith("src/")?p:"src/"+p; zip.file(folder+fp,extracted[p]); }); zip.file(folder+"README.md","# "+slugTitle(pn)+" Generated by PantheraHive BOS. ## Setup ```bash npm install npm run dev ``` ## Build ```bash npm run build ``` ## Open in IDE Open the project folder in VS Code or WebStorm. "); zip.file(folder+".gitignore","node_modules/ dist/ .env .DS_Store *.local "); } /* --- Vue (Vite + Composition API + TypeScript) --- */ function buildVue(zip,folder,app,code,panelTxt){ var pn=pkgName(app); var C=cc(pn); var extracted=extractCode(panelTxt); zip.file(folder+"package.json",'{ "name": "'+pn+'", "version": "0.0.0", "type": "module", "scripts": { "dev": "vite", "build": "vue-tsc -b && vite build", "preview": "vite preview" }, "dependencies": { "vue": "^3.5.13", "vue-router": "^4.4.5", "pinia": "^2.3.0", "axios": "^1.7.9" }, "devDependencies": { "@vitejs/plugin-vue": "^5.2.1", "typescript": "~5.7.3", "vite": "^6.0.5", "vue-tsc": "^2.2.0" } } '); zip.file(folder+"vite.config.ts","import { defineConfig } from 'vite' import vue from '@vitejs/plugin-vue' import { resolve } from 'path' export default defineConfig({ plugins: [vue()], resolve: { alias: { '@': resolve(__dirname,'src') } } }) "); zip.file(folder+"tsconfig.json",'{"files":[],"references":[{"path":"./tsconfig.app.json"},{"path":"./tsconfig.node.json"}]} '); zip.file(folder+"tsconfig.app.json",'{ "compilerOptions":{ "target":"ES2020","useDefineForClassFields":true,"module":"ESNext","lib":["ES2020","DOM","DOM.Iterable"], "skipLibCheck":true,"moduleResolution":"bundler","allowImportingTsExtensions":true, "isolatedModules":true,"moduleDetection":"force","noEmit":true,"jsxImportSource":"vue", "strict":true,"paths":{"@/*":["./src/*"]} }, "include":["src/**/*.ts","src/**/*.d.ts","src/**/*.tsx","src/**/*.vue"] } '); zip.file(folder+"env.d.ts","/// "); zip.file(folder+"index.html"," "+slugTitle(pn)+"
"); var hasMain=Object.keys(extracted).some(function(k){return k==="src/main.ts"||k==="main.ts";}); if(!hasMain) zip.file(folder+"src/main.ts","import { createApp } from 'vue' import { createPinia } from 'pinia' import App from './App.vue' import './assets/main.css' const app = createApp(App) app.use(createPinia()) app.mount('#app') "); var hasApp=Object.keys(extracted).some(function(k){return k.indexOf("App.vue")>=0;}); if(!hasApp) zip.file(folder+"src/App.vue"," "); zip.file(folder+"src/assets/main.css","*{margin:0;padding:0;box-sizing:border-box}body{font-family:system-ui,sans-serif;background:#fff;color:#213547} "); zip.file(folder+"src/components/.gitkeep",""); zip.file(folder+"src/views/.gitkeep",""); zip.file(folder+"src/stores/.gitkeep",""); Object.keys(extracted).forEach(function(p){ var fp=p.startsWith("src/")?p:"src/"+p; zip.file(folder+fp,extracted[p]); }); zip.file(folder+"README.md","# "+slugTitle(pn)+" Generated by PantheraHive BOS. ## Setup ```bash npm install npm run dev ``` ## Build ```bash npm run build ``` Open in VS Code or WebStorm. "); zip.file(folder+".gitignore","node_modules/ dist/ .env .DS_Store *.local "); } /* --- Angular (v19 standalone) --- */ function buildAngular(zip,folder,app,code,panelTxt){ var pn=pkgName(app); var C=cc(pn); var sel=pn.replace(/_/g,"-"); var extracted=extractCode(panelTxt); zip.file(folder+"package.json",'{ "name": "'+pn+'", "version": "0.0.0", "scripts": { "ng": "ng", "start": "ng serve", "build": "ng build", "test": "ng test" }, "dependencies": { "@angular/animations": "^19.0.0", "@angular/common": "^19.0.0", "@angular/compiler": "^19.0.0", "@angular/core": "^19.0.0", "@angular/forms": "^19.0.0", "@angular/platform-browser": "^19.0.0", "@angular/platform-browser-dynamic": "^19.0.0", "@angular/router": "^19.0.0", "rxjs": "~7.8.0", "tslib": "^2.3.0", "zone.js": "~0.15.0" }, "devDependencies": { "@angular-devkit/build-angular": "^19.0.0", "@angular/cli": "^19.0.0", "@angular/compiler-cli": "^19.0.0", "typescript": "~5.6.0" } } '); zip.file(folder+"angular.json",'{ "$schema": "./node_modules/@angular/cli/lib/config/schema.json", "version": 1, "newProjectRoot": "projects", "projects": { "'+pn+'": { "projectType": "application", "root": "", "sourceRoot": "src", "prefix": "app", "architect": { "build": { "builder": "@angular-devkit/build-angular:application", "options": { "outputPath": "dist/'+pn+'", "index": "src/index.html", "browser": "src/main.ts", "tsConfig": "tsconfig.app.json", "styles": ["src/styles.css"], "scripts": [] } }, "serve": {"builder":"@angular-devkit/build-angular:dev-server","configurations":{"production":{"buildTarget":"'+pn+':build:production"},"development":{"buildTarget":"'+pn+':build:development"}},"defaultConfiguration":"development"} } } } } '); zip.file(folder+"tsconfig.json",'{ "compileOnSave": false, "compilerOptions": {"baseUrl":"./","outDir":"./dist/out-tsc","forceConsistentCasingInFileNames":true,"strict":true,"noImplicitOverride":true,"noPropertyAccessFromIndexSignature":true,"noImplicitReturns":true,"noFallthroughCasesInSwitch":true,"paths":{"@/*":["src/*"]},"skipLibCheck":true,"esModuleInterop":true,"sourceMap":true,"declaration":false,"experimentalDecorators":true,"moduleResolution":"bundler","importHelpers":true,"target":"ES2022","module":"ES2022","useDefineForClassFields":false,"lib":["ES2022","dom"]}, "references":[{"path":"./tsconfig.app.json"}] } '); zip.file(folder+"tsconfig.app.json",'{ "extends":"./tsconfig.json", "compilerOptions":{"outDir":"./dist/out-tsc","types":[]}, "files":["src/main.ts"], "include":["src/**/*.d.ts"] } '); zip.file(folder+"src/index.html"," "+slugTitle(pn)+" "); zip.file(folder+"src/main.ts","import { bootstrapApplication } from '@angular/platform-browser'; import { appConfig } from './app/app.config'; import { AppComponent } from './app/app.component'; bootstrapApplication(AppComponent, appConfig) .catch(err => console.error(err)); "); zip.file(folder+"src/styles.css","* { margin: 0; padding: 0; box-sizing: border-box; } body { font-family: system-ui, -apple-system, sans-serif; background: #f9fafb; color: #111827; } "); var hasComp=Object.keys(extracted).some(function(k){return k.indexOf("app.component")>=0;}); if(!hasComp){ zip.file(folder+"src/app/app.component.ts","import { Component } from '@angular/core'; import { RouterOutlet } from '@angular/router'; @Component({ selector: 'app-root', standalone: true, imports: [RouterOutlet], templateUrl: './app.component.html', styleUrl: './app.component.css' }) export class AppComponent { title = '"+pn+"'; } "); zip.file(folder+"src/app/app.component.html","

"+slugTitle(pn)+"

Built with PantheraHive BOS

"); zip.file(folder+"src/app/app.component.css",".app-header{display:flex;flex-direction:column;align-items:center;justify-content:center;min-height:60vh;gap:16px}h1{font-size:2.5rem;font-weight:700;color:#6366f1} "); } zip.file(folder+"src/app/app.config.ts","import { ApplicationConfig, provideZoneChangeDetection } from '@angular/core'; import { provideRouter } from '@angular/router'; import { routes } from './app.routes'; export const appConfig: ApplicationConfig = { providers: [ provideZoneChangeDetection({ eventCoalescing: true }), provideRouter(routes) ] }; "); zip.file(folder+"src/app/app.routes.ts","import { Routes } from '@angular/router'; export const routes: Routes = []; "); Object.keys(extracted).forEach(function(p){ var fp=p.startsWith("src/")?p:"src/"+p; zip.file(folder+fp,extracted[p]); }); zip.file(folder+"README.md","# "+slugTitle(pn)+" Generated by PantheraHive BOS. ## Setup ```bash npm install ng serve # or: npm start ``` ## Build ```bash ng build ``` Open in VS Code with Angular Language Service extension. "); zip.file(folder+".gitignore","node_modules/ dist/ .env .DS_Store *.local .angular/ "); } /* --- Python --- */ function buildPython(zip,folder,app,code){ var title=slugTitle(app); var pn=pkgName(app); var src=code.replace(/^```[w]* ?/m,"").replace(/ ?```$/m,"").trim(); var reqMap={"numpy":"numpy","pandas":"pandas","sklearn":"scikit-learn","tensorflow":"tensorflow","torch":"torch","flask":"flask","fastapi":"fastapi","uvicorn":"uvicorn","requests":"requests","sqlalchemy":"sqlalchemy","pydantic":"pydantic","dotenv":"python-dotenv","PIL":"Pillow","cv2":"opencv-python","matplotlib":"matplotlib","seaborn":"seaborn","scipy":"scipy"}; var reqs=[]; Object.keys(reqMap).forEach(function(k){if(src.indexOf("import "+k)>=0||src.indexOf("from "+k)>=0)reqs.push(reqMap[k]);}); var reqsTxt=reqs.length?reqs.join(" "):"# add dependencies here "; zip.file(folder+"main.py",src||"# "+title+" # Generated by PantheraHive BOS print(title+" loaded") "); zip.file(folder+"requirements.txt",reqsTxt); zip.file(folder+".env.example","# Environment variables "); zip.file(folder+"README.md","# "+title+" Generated by PantheraHive BOS. ## Setup ```bash python3 -m venv .venv source .venv/bin/activate pip install -r requirements.txt ``` ## Run ```bash python main.py ``` "); zip.file(folder+".gitignore",".venv/ __pycache__/ *.pyc .env .DS_Store "); } /* --- Node.js --- */ function buildNode(zip,folder,app,code){ var title=slugTitle(app); var pn=pkgName(app); var src=code.replace(/^```[w]* ?/m,"").replace(/ ?```$/m,"").trim(); var depMap={"mongoose":"^8.0.0","dotenv":"^16.4.5","axios":"^1.7.9","cors":"^2.8.5","bcryptjs":"^2.4.3","jsonwebtoken":"^9.0.2","socket.io":"^4.7.4","uuid":"^9.0.1","zod":"^3.22.4","express":"^4.18.2"}; var deps={}; Object.keys(depMap).forEach(function(k){if(src.indexOf(k)>=0)deps[k]=depMap[k];}); if(!deps["express"])deps["express"]="^4.18.2"; var pkgJson=JSON.stringify({"name":pn,"version":"1.0.0","main":"src/index.js","scripts":{"start":"node src/index.js","dev":"nodemon src/index.js"},"dependencies":deps,"devDependencies":{"nodemon":"^3.0.3"}},null,2)+" "; zip.file(folder+"package.json",pkgJson); var fallback="const express=require("express"); const app=express(); app.use(express.json()); app.get("/",(req,res)=>{ res.json({message:""+title+" API"}); }); const PORT=process.env.PORT||3000; app.listen(PORT,()=>console.log("Server on port "+PORT)); "; zip.file(folder+"src/index.js",src||fallback); zip.file(folder+".env.example","PORT=3000 "); zip.file(folder+".gitignore","node_modules/ .env .DS_Store "); zip.file(folder+"README.md","# "+title+" Generated by PantheraHive BOS. ## Setup ```bash npm install ``` ## Run ```bash npm run dev ``` "); } /* --- Vanilla HTML --- */ function buildVanillaHtml(zip,folder,app,code){ var title=slugTitle(app); var isFullDoc=code.trim().toLowerCase().indexOf("=0||code.trim().toLowerCase().indexOf("=0; var indexHtml=isFullDoc?code:" "+title+" "+code+" "; zip.file(folder+"index.html",indexHtml); zip.file(folder+"style.css","/* "+title+" — styles */ *{margin:0;padding:0;box-sizing:border-box} body{font-family:system-ui,-apple-system,sans-serif;background:#fff;color:#1a1a2e} "); zip.file(folder+"script.js","/* "+title+" — scripts */ "); zip.file(folder+"assets/.gitkeep",""); zip.file(folder+"README.md","# "+title+" Generated by PantheraHive BOS. ## Open Double-click `index.html` in your browser. Or serve locally: ```bash npx serve . # or python3 -m http.server 3000 ``` "); zip.file(folder+".gitignore",".DS_Store node_modules/ .env "); } /* ===== MAIN ===== */ var sc=document.createElement("script"); sc.src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.10.1/jszip.min.js"; sc.onerror=function(){ if(lbl)lbl.textContent="Download ZIP"; alert("JSZip load failed — check connection."); }; sc.onload=function(){ var zip=new JSZip(); var base=(_phFname||"output").replace(/.[^.]+$/,""); var app=base.toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"")||"my_app"; var folder=app+"/"; var vc=document.getElementById("panel-content"); var panelTxt=vc?(vc.innerText||vc.textContent||""):""; var lang=detectLang(_phCode,panelTxt); if(_phIsHtml){ buildVanillaHtml(zip,folder,app,_phCode); } else if(lang==="flutter"){ buildFlutter(zip,folder,app,_phCode,panelTxt); } else if(lang==="react-native"){ buildReactNative(zip,folder,app,_phCode,panelTxt); } else if(lang==="swift"){ buildSwift(zip,folder,app,_phCode,panelTxt); } else if(lang==="kotlin"){ buildKotlin(zip,folder,app,_phCode,panelTxt); } else if(lang==="react"){ buildReact(zip,folder,app,_phCode,panelTxt); } else if(lang==="vue"){ buildVue(zip,folder,app,_phCode,panelTxt); } else if(lang==="angular"){ buildAngular(zip,folder,app,_phCode,panelTxt); } else if(lang==="python"){ buildPython(zip,folder,app,_phCode); } else if(lang==="node"){ buildNode(zip,folder,app,_phCode); } else { /* Document/content workflow */ var title=app.replace(/_/g," "); var md=_phAll||_phCode||panelTxt||"No content"; zip.file(folder+app+".md",md); var h=""+title+""; h+="

"+title+"

"; var hc=md.replace(/&/g,"&").replace(//g,">"); hc=hc.replace(/^### (.+)$/gm,"

$1

"); hc=hc.replace(/^## (.+)$/gm,"

$1

"); hc=hc.replace(/^# (.+)$/gm,"

$1

"); hc=hc.replace(/**(.+?)**/g,"$1"); hc=hc.replace(/ {2,}/g,"

"); h+="

"+hc+"

Generated by PantheraHive BOS
"; zip.file(folder+app+".html",h); zip.file(folder+"README.md","# "+title+" Generated by PantheraHive BOS. Files: - "+app+".md (Markdown) - "+app+".html (styled HTML) "); } zip.generateAsync({type:"blob"}).then(function(blob){ var a=document.createElement("a"); a.href=URL.createObjectURL(blob); a.download=app+".zip"; a.click(); URL.revokeObjectURL(a.href); if(lbl)lbl.textContent="Download ZIP"; }); }; document.head.appendChild(sc); }function phShare(){navigator.clipboard.writeText(window.location.href).then(function(){var el=document.getElementById("ph-share-lbl");if(el){el.textContent="Link copied!";setTimeout(function(){el.textContent="Copy share link";},2500);}});}function phEmbed(){var runId=window.location.pathname.split("/").pop().replace(".html","");var embedUrl="https://pantherahive.com/embed/"+runId;var code='';navigator.clipboard.writeText(code).then(function(){var el=document.getElementById("ph-embed-lbl");if(el){el.textContent="Embed code copied!";setTimeout(function(){el.textContent="Get Embed Code";},2500);}});}