API Documentation Writer
Run ID: 69cb9cfa61b1021a29a8aa862026-03-31Development
PantheraHive BOS
BOS Dashboard

We are delighted to present the comprehensive API documentation, meticulously crafted to empower developers in integrating with our robust platform. This document serves as your definitive guide, providing all the necessary information to understand, implement, and leverage the full capabilities of our API.


Welcome to the [Your Company Name] API Documentation

Unlock the Power of [Your Product/Service Name] with Seamless Integration

Welcome, developers! This documentation is designed to guide you through integrating your applications with the [Your Company Name] platform. Our API provides a powerful and flexible way to programmatically access and manage your data, automate workflows, and extend the functionality of our services directly within your own applications.

Whether you're building custom dashboards, integrating with third-party tools, or developing new features, our API offers the tools you need to succeed. We've focused on creating a RESTful API that is intuitive, consistent, and well-documented.


1. Getting Started

This section will walk you through the initial steps required to make your first API call.

1.1. Authentication

To ensure the security of your data, all requests to the [Your Company Name] API must be authenticated. We primarily use API Key authentication.

1. Log in to your [Your Company Name] dashboard.

2. Navigate to the "Settings" or "Developer" section.

3. Generate a new API Key.

4. Important: Treat your API Key like a password. Do not share it publicly or commit it to version control.

Include your API Key in the Authorization header of every request, prefixed with Bearer.

Example:

text • 1,053 chars
For a comprehensive list of error codes, please refer to Section 5.

---

## **2. API Endpoints Reference**

Our API is organized around RESTful principles, providing clear, resource-oriented URLs. Below are the core resources and their available operations.

### **2.1. Products Resource**

Manage your product catalog, including creation, retrieval, updates, and deletion of product information.

#### **2.1.1. List All Products**

Retrieves a list of all products in your catalog.

*   **`GET /products`**

*   **Description:** Returns an array of product objects. Supports pagination and filtering.

*   **Query Parameters:**
    *   `limit` (optional, integer): Maximum number of products to return. Default is 10, max is 100.
    *   `offset` (optional, integer): Number of products to skip before starting to collect the result set. Default is 0.
    *   `category` (optional, string): Filter products by a specific category.
    *   `status` (optional, enum: `active`, `inactive`): Filter products by their status.

*   **Example Request:**
    
Sandboxed live preview

Step 1 of 3: Research Topic - API Documentation Writer

This deliverable provides a comprehensive overview and foundational research for the role and requirements of an API Documentation Writer. It outlines the core purpose, essential components, best practices, and strategic considerations necessary for producing high-quality, effective API documentation.


1. Introduction to API Documentation Writing

API Documentation Writing is the specialized process of creating clear, accurate, and user-friendly guides and references for Application Programming Interfaces (APIs). Its primary goal is to enable developers (internal and external) to understand, integrate, and utilize an API efficiently and effectively, minimizing friction and accelerating development cycles. A skilled API Documentation Writer bridges the gap between complex technical functionalities and practical application.

2. Core Purpose and Importance of API Documentation

Effective API documentation is crucial for:

  • Developer Onboarding & Adoption: Simplifies the learning curve for new users, encouraging faster adoption and integration of the API.
  • Reduced Support Burden: Clear documentation answers common questions, decreasing the volume of support requests and freeing up engineering resources.
  • Improved Developer Experience (DX): A positive DX fosters loyalty and encourages continued use of the API.
  • Product Success & Market Penetration: Well-documented APIs are more appealing and easier to consume, leading to wider adoption and a stronger market presence.
  • Internal Alignment & Collaboration: Serves as a single source of truth for internal teams (developers, product managers, QA) regarding API functionality and behavior.
  • Compliance & Audit Trails: Can be essential for regulatory compliance and provides a historical record of API capabilities.

3. Key Components of Comprehensive API Documentation

Professional API documentation typically includes, but is not limited to, the following sections:

  • Getting Started Guide / Quickstart:

