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

PantheraHive Product Catalog API Documentation

Unleash Your Product Data: A Comprehensive Guide to the PantheraHive Product Catalog API

Welcome to the PantheraHive Product Catalog API documentation! This guide provides everything you need to integrate, manage, and retrieve your product data programmatically. Designed for developers, our API offers a robust and flexible way to interact with your product catalog, enabling seamless synchronization with e-commerce platforms, mobile applications, and internal systems.

Whether you're looking to display product listings, update inventory, or manage product details, this documentation will walk you through the process, from authentication to advanced usage.


1. Getting Started: Your First API Call

This section will guide you through making your very first API request to the PantheraHive Product Catalog.

1.1. Authentication

All requests to the PantheraHive Product Catalog API require authentication using an API Key.

  1. Obtain Your API Key:

* Log in to your PantheraHive developer dashboard.

* Navigate to "API Keys" under your project settings.

* Generate a new API Key if you don't have one, or use an existing one.

* Keep your API Key secure and do not share it publicly.

  1. Include API Key in Requests:

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

Example Header:

text • 2,170 chars
---

### 4. Error Handling

The PantheraHive Product Catalog 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` field with a `code` and a `message`, and optionally `details` for more specific issues.

| HTTP Status Code | Error Code         | Description                                                                                               |
| :--------------- | :----------------- | :-------------------------------------------------------------------------------------------------------- |
| `200 OK`         | -                  | The request was successful.                                                                               |
| `201 Created`    | -                  | A new resource was successfully created.                                                                  |
| `204 No Content` | -                  | The request was successful, but there's no content to return (e.g., successful deletion).                 |
| `400 Bad Request`| `INVALID_INPUT`    | The request was malformed or missing required parameters. Check `details` for specific issues.            |
| `401 Unauthorized`| `UNAUTHORIZED`    | Authentication credentials were missing or invalid. Check your `X-API-Key` header.                        |
| `403 Forbidden`  | `FORBIDDEN`        | The authenticated user does not have permission to perform this action.                                   |
| `404 Not Found`  | `RESOURCE_NOT_FOUND`| The requested resource (e.g., product ID) could not be found.                                             |
| `405 Method Not Allowed`| `METHOD_NOT_ALLOWED`| The HTTP method used is not supported for this endpoint.                                                |
| `429 Too Many Requests`| `RATE_LIMIT_EXCEEDED`| You have sent too many requests in a given amount of time. See Rate Limiting section.                   |
| `500 Internal Server Error`| `INTERNAL_ERROR`| An unexpected error occurred on the server. Please try again later or contact support if the issue persists.|

**Example Error Response:**

Sandboxed live preview

Step 1 of 3: Research Topic - API Documentation Writer

This deliverable provides a comprehensive overview of the "API Documentation Writer" role, encompassing the core responsibilities, essential components of API documentation, key tools, best practices, and the skills required for success. This foundational research will guide subsequent steps in the workflow, ensuring a thorough and professional approach to generating API documentation.


1. Understanding the Role of an API Documentation Writer

An API Documentation Writer is a specialized technical writer focused on creating clear, accurate, and user-friendly documentation for Application Programming Interfaces (APIs). Their primary goal is to enable developers, both internal and external, to understand, integrate, and effectively use an API with minimal friction. They act as a crucial bridge between the API developers and the API consumers.

Core Responsibilities:

  • Content Creation: Writing, editing, and maintaining various forms of API documentation.
  • Information Architecture: Structuring documentation logically for easy navigation and discoverability.
  • Technical Accuracy: Collaborating with engineers to ensure all technical details are correct and up-to-date.
  • User Empathy: Understanding the needs and pain points of target audiences (e.g., developers, product managers).
  • Tool Proficiency: Utilizing documentation tools, version control systems, and API specification formats.
  • Feedback Integration: Incorporating user feedback to continuously improve documentation.
  • Style & Consistency: Adhering to style guides and maintaining a consistent voice and tone.

2. Core Components of API Documentation

Effective API documentation typically includes a range of elements designed to support the user journey from discovery to integration and ongoing use.

  • Getting Started Guide / Quickstart:

* Purpose: Rapid onboarding for new users.

* Content: High-level overview, authentication steps, first API call example, common use cases.

  • Authentication & Authorization:

* Purpose: Explaining how to securely access the API.

* Content: Supported authentication methods (API keys, OAuth 2.0, JWT), token management, permissions, security best practices.

  • API Reference:

* Purpose: Detailed, exhaustive information about each API endpoint.

* Content:

* Endpoint Details: HTTP method (GET, POST, PUT, DELETE), URL path.

* Parameters: Path, query, header, body parameters (name, type, description, required/optional, example values).

* Request Examples: Code snippets in multiple languages (cURL, Python, Node.js, Ruby, Java, etc.).

* Response Examples: Sample JSON/XML responses for success and various error codes.

* Status Codes: Explanation of common HTTP status codes (200, 201, 400, 401, 403, 404, 500, etc.).

  • Tutorials & How-To Guides:

* Purpose: Step-by-step instructions for achieving specific tasks or integrating common features.

* Content: Practical examples, code walkthroughs, use-case specific solutions.

  • Concepts & Explanations:

* Purpose: Providing foundational knowledge and context for the API's design and functionality.

* Content: Architectural overview, data models, key terminology, design principles, rate limiting, webhooks.

  • SDKs (Software Development Kits) & Libraries:

* Purpose: Guiding users on how to use provided client libraries.

* Content: Installation instructions, usage examples, supported languages.

  • Error Handling:

* Purpose: Helping users diagnose and resolve issues.

* Content: Common error codes, error message formats, troubleshooting tips.

  • Release Notes & Changelog:

* Purpose: Informing users about API updates, new features, deprecations, and breaking changes.

* Content: Version numbers, date, summary of changes, migration guides.

  • Support & Community Resources:

* Purpose: Directing users to help channels.

* Content: FAQs, support forums, contact information, service status page.

3. Key Target Audiences

API documentation must cater to diverse user needs, often requiring different levels of detail and types of examples.

  • Software Developers: The primary audience, needing detailed technical specifications, code examples, and troubleshooting guides.
  • Product Managers: Interested in API capabilities, use cases, and how it aligns with business goals.
  • Technical Writers (internal/external): May use the documentation to understand the API for their own projects or to contribute.
  • Solution Architects: Need to understand the API's architecture, scalability, and integration patterns.
  • QA Engineers: Use documentation to validate API functionality and responses.

4. Essential Tools & Technologies

API Documentation Writers leverage a variety of tools to create, manage, and publish documentation efficiently.

  • API Specification Formats:

* OpenAPI Specification (OAS) / Swagger: Industry standard for describing RESTful APIs. Enables auto-generation of documentation, client SDKs, and server stubs.

* AsyncAPI: For event-driven APIs (e.g., Kafka, WebSocket).

* RAML (RESTful API Modeling Language): Another specification for RESTful APIs.

  • Documentation Generators:

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

* Docusaurus, GitBook, Read the Docs, MkDocs: Static site generators popular for technical documentation.

* Postman: Can generate documentation from collections.

* Stoplight Studio, ReadMe.io, Apigee: API-specific documentation platforms that offer advanced features.

  • Version Control Systems:

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

  • Markdown Editors:

* VS Code, Sublime Text, Typora: For writing content in Markdown, a lightweight markup language.

  • Diagramming Tools:

* draw.io (diagrams.net), Lucidchart, Miro: For creating visual aids like architectural diagrams, flowcharts, and sequence diagrams.

  • API Clients/Testing Tools:

* Postman, Insomnia, cURL: For testing API endpoints, generating request/response examples, and verifying documentation accuracy.

5. Best Practices & Principles for Effective API Documentation

  • Accuracy & Completeness: Ensure all information is technically correct and all aspects of the API are covered.
  • Clarity & Conciseness: Use plain language, avoid jargon where possible, and get straight to the point.
  • Consistency: Maintain a consistent style, terminology, and structure across all documentation.
  • User-Centric Approach: Write from the perspective of the developer, anticipating their questions and needs.
  • Discoverability & Navigation: Implement clear headings, a logical table of contents, search functionality, and internal linking.
  • Actionable Examples: Provide abundant, runnable code examples in multiple popular languages for every endpoint and common use case.
  • Interactive Elements: Incorporate "Try It Out" features (e.g., Swagger UI), API explorers, and sandbox environments.
  • Version Control & Changelogs: Clearly indicate API versions, document breaking changes, and provide migration guides.
  • Visual Aids: Use diagrams, flowcharts, and screenshots to explain complex concepts.
  • Regular Updates: Keep documentation current with API changes, deprecations, and new features.
  • Feedback Mechanism: Provide an easy way for users to submit feedback, report errors, or ask questions.
  • DRY (Don't Repeat Yourself): Leverage API specification formats (like OpenAPI) to generate documentation from a single source of truth.

6. Challenges in API Documentation

  • Keeping Up with API Changes: APIs evolve rapidly, making it challenging to keep documentation current and accurate.
  • Bridging the Gap: Translating complex technical concepts from engineers into understandable language for various audiences.
  • Tooling Complexity: Managing multiple documentation tools, build processes, and publishing pipelines.
  • Lack of Developer Engagement: Difficulty in getting engineers to contribute to or review documentation effectively.
  • Measuring Effectiveness: Quantifying the impact of documentation on developer adoption and success.
  • Handling Multiple Versions: Managing documentation for different API versions simultaneously.

7. Essential Skills for an API Documentation Writer

  • Technical Aptitude: Strong understanding of software development principles, web technologies (HTTP, REST), data formats (JSON, XML), and programming concepts.
  • Writing & Editing: Excellent command of grammar, style, and ability to write clear, concise, and engaging technical content.
  • Empathy & User Focus: Ability to understand and advocate for the user's perspective.
  • Collaboration: Strong interpersonal skills to work effectively with engineers, product managers, and QA teams.
  • Problem-Solving: Ability to break down complex topics into digestible information and troubleshoot documentation issues.
  • Tool Proficiency: Expertise in documentation tools, markdown, version control, and API specification formats.
  • Attention to Detail: Meticulousness in ensuring accuracy, consistency, and completeness.
  • Basic Programming Knowledge: Ability to read and understand code snippets (e.g., Python, JavaScript, Java, cURL) to verify examples.

This research provides a robust foundation for the subsequent steps of the "API Documentation Writer" workflow, ensuring that the generated output is comprehensive, professional, and directly addresses the core requirements of high-quality API documentation.


5. Rate Limiting

To ensure fair usage and maintain API stability, the PantheraHive Product Catalog API implements rate limiting.

  • Limit: 100 requests per minute per API Key.
  • Headers: When you make an API request, the following headers will be included
gemini Output

This document presents the finalized and professionally formatted API documentation, a deliverable from the "API Documentation Writer" workflow. This output has been meticulously polished for clarity, accuracy, and ease of use, ensuring it serves as a comprehensive guide for developers integrating with the PantheraHive Product Management API.


PantheraHive Product Management API Documentation

Welcome to the official documentation for the PantheraHive Product Management API. This API provides programmatic access to manage product catalogs, user orders, and customer information within the PantheraHive ecosystem.

Our API is designed to be RESTful, predictable, and easy to use, allowing you to seamlessly integrate product management functionalities into your applications.

1. Introduction

The PantheraHive Product Management API enables developers to build powerful applications that interact with our product catalog, manage customer orders, and retrieve user data. This documentation will guide you through authentication, available endpoints, request/response formats, and error handling.

Key Features:

  • Product Management: Create, retrieve, update, and delete product listings.
  • Order Management: Retrieve and create customer orders.
  • User Information: Access user profiles (with appropriate permissions).

2. Base URL

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

https://api.pantherahive.com/v1

3. Authentication

The PantheraHive Product Management API uses API Key authentication. You must include your unique API key in the X-API-Key header for every request to an authenticated endpoint.

You can obtain your API key from your PantheraHive developer dashboard.

Example Authentication Header:


X-API-Key: YOUR_API_KEY_HERE

Important Notes:

  • Keep your API key secure and do not expose it in client-side code.
  • If your API key is compromised, generate a new one immediately from your developer dashboard.

4. Error Handling

The 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 details about the error.

| HTTP Status Code | Description | Common Cause |

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

| 200 OK | Request successful. | N/A |

| 201 Created | Resource successfully created. | N/A |

| 204 No Content | Request successful, no content to return. | Successfully deleted a resource. |

| 400 Bad Request| The request was malformed or invalid. | Missing required parameters, invalid data types. |

| 401 Unauthorized| Authentication failed or API key is missing. | Invalid API Key, no X-API-Key header. |

| 403 Forbidden | You do not have permission to access this resource.| Insufficient permissions for the requested action. |

| 404 Not Found | The requested resource could not be found. | Invalid resource ID, incorrect endpoint path. |

| 405 Method Not Allowed| The HTTP method used is not supported for this endpoint.| Using GET on an endpoint that only supports POST. |

| 429 Too Many Requests| You have exceeded the API rate limit. | Sending too many requests in a short period. |

| 500 Internal Server Error| An unexpected error occurred on the server. | A bug on our end. Please report this with request details if it persists. |

Example Error Response (400 Bad Request):


{
  "status": 400,
  "code": "invalid_parameter",
  "message": "The 'name' field is required.",
  "details": [
    {
      "field": "name",
      "issue": "must not be blank"
    }
  ]
}

5. Rate Limiting

To ensure fair usage and system stability, the PantheraHive Product Management API enforces rate limits.

  • Limit: 100 requests per minute per API Key.
  • Exceeding the limit: Will result in a 429 Too Many Requests HTTP status code.

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

6. Endpoints

This section details the available API endpoints, their methods, request parameters, and response structures.

6.1. Products

The Products endpoint allows you to manage product listings in your catalog.


##### 6.1.1. List All Products

GET /products

Retrieves a list of all products in the catalog.

Parameters:

| Name | Type | Description | Required | Default |

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

| limit | integer| Maximum number of products to return (1-100). | No | 20 |

| offset | integer| Number of products to skip for pagination. | No | 0 |

| category| string | Filter products by a specific category. | No | All |

Request Example:


curl -X GET \
  'https://api.pantherahive.com/v1/products?limit=5&category=electronics' \
  -H 'X-API-Key: YOUR_API_KEY_HERE'

Response (200 OK):


{
  "data": [
    {
      "id": "prod_abc123",
      "name": "Wireless Ergonomic Mouse",
      "description": "2.4GHz wireless mouse with adjustable DPI.",
      "price": 29.99,
      "currency": "USD",
      "category": "electronics",
      "stock": 150,
      "created_at": "2023-01-15T10:00:00Z",
      "updated_at": "2023-01-15T10:00:00Z"
    },
    {
      "id": "prod_def456",
      "name": "Mechanical Keyboard",
      "description": "RGB backlit mechanical keyboard with blue switches.",
      "price": 79.99,
      "currency": "USD",
      "category": "electronics",
      "stock": 75,
      "created_at": "2023-02-01T14:30:00Z",
      "updated_at": "2023-02-01T14:30:00Z"
    }
  ],
  "meta": {
    "total": 2,
    "limit": 5,
    "offset": 0
  }
}

##### 6.1.2. Get a Single Product

GET /products/{id}

Retrieves details for a specific product by its ID.

Path Parameters:

| Name | Type | Description | Required |

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

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

Request Example:


curl -X GET \
  'https://api.pantherahive.com/v1/products/prod_abc123' \
  -H 'X-API-Key: YOUR_API_KEY_HERE'

Response (200 OK):


{
  "id": "prod_abc123",
  "name": "Wireless Ergonomic Mouse",
  "description": "2.4GHz wireless mouse with adjustable DPI.",
  "price": 29.99,
  "currency": "USD",
  "category": "electronics",
  "stock": 150,
  "created_at": "2023-01-15T10:00:00Z",
  "updated_at": "2023-01-15T10:00:00Z"
}

Response (404 Not Found):


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

##### 6.1.3. Create a New Product

POST /products

Creates a new product in the catalog.

Request Body:

| Name | Type | Description | Required |

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

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

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

| price | number | The price of the product. | Yes |

| currency | string | The currency code (e.g., "USD", "EUR"). | Yes |

| category | string | The product category. | No |

| stock | integer | The initial stock quantity of the product. | Yes |

Request Example:


curl -X POST \
  'https://api.pantherahive.com/v1/products' \
  -H 'Content-Type: application/json' \
  -H 'X-API-Key: YOUR_API_KEY_HERE' \
  -d '{
        "name": "Smart LED Desk Lamp",
        "description": "Dimmable LED lamp with color temperature control.",
        "price": 49.99,
        "currency": "USD",
        "category": "home_goods",
        "stock": 200
      }'

Response (201 Created):


{
  "id": "prod_new789",
  "name": "Smart LED Desk Lamp",
  "description": "Dimmable LED lamp with color temperature control.",
  "price": 49.99,
  "currency": "USD",
  "category": "home_goods",
  "stock": 200,
  "created_at": "2023-03-20T11:00:00Z",
  "updated_at": "2023-03-20T11:00:00Z"
}

6.2. Orders

The Orders endpoint allows you to manage customer orders.


##### 6.2.1. Get a Single Order

GET /orders/{id}

Retrieves details for a specific order by its ID.

Path Parameters:

| Name | Type | Description | Required |

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

| id | string | The unique ID of the order. | Yes |

Request Example:


curl -X GET \
  'https://api.pantherahive.com/v1/orders/ord_xyz789' \
  -H 'X-API-Key: YOUR_API_KEY_HERE'

Response (200 OK):


{
  "id": "ord_xyz789",
  "user_id": "user_101",
  "status": "completed",
  "total_amount": 109.98,
  "currency": "USD",
  "items": [
    {
      "product_id": "prod_abc123",
      "name": "Wireless Ergonomic Mouse",
      "quantity": 2,
      "unit_price": 29.99
    },
    {
      "product_id": "prod_new789",
      "name": "Smart LED Desk Lamp",
      "quantity": 1,
      "unit_price": 49.99
    }
  ],
  "shipping_address": {
    "street": "123 Main St",
    "city": "Anytown",
    "state": "CA",
    "zip_code": "90210",
    "country": "USA"
  },
  "created_at": "2023-03-20T12:05:00Z",
  "updated_at": "2023-03-20T12:15:00Z"
}

Response (404 Not Found):


{
  "status": 404,
  "code": "order_not_found",
  "message": "Order with ID 'ord_nonexistent' not found."
}

7. Data Models

This section provides a detailed schema for the common data objects returned by the API.

7.1. Product Object

Represents a single product in the catalog.

| Field | Type | Description | Example |

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

| id | string | Unique identifier for the product. | prod_abc123 |

| name | string | The product's name. | Wireless Ergonomic Mouse |

| description| string | A detailed description of the product. | 2.4GHz wireless mouse... |

| price | number | The current price of the product. | 29.99 |

| currency | string | The currency code (e.g., USD, EUR). | USD |

| category | string | The product's category. | electronics |

| stock | integer | The current stock quantity. | 150 |

| created_at| string | ISO 8601 timestamp of when the product was created. | `2023-01-15T10:00:

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);}});}