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

API Documentation: PantheraHive Notifications API

Welcome to the PantheraHive Notifications API documentation! This guide provides comprehensive details for integrating with our powerful notification system, enabling you to send real-time, personalized communications to your users.


Introduction to PantheraHive Notifications API

The PantheraHive Notifications API empowers developers to seamlessly integrate robust notification capabilities into their applications. Whether you need to send transactional alerts, marketing messages, or system updates, our API provides a flexible and reliable platform. Designed for scalability and ease of use, this API ensures your messages reach the right users at the right time, across various channels.

Key Features:

Who is this API for?

This documentation is intended for developers, product managers, and technical leads looking to integrate sophisticated notification features into web, mobile, or backend applications. A basic understanding of RESTful APIs, HTTP protocols, and JSON data formats is recommended.


Getting Started

To begin sending notifications with the PantheraHive Notifications API, follow these quick steps.

1. Authentication

All requests to the PantheraHive Notifications API must be authenticated using an API Key. You can generate your API Key from your PantheraHive Developer Dashboard under "API Keys".

Authentication Method:

Include your API Key in the Authorization header of every request as a Bearer token.

Example Header:

text • 696 chars
#### Get Notification Status

Retrieves the delivery status and details of a specific notification.

**Endpoint:** `/{notification_id}`
**Method:** `GET`

**Description:**
Use this endpoint to check the status of a notification previously sent via the `/send` endpoint. The `notification_id` is returned in the successful response of the `/send` call.

**Path Parameters:**

| Parameter         | Type   | Required | Description                     | Example             |
| :---------------- | :----- | :------- | :------------------------------ | :------------------ |
| `notification_id` | String | Yes      | The unique ID of the notification. | `noti_abc123xyz456` |

**Example Request:**

Sandboxed live preview

As "gemini", I have thoroughly researched the topic "API Documentation Writer" to provide a comprehensive and detailed understanding. This output serves as the foundational research for developing effective API documentation strategies and content.


Research Output: The API Documentation Writer

1. Introduction: The Critical Role of an API Documentation Writer

An API Documentation Writer is a specialized technical writer who creates, maintains, and manages documentation for Application Programming Interfaces (APIs). This role is crucial for the success and adoption of any API, acting as the primary bridge between the API's developers and its consumers (e.g., other developers, partners, internal teams). Effective API documentation significantly enhances the developer experience (DX), reduces support overhead, and accelerates integration time.

2. Core Responsibilities and Scope of Work

The responsibilities of an API Documentation Writer are multifaceted and highly collaborative, encompassing various stages of the API lifecycle:

  • Information Gathering & Research:

* Collaborating closely with API developers, product managers, and architects to understand API functionality, design, and intended use cases.

* Analyzing API specifications (e.g., OpenAPI/Swagger definitions), code, design documents, and test cases to extract necessary details.

* Participating in design reviews and sprint meetings to stay current with API development.

  • Content Creation & Development:

* Reference Documentation: Writing detailed descriptions of endpoints, methods, parameters, request/response bodies, authentication mechanisms, error codes, and data models.

* Getting Started Guides: Crafting clear, step-by-step instructions for initial setup, authentication, and making the first API call.

* Tutorials & How-To Guides: Developing practical, use-case-driven examples that demonstrate how to achieve specific tasks with the API.

* SDK Documentation: Explaining how to use Software Development Kits (SDKs) and client libraries.

* Code Samples: Creating and validating runnable code snippets in multiple programming languages (e.g., cURL, Python, JavaScript, Java, Ruby) to illustrate API usage.

* Conceptual Overviews: Providing high-level explanations of the API's architecture, core concepts, and underlying business logic.

  • Maintenance & Updates:

* Regularly reviewing and updating existing documentation to reflect API changes, deprecations, and new features.

* Managing version control for documentation to align with API versions.

* Ensuring accuracy, consistency, and completeness across all documentation assets.

  • Quality Assurance & Usability:

* Testing documentation against the live API to verify accuracy of examples and instructions.

* Gathering feedback from users and internal teams to identify areas for improvement.

* Ensuring documentation adheres to established style guides and branding.

  • Tooling & Process Management:

* Selecting and leveraging appropriate documentation tools and platforms.

* Defining and implementing documentation workflows and best practices.

* Contributing to the development of documentation standards and templates.

3. Essential Skills and Competencies

To excel in this role, an API Documentation Writer requires a unique blend of technical, writing, and interpersonal skills:

  • Exceptional Technical Writing Skills:

* Clarity, conciseness, and precision in language.

* Strong grammar, punctuation, and stylistic consistency.

* Ability to translate complex technical concepts into easily understandable language for varied audiences.

  • Strong Technical Aptitude:

* Fundamental understanding of API concepts (REST, GraphQL, SOAP, webhooks).

* Familiarity with data formats (JSON, XML) and serialization/deserialization.

* Knowledge of authentication methods (OAuth, API Keys, JWT).

* Ability to read and understand code (e.g., Python, JavaScript, Java, Go, C#) to interpret API behavior.

* Understanding of development workflows (version control, CI/CD).

  • User Empathy & Audience Awareness:

* Ability to put themselves in the shoes of the API consumer.

* Understanding different user personas (e.g., beginner developers, experienced integrators, business users).

* Focus on user goals and pain points.

  • Research and Information Gathering:

* Proficiency in interviewing Subject Matter Experts (SMEs).

* Ability to independently research and analyze technical specifications.

* Strong problem-solving skills to fill knowledge gaps.

  • Collaboration and Communication:

* Excellent interpersonal skills for working with developers, product managers, QA, and support teams.

* Ability to articulate documentation needs and advocate for the user experience.

  • Attention to Detail:

* Meticulous review for accuracy, completeness, and consistency.

* Careful validation of code samples and API responses.

4. Key Tools and Technologies

API Documentation Writers utilize a range of tools to create, manage, and publish documentation effectively:

  • API Specification Formats:

* OpenAPI (Swagger): Widely used for defining RESTful APIs, often serves as the source for generating documentation.

* AsyncAPI: For event-driven APIs.

  • Documentation Generators & Platforms:

* Swagger UI/Editor: For rendering OpenAPI specifications into interactive documentation.

* Postman: Can generate documentation directly from API collections.

* ReadMe.io, Stoplight, Apiary: Dedicated API documentation platforms offering interactive features, analytics, and versioning.

* Docusaurus, GitBook, Slate, MkDocs: Static site generators popular for technical documentation.

* Custom CMS/Publishing Systems: Internal tools for larger organizations.

  • Version Control Systems:

* Git (GitHub, GitLab, Bitbucket): Essential for managing documentation source files, collaboration, and versioning.

  • Markup Languages:

* Markdown, reStructuredText, AsciiDoc: For writing content in a human-readable and machine-renderable format.

  • API Testing Tools:

* Postman, Insomnia, cURL: Used to test API endpoints, validate responses, and generate accurate code samples.

  • Integrated Development Environments (IDEs) / Text Editors:

* VS Code, Sublime Text, Atom: For writing and editing documentation files and code samples.

5. Best Practices for API Documentation

Effective API documentation adheres to several guiding principles:

  • Clarity and Conciseness: Avoid jargon where possible, explain complex terms, and get straight to the point.
  • Accuracy and Up-to-Date: Documentation must reflect the current state and behavior of the API. Outdated documentation is worse than no documentation.
  • Consistency: Maintain a consistent structure, terminology, and style throughout the documentation. Use a style guide.
  • Completeness: Cover all essential aspects: authentication, endpoints, methods, parameters, request/response examples, error handling, rate limits, and deprecation policies.
  • Practical Examples: Provide runnable code samples in multiple popular languages. Show both request and response examples.
  • User-Centric Design: Organize documentation logically from the user's perspective, prioritizing common use cases. Include "getting started" guides and tutorials.
  • Discoverability and Navigability: Implement clear navigation, search functionality, and a well-structured table of contents.
  • Version Control: Clearly indicate the API version to which the documentation applies and provide access to previous versions.
  • Interactive Elements: Utilize interactive consoles (e.g., "Try It Out" features) where users can make live API calls directly from the documentation.
  • Feedback Mechanism: Provide a way for users to report issues or suggest improvements to the documentation.

6. Conclusion

The API Documentation Writer plays a pivotal role in the success of any API product. By providing clear, accurate, and user-friendly documentation, they empower developers, foster API adoption, and contribute significantly to a positive developer experience. This detailed research provides the necessary foundation for understanding the scope, skills, tools, and best practices involved in this critical function.

Possible status values for channels_status:

  • queued: Notification is in the queue for sending.
  • sending: Notification is currently being sent by a provider.
  • sent: Notification has been sent from our system.
  • delivered: Notification has been successfully delivered to the recipient's device/inbox.
  • failed: Notification failed to deliver.
  • opened: For email, the recipient opened the email.
  • clicked: For email, the recipient clicked a link in the email.

Error Handling

The PantheraHive Notifications API uses standard HTTP status codes to indicate the success or failure of an API request. In case of an error, the API will return a JSON object containing an error code, a human-readable message, and sometimes additional details.

| HTTP Status Code | Description |

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

| 200 OK | The request was successful. |

| 202 Accepted | The request was accepted for processing. |

| 400 Bad Request| The request was malformed or invalid. |

| 401 Unauthorized| Authentication credentials were missing or invalid. |

| 403 Forbidden | You do not have permission to access this resource. |

| 404 Not Found | The requested resource could not be found. |

| 429 Too Many Requests| You have exceeded the rate limit. |

| 500 Internal Server Error| An unexpected error occurred on the server. |

Common Error Codes:

| Error Code | Description | Suggested Action |

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

| INVALID_API_KEY | The provided API key is invalid or expired. | Check your API key. Generate a new one if necessary. |

| MISSING_PARAMETER | A required parameter is missing from the request. | Review the endpoint documentation and ensure all required parameters are included. |

| INVALID_PARAMETER | A parameter has an invalid value or format. | Check the data types and formats of your parameters. |

| TEMPLATE_NOT_FOUND | The specified template_id does not exist. | Verify the template_id in your PantheraHive dashboard. |

| RECIPIENT_INVALID | No valid recipient identifiers provided. | Ensure each recipient object has at least user_id, email, or phone. |

| RATE_LIMIT_EXCEEDED | You have sent too many requests in a given time. | Implement exponential backoff and retry mechanisms. Refer to Rate Limiting section. |


Rate Limiting

To ensure fair usage and system stability, the PantheraHive Notifications API enforces rate limits. If you exceed these limits, you will receive an HTTP 429 Too Many Requests status code.

Current Limits:

  • Default: 100 requests per second per API key.
  • Higher limits may be available for enterprise accounts. Please contact support.

Headers for Rate Limit Information:

When you make an API request, the response headers will include information about your current rate limit status:

  • 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) when the current rate limit window resets.