* Overview: What the API does and its primary use cases.

* Authentication: How to get an API key, token, or credentials; authentication methods (e.g., OAuth 2.0, API Keys, Basic Auth).

* Installation/Setup: How to install SDKs (if applicable) or set up the development environment.

* First Request Example: A simple, copy-pasteable code example to make a successful API call.

  • API Reference (Core Documentation):

* Endpoints: List of all available API endpoints (e.g., /users, /products).

* HTTP Methods: For each endpoint, specify supported methods (GET, POST, PUT, DELETE, PATCH).

* Parameters:

* Path Parameters: Variables embedded in the URL.

* Query Parameters: Optional parameters passed in the URL.

* Request Body Parameters: Data sent in the request body (JSON, XML, form-data).

* Headers: Required or optional HTTP headers.

* Request Examples: Illustrative code snippets for different programming languages (cURL, Python, JavaScript, Ruby, etc.) for each operation.

* Response Examples: Sample successful (2xx) and error (4xx, 5xx) responses, including status codes and response body schemas.

* Data Models/Schemas: Detailed descriptions of request and response data structures, including data types, constraints, and descriptions for each field.

* Error Codes: Comprehensive list of possible error codes, their meanings, and potential solutions.

  • Tutorials & How-To Guides:

* Step-by-step instructions for common use cases or complex workflows.

* Examples of integrating the API with other services or platforms.

* Recipes for achieving specific outcomes.

  • SDKs & Libraries (if applicable):

* Links to official SDKs.

* Installation instructions and usage examples for each SDK.

  • Rate Limiting & Throttling:

* Details on API usage limits and how to handle them.

* Strategies for optimizing API calls.

  • Webhooks (if applicable):

* Explanation of webhook events, payloads, and how to set them up.

  • Glossary: Definitions of domain-specific terms and acronyms.
  • Changelog / Versioning:

* History of API changes, new features, deprecations, and breaking changes.

* Clear guidance on API versioning strategy (e.g., v1, v2).

  • Support & Community:

* Links to support channels, forums, or community resources.

* FAQs.

  • Terms of Service & Privacy Policy: Links to legal documentation.

4. Best Practices for Effective API Documentation

  • Audience-Centric Approach: Tailor content to the target audience (e.g., beginner vs. advanced developers, specific programming language preferences).
  • Clarity and Conciseness: Use simple, unambiguous language. Avoid jargon where possible, or define it clearly.
  • Accuracy: Ensure all examples, descriptions, and specifications are up-to-date and reflect the API's current behavior.
  • Consistency: Maintain a consistent tone, style, and terminology throughout the documentation.
  • Examples, Examples, Examples: Provide abundant, runnable code examples in multiple popular languages.
  • Interactive Elements: Incorporate "Try It Out" features, interactive consoles, or OpenAPI (Swagger UI) explorers.
  • Searchability & Navigation: Implement robust search functionality and intuitive navigation (table of contents, breadcrumbs).
  • Versioning: Clearly indicate which version of the API the documentation applies to, and provide access to older versions if necessary.
  • Regular Updates: Treat documentation as a living product; update it frequently with API changes, bug fixes, and new features.
  • Feedback Mechanism: Provide a way for users to submit feedback, report errors, or suggest improvements.
  • Accessibility: Ensure documentation is accessible to users with disabilities.
  • Visual Aids: Use diagrams, flowcharts, and screenshots to explain complex concepts.

5. Common Tools and Technologies for API Documentation

  • OpenAPI Specification (formerly Swagger): A language-agnostic standard for describing RESTful APIs. Tools like Swagger UI can generate interactive documentation directly from an OpenAPI definition.
  • Markdown/MDX: Widely used for its simplicity and readability, often combined with static site generators.
  • Static Site Generators:

* Docusaurus: Facebook's open-source project, great for documentation sites.

* Gatsby/Next.js: Can be used with MDX for highly customizable documentation portals.

* Jekyll/Hugo: Simpler, fast static site generators.

  • Documentation Platforms/Tools:

* ReadMe.io: Feature-rich platform with interactive API explorers, versioning, and analytics.

* Stoplight: Comprehensive API design and documentation platform.

* Postman: While primarily an API development tool, it can also generate basic documentation collections.

* GitBook: Collaborative documentation platform.

  • Version Control Systems: Git (GitHub, GitLab, Bitbucket) for managing documentation source files.

6. Challenges in API Documentation Writing

  • Staying Up-to-Date: Synchronizing documentation with rapid API development cycles.
  • Technical Accuracy: Ensuring all technical details are precisely correct.
  • Balancing Detail and Simplicity: Providing enough information without overwhelming the user.
  • Audience Diversity: Catering to developers with varying skill levels and programming language preferences.
  • Tooling Integration: Selecting and integrating the right tools for publishing and maintaining documentation.
  • Generating Useful Examples: Crafting relevant, runnable, and context-rich code examples.
  • Measuring Effectiveness: Quantifying the impact of documentation on developer success and support load.

7. The Value Proposition of a Dedicated API Documentation Writer

A professional API Documentation Writer brings specialized skills to:

  • Strategic Planning: Defining documentation scope, structure, and audience.
  • Technical Acumen: Understanding complex API functionalities and translating them into clear language.
  • Writing & Editing Expertise: Producing high-quality, grammatically correct, and consistent content.
  • Tooling Proficiency: Leveraging documentation tools and standards (e.g., OpenAPI) effectively.
  • User Advocacy: Championing the developer experience and ensuring documentation meets user needs.
  • Collaboration: Working closely with product managers, engineers, and support teams to gather information and ensure accuracy.

By investing in a dedicated API Documentation Writer, organizations can significantly enhance their developer experience, accelerate product adoption, and ultimately drive greater success for their API products.


3. Authentication & Authorization

Beyond the basic API Key, understanding our authentication and authorization mechanisms is crucial for secure integration.

3.1. API Key Security Best Practices

  • Environment Variables: Store your API keys in environment variables, not directly in your code.
  • Server-Side Usage: API keys are best used for server-to-server communication or backend applications.
  • Never Client-Side: Do not embed API keys directly into public client-side code (e.g., JavaScript in a browser, mobile app code).
  • Rotation: Regularly rotate your API keys for enhanced security.

3.2. Scopes and Permissions (Coming Soon / Advanced)

For more granular control, we will introduce OAuth 2.0 with scopes, allowing you to limit an API key's access to specific resources or actions. This feature is currently under development.


4. Rate Limiting

To ensure fair usage and maintain API stability, we enforce rate limits on all API requests.

  • Default Limit: 100 requests per minute per API Key.
  • Exceeding Limits: If you exceed the rate limit, your requests will be temporarily blocked, and you will receive a 429 Too Many Requests HTTP status code.
  • Headers:

* X-RateLimit-Limit: The maximum number of requests you can make in the current window.

* X-RateLimit-Remaining: The number of requests remaining in the current window.

* X-RateLimit-Reset: The time (in UTC epoch seconds) at which the current rate limit window resets.

Best Practice: Implement exponential backoff in your application to gracefully handle rate limit errors.


5. Error Codes Reference

Understanding error responses is key to building robust integrations.

| HTTP Status Code | Code | Description | Suggested Action |

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

| 200 OK | success | The request was successful. | Process the response data. |

| 201 Created | resource_created | A new

gemini Output

As the final step in the "API Documentation Writer" workflow, this output represents the fully polished, professionally formatted, and comprehensive API documentation, ready for direct delivery to your customers.

This document assumes the preceding workflow steps (e.g., gemini) successfully generated the core content for a hypothetical API. This final step focuses on structuring, clarifying, enhancing readability, and ensuring all best practices for API documentation are met.


PantheraHive Notification Service API Documentation

Version: 1.0.0