Handling Rate Limits:

When a 429 error is received, we recommend implementing an exponential backoff strategy for retries. Do not immediately retry the request. Instead, wait for the duration specified in the Retry-After header (if present) or implement a progressively longer delay between retries.


SDKs and Libraries

To simplify your integration process, we offer official SDKs for popular programming languages. These SDKs handle authentication, request signing, and provide convenient methods for interacting with the API.

  • Node.js SDK: [Link to GitHub / npm package]
  • Python SDK: [Link to GitHub / PyPI package]
  • Java SDK: [Link to GitHub / Maven package]

Stay tuned! We are continuously developing and releasing new SDKs to support a wider range of development environments.


Support & Feedback

We're here to help you succeed! If you encounter any issues, have questions, or would like to provide feedback, please reach out to us.

  • Documentation Feedback: Found an error or something unclear? Click the "Suggest an Edit" button at the top of this page or open an issue on our [Documentation GitHub Repository](https://github.com/PantheraHive/docs).
  • Technical Support: For integration issues, bug reports, or account-specific queries, please visit our [Support Portal](https://support.pantherahive.com) or email support@pantherahive.com.
  • Community Forum: Join our developer community to share ideas, ask questions, and connect with other PantheraHive users: [community.pantherahive.com](https://community.pantherahive.com).

Ready to Build?

Start integrating the PantheraHive Notifications API today and elevate your application's communication capabilities.

[Sign Up for a Free PantheraHive Account](https://pantherahive.com/signup)

[Access Your Developer Dashboard](https://pantherahive.com/dashboard)

[Explore Notification Templates](https://pantherahive.com/templates)

gemini Output

API Documentation: Product Management API

This document provides a comprehensive guide to integrating with the Product Management API. It details available endpoints, authentication methods, request/response formats, and error handling. This API allows for programmatic management of products, categories, and related data within your system.


1. Introduction

The Product Management API offers a robust set of RESTful endpoints designed to facilitate the creation, retrieval, updating, and deletion of product-related data. Developers can leverage this API to build custom integrations, automate product catalog updates, synchronize data across platforms, and extend the functionality of their existing applications.

Key Features:

  • Manage product details (name, description, price, SKU, etc.).
  • Organize products into categories.
  • Retrieve comprehensive product listings and individual product data.
  • Secure access via API Keys.

2. Getting Started

2.1. Authentication

The Product Management API uses API Key authentication. To authenticate your requests, you must include your unique API Key in the X-API-Key header of every request.

  • Header Name: X-API-Key
  • Header Value: YOUR_API_KEY (e.g., sk_live_xyz123abc456)

Example Request Header:


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

Obtaining Your API Key:

Your API Key can be generated and managed from your developer dashboard under "API Settings". Treat your API Key as a sensitive credential and keep it secure. Do not expose it in client-side code or public repositories.

2.2. Base URL

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

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

2.3. Request Headers

In addition to the X-API-Key header, the following headers are generally recommended or required:

  • Content-Type: application/json (for requests with a body, e.g., POST, PUT)
  • Accept: application/json (to explicitly request JSON responses)

3. API Endpoints

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

3.1. Products

##### 3.1.1. Get All Products

Retrieves a list of all products. Supports pagination and filtering.

  • Endpoint: /products
  • Method: GET
  • Description: Returns an array of product objects.
  • Parameters:

* page (Query, Integer, Optional): The page number to retrieve. Default is 1.

* limit (Query, Integer, Optional): The number of items per page. Max is 100. Default is 20.

* category_id (Query, String, Optional): Filter products by a specific category ID.

* status (Query, String, Optional): Filter products by status (e.g., active, draft, archived).

  • Response Status Codes:

* 200 OK: Successfully retrieved the list of products.

* 401 Unauthorized: Invalid or missing API Key.

* 400 Bad Request: Invalid query parameters.

Example Request (cURL):


curl -X GET \
  'https://api.example.com/api/v1/products?page=1&limit=10&status=active' \
  -H 'Accept: application/json' \
  -H 'X-API-Key: YOUR_API_KEY'

Example Response (200 OK):


{
  "page": 1,
  "limit": 10,
  "total_items": 50,
  "total_pages": 5,
  "data": [
    {
      "id": "prod_abc123",
      "name": "Wireless Bluetooth Headphones",
      "description": "High-fidelity sound with active noise cancellation.",
      "sku": "WH-BT-001",
      "price": 99.99,
      "currency": "USD",
      "category_id": "cat_audio",
      "status": "active",
      "created_at": "2023-01-15T10:00:00Z",
      "updated_at": "2023-01-15T10:00:00Z"
    },
    {
      "id": "prod_xyz789",
      "name": "Smartwatch Series 5",
      "description": "Track your fitness and stay connected.",
      "sku": "SW-S5-001",
      "price": 249.00,
      "currency": "USD",
      "category_id": "cat_wearables",
      "status": "active",
      "created_at": "2023-02-20T14:30:00Z",
      "updated_at": "2023-02-20T14:30:00Z"
    }
  ]
}

##### 3.1.2. Get Product by ID

Retrieves a single product by its unique identifier.

  • Endpoint: /products/{product_id}
  • Method: GET
  • Description: Returns a single product object.
  • Parameters:

* product_id (Path, String, Required): The unique ID of the product.

  • Response Status Codes:

* 200 OK: Successfully retrieved the product.

* 401 Unauthorized: Invalid or missing API Key.

* 404 Not Found: Product with the given ID does not exist.

Example Request (cURL):


curl -X GET \
  'https://api.example.com/api/v1/products/prod_abc123' \
  -H 'Accept: application/json' \
  -H 'X-API-Key: YOUR_API_KEY'

Example Response (200 OK):


{
  "id": "prod_abc123",
  "name": "Wireless Bluetooth Headphones",
  "description": "High-fidelity sound with active noise cancellation.",
  "sku": "WH-BT-001",
  "price": 99.99,
  "currency": "USD",
  "category_id": "cat_audio",
  "status": "active",
  "created_at": "2023-01-15T10:00:00Z",
  "updated_at": "2023-01-15T10:00:00Z"
}

##### 3.1.3. Create a New Product

Adds a new product to the catalog.

  • Endpoint: /products
  • Method: POST
  • Description: Creates a new product and returns the created product object.
  • Request Body (JSON):

* name (String, Required): The name of the product.

* description (String, Optional): A detailed description of the product.

* sku (String, Required): Stock Keeping Unit, must be unique.

* price (Number, Required): The price of the product.

* currency (String, Required): The currency code (e.g., USD, EUR).

* category_id (String, Optional): The ID of the category this product belongs to.

* status (String, Optional): The initial status of the product. Default is draft.

  • Response Status Codes:

* 201 Created: Successfully created the product.

* 400 Bad Request: Invalid request body or missing required fields.

* 401 Unauthorized: Invalid or missing API Key.

* 409 Conflict: A product with the given SKU already exists.

Example Request (cURL):


curl -X POST \
  'https://api.example.com/api/v1/products' \
  -H 'Content-Type: application/json' \
  -H 'X-API-Key: YOUR_API_KEY' \
  -d '{
        "name": "Gaming Mouse Pro",
        "description": "Ergonomic gaming mouse with customizable RGB lighting.",
        "sku": "GM-PRO-001",
        "price": 79.99,
        "currency": "USD",
        "category_id": "cat_peripherals",
        "status": "active"
      }'

Example Response (201 Created):


{
  "id": "prod_def456",
  "name": "Gaming Mouse Pro",
  "description": "Ergonomic gaming mouse with customizable RGB lighting.",
  "sku": "GM-PRO-001",
  "price": 79.99,
  "currency": "USD",
  "category_id": "cat_peripherals",
  "status": "active",
  "created_at": "2023-03-01T09:15:00Z",
  "updated_at": "2023-03-01T09:15:00Z"
}

##### 3.1.4. Update a Product

Modifies an existing product. Only fields provided in the request body will be updated.

  • Endpoint: /products/{product_id}
  • Method: PUT (or PATCH for partial updates, assuming PUT for full replacement here)
  • Description: Updates an existing product and returns the updated product object.
  • Parameters:

* product_id (Path, String, Required): The unique ID of the product to update.

  • Request Body (JSON):

* name (String, Optional): New name for the product.

* description (String, Optional): New description for the product.

* price (Number, Optional): New price for the product.

* currency (String, Optional): New currency for the product.

* category_id (String, Optional): New category ID.

* status (String, Optional): New status for the product.

  • Response Status Codes:

* 200 OK: Successfully updated the product.

* 400 Bad Request: Invalid request body.

* 401 Unauthorized: Invalid or missing API Key.

* 404 Not Found: Product with the given ID does not exist.

Example Request (cURL):


curl -X PUT \
  'https://api.example.com/api/v1/products/prod_abc123' \
  -H 'Content-Type: application/json' \
  -H 'X-API-Key: YOUR_API_KEY' \
  -d '{
        "price": 89.99,
        "status": "on_sale"
      }'

Example Response (200 OK):


{
  "id": "prod_abc123",
  "name": "Wireless Bluetooth Headphones",
  "description": "High-fidelity sound with active noise cancellation.",
  "sku": "WH-BT-001",
  "price": 89.99,
  "currency": "USD",
  "category_id": "cat_audio",
  "status": "on_sale",
  "created_at": "2023-01-15T10:00:00Z",
  "updated_at": "2023-03-05T11:30:00Z"
}

##### 3.1.5. Delete a Product

Removes a product from the catalog.

  • Endpoint: /products/{product_id}
  • Method: DELETE
  • Description: Deletes the specified product. This action is irreversible.
  • Parameters:

* product_id (Path, String, Required): The unique ID of the product to delete.

  • Response Status Codes:

* 204 No Content: Product successfully deleted.

* 401 Unauthorized: Invalid or missing API Key.

* 404 Not Found: Product with the given ID does not exist.

Example Request (cURL):


curl -X DELETE \
  'https://api.example.com/api/v1/products/prod_abc123' \
  -H 'X-API-Key: YOUR_API_KEY'

Example Response (204 No Content):

(No response body for 204 status)


3.2. Categories

##### 3.2.1. Get All Categories

Retrieves a list of all product categories.

  • Endpoint: /categories
  • Method: GET
  • Description: Returns an array of category objects.
  • Parameters:

* page (Query, Integer, Optional): The page number to retrieve. Default is 1.

* limit (Query, Integer, Optional): The number of items per page. Max is 100. Default is 20.

  • Response Status Codes:

* 200 OK: Successfully retrieved the list of categories.

* 401 Unauthorized: Invalid or missing API Key.

* 400 Bad Request: Invalid query parameters.

Example Request (cURL):


curl -X GET \
  'https://api.example.com/api/v1/categories' \
  -H 'Accept: application/json' \
  -H 'X-API-Key: YOUR_API_KEY'

Example Response (200 OK):


{
  "page": 1,
  "limit": 20,
  "total_items": 3,
  "total_pages": 1,
  "data": [
    {
      "id": "cat_audio",
      "name": "Audio Devices",
      "slug": "audio-devices",
      "description": "Headphones, speakers, and other audio equipment.",
      "created_at": "2022-10-01T08:00:00Z",
      "updated_at": "2022-10-01T08:00:00Z"
    },
    {
      "id": "
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);}});}