Last Updated: October 26, 2023


1. Introduction

Welcome to the PantheraHive Notification Service API Documentation! This API allows developers to programmatically send, manage, and retrieve notifications across various channels (e.g., email, SMS, push notifications) from their applications. Designed for reliability and ease of integration, our API provides a robust solution for enhancing user engagement through timely and relevant communication.

Key Features:

  • Multi-channel Delivery: Send notifications via Email, SMS, and Push.
  • Templating Support: Utilize predefined or custom templates for consistent messaging.
  • Status Tracking: Monitor the delivery status of your notifications.
  • Webhook Integration: Receive real-time updates on notification events.
  • Scalable & Secure: Built on a resilient infrastructure with industry-standard security protocols.

Target Audience:

This documentation is intended for developers, system architects, and technical leads who wish to integrate notification capabilities into their applications using the PantheraHive Notification Service API.

2. Getting Started

To begin integrating with the PantheraHive Notification Service API, follow these steps:

2.1 Base URL

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

https://api.pantherahive.com/notifications/v1

2.2 Authentication

The PantheraHive Notification Service API uses API Key Authentication.

Each request must include your unique API Key in the X-API-Key header.

How to Obtain Your API Key:

  1. Log in to your PantheraHive 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 one.
  4. Ensure your API Key has the necessary permissions for the endpoints you intend to use.

Example Authentication Header:


X-API-Key: YOUR_API_KEY_HERE

Security Best Practices:

  • Never hardcode your API Key directly into client-side code.
  • Use environment variables or a secure configuration management system to store your API Key.
  • Rotate your API Keys regularly.
  • Restrict API Key permissions to the minimum necessary for your application.

2.3 Rate Limiting

To ensure fair usage and system stability, the PantheraHive Notification Service API enforces rate limits.

  • Requests per minute: 1000 requests/minute per API Key.
  • Burst limit: 100 requests/second.

If you exceed the rate limits, the API will return a 429 Too Many Requests status code. You should implement exponential backoff and retry logic in your application to handle rate limit errors gracefully.

3. Endpoints

This section details all available API endpoints, their methods, parameters, and example requests/responses.

3.1 Send a Notification

Sends a new notification to one or more recipients across specified channels.

  • HTTP Method: POST
  • Path: /send

Description:

This endpoint initiates the delivery of a notification. You can specify the content directly or use a predefined template.

Request Body Parameters:

| Name | Type | Required | Description | Example |

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

| recipients | Array | Yes | An array of recipient objects. Each object must contain type and address. | [{"type": "email", "address": "user@example.com"}] |

| channels | Array | Yes | An array of notification channels to use. Supported: email, sms, push. | ["email", "sms"] |

| templateId | String | No | ID of a predefined notification template. Mutually exclusive with content. | "welcome_message" |

| content | Object | No | Custom notification content. Required if templateId is not provided. | { "subject": "Hello", "body": "Welcome!" } |

| data | Object | No | Key-value pairs to populate template variables or provide additional context. | { "userName": "John Doe", "orderId": "12345" } |

| scheduledFor| String | No | ISO 8601 timestamp for scheduling the notification in the future. | "2024-01-01T10:00:00Z" |

| priority | String | No | Notification priority. low, medium (default), high. | "high" |

Example Request:

cURL:


curl -X POST \
  https://api.pantherahive.com/notifications/v1/send \
  -H 'Content-Type: application/json' \
  -H 'X-API-Key: YOUR_API_KEY_HERE' \
  -d '{
    "recipients": [
      {
        "type": "email",
        "address": "johndoe@example.com"
      },
      {
        "type": "sms",
        "address": "+15551234567"
      }
    ],
    "channels": ["email", "sms"],
    "templateId": "ORDER_CONFIRMATION",
    "data": {
      "orderId": "PHX7890123",
      "customerName": "John Doe",
      "totalAmount": "99.99"
    },
    "priority": "high"
  }'

Python (using requests library):


import requests

api_key = "YOUR_API_KEY_HERE"
base_url = "https://api.pantherahive.com/notifications/v1"

headers = {
    "Content-Type": "application/json",
    "X-API-Key": api_key
}

payload = {
    "recipients": [
        {"type": "email", "address": "johndoe@example.com"},
        {"type": "sms", "address": "+15551234567"}
    ],
    "channels": ["email", "sms"],
    "templateId": "ORDER_CONFIRMATION",
    "data": {
        "orderId": "PHX7890123",
        "customerName": "John Doe",
        "totalAmount": "99.99"
    },
    "priority": "high"
}

response = requests.post(f"{base_url}/send", json=payload, headers=headers)

print(response.status_code)
print(response.json())

Example Success Response (HTTP 202 Accepted):


{
  "message": "Notification request accepted.",
  "notificationId": "notif_abc123xyz456",
  "status": "pending",
  "details": [
    {
      "channel": "email",
      "recipient": "johndoe@example.com",
      "status": "accepted"
    },
    {
      "channel": "sms",
      "recipient": "+15551234567",
      "status": "accepted"
    }
  ]
}

Response Fields:

| Name | Type | Description |

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

| message | String | A human-readable message indicating the status of the request. |

| notificationId | String | A unique identifier for the overall notification request. |

| status | String | The overall status of the notification request (pending, failed). |

| details | Array | An array containing the status for each channel and recipient combination. |

3.2 Get Notification Status

Retrieves the current status of a previously sent notification.

  • HTTP Method: GET
  • Path: /status/{notificationId}

Description:

Use this endpoint to query the delivery status of a notification using its notificationId.

Path Parameters:

| Name | Type | Required | Description | Example |

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

| notificationId | String | Yes | The unique ID of the notification to retrieve. | "notif_abc123xyz456" |

Example Request:

cURL:


curl -X GET \
  https://api.pantherahive.com/notifications/v1/status/notif_abc123xyz456 \
  -H 'X-API-Key: YOUR_API_KEY_HERE'

Example Success Response (HTTP 200 OK):


{
  "notificationId": "notif_abc123xyz456",
  "overallStatus": "delivered",
  "createdAt": "2023-10-26T14:30:00Z",
  "lastUpdated": "2023-10-26T14:35:15Z",
  "channelStatuses": [
    {
      "channel": "email",
      "recipient": "johndoe@example.com",
      "status": "delivered",
      "statusDetails": "Email successfully sent and delivered to recipient inbox."
    },
    {
      "channel": "sms",
      "recipient": "+15551234567",
      "status": "failed",
      "statusDetails": "SMS delivery failed: Invalid phone number format."
    }
  ]
}

Response Fields:

| Name | Type | Description |

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

| notificationId | String | The unique ID of the notification. |

| overallStatus | String | The aggregated status of the notification (pending, partial_success, delivered, failed). |

| createdAt | String | ISO 8601 timestamp when the notification request was initiated. |

| lastUpdated | String | ISO 8601 timestamp when the notification status was last updated. |

| channelStatuses | Array | An array detailing the status for each individual channel-recipient pair. |

| channel | String | The channel used for this specific notification part. |

| recipient | String | The recipient address for this specific notification part. |

| status | String | The status for this specific notification part (pending, sent, delivered, failed, read, clicked). |

| statusDetails | String | Additional details regarding the status, especially for failures. |

4. Error Handling

The PantheraHive Notification Service API uses standard HTTP status codes to indicate the success or failure of an API request. In case of an error, the response body will contain a JSON object with details about the error.

4.1 Common HTTP Status Codes

| Status Code | Meaning | Description

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
\n\n\n"); 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'\nimport ReactDOM from 'react-dom/client'\nimport App from './App'\nimport './index.css'\n\nReactDOM.createRoot(document.getElementById('root')!).render(\n \n \n \n)\n"); 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'\nimport './App.css'\n\nfunction App(){\n return(\n
\n
\n

"+slugTitle(pn)+"

\n

Built with PantheraHive BOS

\n
\n
\n )\n}\nexport default App\n"); zip.file(folder+"src/index.css","*{margin:0;padding:0;box-sizing:border-box}\nbody{font-family:system-ui,-apple-system,sans-serif;background:#f0f2f5;color:#1a1a2e}\n.app{min-height:100vh;display:flex;flex-direction:column}\n.app-header{flex:1;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:12px;padding:40px}\nh1{font-size:2.5rem;font-weight:700}\n"); 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)+"\n\nGenerated by PantheraHive BOS.\n\n## Setup\n\`\`\`bash\nnpm install\nnpm run dev\n\`\`\`\n\n## Build\n\`\`\`bash\nnpm run build\n\`\`\`\n\n## Open in IDE\nOpen the project folder in VS Code or WebStorm.\n"); zip.file(folder+".gitignore","node_modules/\ndist/\n.env\n.DS_Store\n*.local\n"); } /* --- 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",'{\n "name": "'+pn+'",\n "version": "0.0.0",\n "type": "module",\n "scripts": {\n "dev": "vite",\n "build": "vue-tsc -b && vite build",\n "preview": "vite preview"\n },\n "dependencies": {\n "vue": "^3.5.13",\n "vue-router": "^4.4.5",\n "pinia": "^2.3.0",\n "axios": "^1.7.9"\n },\n "devDependencies": {\n "@vitejs/plugin-vue": "^5.2.1",\n "typescript": "~5.7.3",\n "vite": "^6.0.5",\n "vue-tsc": "^2.2.0"\n }\n}\n'); zip.file(folder+"vite.config.ts","import { defineConfig } from 'vite'\nimport vue from '@vitejs/plugin-vue'\nimport { resolve } from 'path'\n\nexport default defineConfig({\n plugins: [vue()],\n resolve: { alias: { '@': resolve(__dirname,'src') } }\n})\n"); zip.file(folder+"tsconfig.json",'{"files":[],"references":[{"path":"./tsconfig.app.json"},{"path":"./tsconfig.node.json"}]}\n'); zip.file(folder+"tsconfig.app.json",'{\n "compilerOptions":{\n "target":"ES2020","useDefineForClassFields":true,"module":"ESNext","lib":["ES2020","DOM","DOM.Iterable"],\n "skipLibCheck":true,"moduleResolution":"bundler","allowImportingTsExtensions":true,\n "isolatedModules":true,"moduleDetection":"force","noEmit":true,"jsxImportSource":"vue",\n "strict":true,"paths":{"@/*":["./src/*"]}\n },\n "include":["src/**/*.ts","src/**/*.d.ts","src/**/*.tsx","src/**/*.vue"]\n}\n'); zip.file(folder+"env.d.ts","/// \n"); zip.file(folder+"index.html","\n\n\n \n \n "+slugTitle(pn)+"\n\n\n
\n \n\n\n"); 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'\nimport { createPinia } from 'pinia'\nimport App from './App.vue'\nimport './assets/main.css'\n\nconst app = createApp(App)\napp.use(createPinia())\napp.mount('#app')\n"); var hasApp=Object.keys(extracted).some(function(k){return k.indexOf("App.vue")>=0;}); if(!hasApp) zip.file(folder+"src/App.vue","\n\n\n\n\n"); 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}\n"); 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)+"\n\nGenerated by PantheraHive BOS.\n\n## Setup\n\`\`\`bash\nnpm install\nnpm run dev\n\`\`\`\n\n## Build\n\`\`\`bash\nnpm run build\n\`\`\`\n\nOpen in VS Code or WebStorm.\n"); zip.file(folder+".gitignore","node_modules/\ndist/\n.env\n.DS_Store\n*.local\n"); } /* --- 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",'{\n "name": "'+pn+'",\n "version": "0.0.0",\n "scripts": {\n "ng": "ng",\n "start": "ng serve",\n "build": "ng build",\n "test": "ng test"\n },\n "dependencies": {\n "@angular/animations": "^19.0.0",\n "@angular/common": "^19.0.0",\n "@angular/compiler": "^19.0.0",\n "@angular/core": "^19.0.0",\n "@angular/forms": "^19.0.0",\n "@angular/platform-browser": "^19.0.0",\n "@angular/platform-browser-dynamic": "^19.0.0",\n "@angular/router": "^19.0.0",\n "rxjs": "~7.8.0",\n "tslib": "^2.3.0",\n "zone.js": "~0.15.0"\n },\n "devDependencies": {\n "@angular-devkit/build-angular": "^19.0.0",\n "@angular/cli": "^19.0.0",\n "@angular/compiler-cli": "^19.0.0",\n "typescript": "~5.6.0"\n }\n}\n'); zip.file(folder+"angular.json",'{\n "$schema": "./node_modules/@angular/cli/lib/config/schema.json",\n "version": 1,\n "newProjectRoot": "projects",\n "projects": {\n "'+pn+'": {\n "projectType": "application",\n "root": "",\n "sourceRoot": "src",\n "prefix": "app",\n "architect": {\n "build": {\n "builder": "@angular-devkit/build-angular:application",\n "options": {\n "outputPath": "dist/'+pn+'",\n "index": "src/index.html",\n "browser": "src/main.ts",\n "tsConfig": "tsconfig.app.json",\n "styles": ["src/styles.css"],\n "scripts": []\n }\n },\n "serve": {"builder":"@angular-devkit/build-angular:dev-server","configurations":{"production":{"buildTarget":"'+pn+':build:production"},"development":{"buildTarget":"'+pn+':build:development"}},"defaultConfiguration":"development"}\n }\n }\n }\n}\n'); zip.file(folder+"tsconfig.json",'{\n "compileOnSave": false,\n "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"]},\n "references":[{"path":"./tsconfig.app.json"}]\n}\n'); zip.file(folder+"tsconfig.app.json",'{\n "extends":"./tsconfig.json",\n "compilerOptions":{"outDir":"./dist/out-tsc","types":[]},\n "files":["src/main.ts"],\n "include":["src/**/*.d.ts"]\n}\n'); zip.file(folder+"src/index.html","\n\n\n \n "+slugTitle(pn)+"\n \n \n \n\n\n \n\n\n"); zip.file(folder+"src/main.ts","import { bootstrapApplication } from '@angular/platform-browser';\nimport { appConfig } from './app/app.config';\nimport { AppComponent } from './app/app.component';\n\nbootstrapApplication(AppComponent, appConfig)\n .catch(err => console.error(err));\n"); zip.file(folder+"src/styles.css","* { margin: 0; padding: 0; box-sizing: border-box; }\nbody { font-family: system-ui, -apple-system, sans-serif; background: #f9fafb; color: #111827; }\n"); 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';\nimport { RouterOutlet } from '@angular/router';\n\n@Component({\n selector: 'app-root',\n standalone: true,\n imports: [RouterOutlet],\n templateUrl: './app.component.html',\n styleUrl: './app.component.css'\n})\nexport class AppComponent {\n title = '"+pn+"';\n}\n"); zip.file(folder+"src/app/app.component.html","
\n
\n

"+slugTitle(pn)+"

\n

Built with PantheraHive BOS

\n
\n \n
\n"); 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}\n"); } zip.file(folder+"src/app/app.config.ts","import { ApplicationConfig, provideZoneChangeDetection } from '@angular/core';\nimport { provideRouter } from '@angular/router';\nimport { routes } from './app.routes';\n\nexport const appConfig: ApplicationConfig = {\n providers: [\n provideZoneChangeDetection({ eventCoalescing: true }),\n provideRouter(routes)\n ]\n};\n"); zip.file(folder+"src/app/app.routes.ts","import { Routes } from '@angular/router';\n\nexport const routes: Routes = [];\n"); 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)+"\n\nGenerated by PantheraHive BOS.\n\n## Setup\n\`\`\`bash\nnpm install\nng serve\n# or: npm start\n\`\`\`\n\n## Build\n\`\`\`bash\nng build\n\`\`\`\n\nOpen in VS Code with Angular Language Service extension.\n"); zip.file(folder+".gitignore","node_modules/\ndist/\n.env\n.DS_Store\n*.local\n.angular/\n"); } /* --- Python --- */ function buildPython(zip,folder,app,code){ var title=slugTitle(app); var pn=pkgName(app); var src=code.replace(/^\`\`\`[\w]*\n?/m,"").replace(/\n?\`\`\`$/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("\n"):"# add dependencies here\n"; zip.file(folder+"main.py",src||"# "+title+"\n# Generated by PantheraHive BOS\n\nprint(title+\" loaded\")\n"); zip.file(folder+"requirements.txt",reqsTxt); zip.file(folder+".env.example","# Environment variables\n"); zip.file(folder+"README.md","# "+title+"\n\nGenerated by PantheraHive BOS.\n\n## Setup\n\`\`\`bash\npython3 -m venv .venv\nsource .venv/bin/activate\npip install -r requirements.txt\n\`\`\`\n\n## Run\n\`\`\`bash\npython main.py\n\`\`\`\n"); zip.file(folder+".gitignore",".venv/\n__pycache__/\n*.pyc\n.env\n.DS_Store\n"); } /* --- Node.js --- */ function buildNode(zip,folder,app,code){ var title=slugTitle(app); var pn=pkgName(app); var src=code.replace(/^\`\`\`[\w]*\n?/m,"").replace(/\n?\`\`\`$/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)+"\n"; zip.file(folder+"package.json",pkgJson); var fallback="const express=require(\"express\");\nconst app=express();\napp.use(express.json());\n\napp.get(\"/\",(req,res)=>{\n res.json({message:\""+title+" API\"});\n});\n\nconst PORT=process.env.PORT||3000;\napp.listen(PORT,()=>console.log(\"Server on port \"+PORT));\n"; zip.file(folder+"src/index.js",src||fallback); zip.file(folder+".env.example","PORT=3000\n"); zip.file(folder+".gitignore","node_modules/\n.env\n.DS_Store\n"); zip.file(folder+"README.md","# "+title+"\n\nGenerated by PantheraHive BOS.\n\n## Setup\n\`\`\`bash\nnpm install\n\`\`\`\n\n## Run\n\`\`\`bash\nnpm run dev\n\`\`\`\n"); } /* --- 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:"\n\n\n\n\n"+title+"\n\n\n\n"+code+"\n\n\n\n"; zip.file(folder+"index.html",indexHtml); zip.file(folder+"style.css","/* "+title+" — styles */\n*{margin:0;padding:0;box-sizing:border-box}\nbody{font-family:system-ui,-apple-system,sans-serif;background:#fff;color:#1a1a2e}\n"); zip.file(folder+"script.js","/* "+title+" — scripts */\n"); zip.file(folder+"assets/.gitkeep",""); zip.file(folder+"README.md","# "+title+"\n\nGenerated by PantheraHive BOS.\n\n## Open\nDouble-click \`index.html\` in your browser.\n\nOr serve locally:\n\`\`\`bash\nnpx serve .\n# or\npython3 -m http.server 3000\n\`\`\`\n"); zip.file(folder+".gitignore",".DS_Store\nnode_modules/\n.env\n"); } /* ===== 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(/\n{2,}/g,"

"); h+="

"+hc+"

Generated by PantheraHive BOS
"; zip.file(folder+app+".html",h); zip.file(folder+"README.md","# "+title+"\n\nGenerated by PantheraHive BOS.\n\nFiles:\n- "+app+".md (Markdown)\n- "+app+".html (styled HTML)\n"); } 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);}});}