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

We are delighted to present the comprehensive API Documentation for the PantheraHive Data Service API. This document is meticulously crafted to empower developers with the knowledge and tools needed to seamlessly integrate with our robust data platform.


PantheraHive Data Service API Documentation

Welcome to the PantheraHive Data Service API!

Welcome, developers! The PantheraHive Data Service API provides a powerful and flexible interface for accessing and managing your structured data within the PantheraHive ecosystem. Whether you're building custom applications, integrating with third-party services, or automating data workflows, our API offers secure, reliable, and high-performance access to your most critical information.

This documentation is your definitive guide to understanding our API's capabilities, authentication methods, available endpoints, and best practices for integration. We've designed it to be clear, concise, and actionable, enabling you to get up and running quickly.

Key Features:

Ready to start building?

[Get Your API Key Now](#getting-started) | [Explore Our Endpoints](#api-endpoints) | [Join Our Developer Community](https://pantherahive.com/community)


1. Getting Started

This section will guide you through the initial steps to make your first successful API call.

1.1. Authentication

All requests to the PantheraHive Data Service API must be authenticated. We primarily use API Key authentication via the Authorization header.

  1. Obtain Your API Key:

* Sign up for a PantheraHive developer account.

* Navigate to your Developer Dashboard.

* Generate a new API Key for your application.

* Keep your API key secure! Do not share it publicly or commit it to version control.

  1. Include in Requests:

* Your API Key must be sent in the Authorization header of every request, prefixed with Bearer.

Example Header:

text • 1,401 chars
---

## 4. Rate Limiting

To ensure fair usage and maintain service stability, the PantheraHive Data Service API enforces rate limits.

*   **Limit:** `100 requests per minute` per API Key.
*   **Exceeded Limit:** Requests exceeding the rate limit will receive a `429 Too Many Requests` HTTP status code.

**Headers for Rate Limiting:**

| Header           | Description                                        |
| :--------------- | :------------------------------------------------- |
| `X-RateLimit-Limit` | The maximum number of requests allowed in the current window. |
| `X-RateLimit-Remaining`| The number of requests remaining in the current window. |
| `X-RateLimit-Reset`| The time (in UTC epoch seconds) when the current rate limit window resets. |

**Best Practice:** Implement retry logic with exponential backoff for `429` responses.

---

## 5. Webhooks

For real-time notifications about data changes without constant polling, leverage our Webhooks.

### 5.1. Subscribing to Webhooks

You can subscribe to events such as `product.created`, `product.updated`, or `product.deleted` via your Developer Dashboard or programmatically through our Webhook API (refer to the `/webhooks` endpoint documentation).

### 5.2. Webhook Event Structure

When an event occurs, we will send an HTTP POST request to your registered webhook URL with a JSON payload.

**Example `product.created` Event:**
Sandboxed live preview

Research Topic: The API Documentation Writer Role

This document provides a comprehensive overview of the "API Documentation Writer" role, detailing its core responsibilities, essential skills, key tools, best practices, and the critical importance of high-quality API documentation. This research serves as the foundational understanding for generating detailed, professional output in subsequent steps of the "API Documentation Writer" workflow.


1. Introduction to the API Documentation Writer Role

An API Documentation Writer is a specialized technical writer who focuses on creating clear, accurate, and comprehensive documentation for Application Programming Interfaces (APIs). Their primary goal is to bridge the gap between complex technical API functionality and the developers or users who need to integrate and utilize those APIs. They translate intricate technical specifications into accessible, actionable content that enables efficient API adoption and usage.

2. Core Responsibilities of an API Documentation Writer

The role encompasses a wide range of tasks crucial for successful API adoption and developer experience:

  • Understanding API Functionality: Deeply grasp the API's architecture, endpoints, request/response formats, authentication mechanisms, error codes, and overall purpose by collaborating closely with engineers and product managers.
  • Audience Analysis: Identify and understand the target audience (e.g., internal developers, third-party partners, specific industry sectors) to tailor the content's depth, tone, and examples.
  • Content Creation:

* Reference Documentation: Detail individual API endpoints, methods, parameters, data models, and authentication.

* Getting Started Guides: Provide step-by-step instructions for initial setup and first API calls.

* Tutorials and How-To Guides: Offer practical examples and use cases for common tasks.

* Code Samples and SDK Documentation: Develop and maintain code snippets in various programming languages.

* Conceptual Overviews: Explain core concepts, architectural patterns, and design principles.

* Troubleshooting Guides: Document common issues and their resolutions.

  • Information Architecture: Design a logical, intuitive, and searchable structure for the documentation portal, ensuring easy navigation and discoverability of information.
  • Maintaining and Updating Documentation: Keep documentation current with API changes, new features, deprecations, and bug fixes, often by integrating with the software development lifecycle.
  • Collaboration and Communication: Work effectively with cross-functional teams, including software engineers, product managers, quality assurance, and support teams, to gather information and ensure accuracy.
  • Tooling and Standards: Utilize documentation tools, API specification formats (e.g., OpenAPI), and version control systems to manage and publish documentation efficiently.
  • Feedback Integration: Solicit and incorporate feedback from users and internal teams to continuously improve the clarity, accuracy, and usefulness of the documentation.

3. Key Skills Required

An effective API Documentation Writer possesses a blend of technical, writing, and interpersonal skills:

  • Technical Aptitude:

* Strong understanding of API concepts (REST, GraphQL, SOAP, gRPC).

* Familiarity with data formats (JSON, XML).

* Ability to read and understand code (e.g., Python, JavaScript, Java, cURL).

* Knowledge of web technologies (HTTP, client-server architecture).

* Understanding of authentication/authorization methods (OAuth, API Keys).

  • Exceptional Writing Skills:

* Clarity, conciseness, and accuracy in explaining complex technical topics.

* Strong grammar, punctuation, and syntax.

* Ability to adapt writing style and tone for different audiences.

* Experience with style guides and content standards.

  • User Empathy and Developer Experience (DX) Focus:

* Ability to anticipate user questions and pain points.

* Focus on creating a positive and efficient experience for developers.

  • Attention to Detail: Meticulous review of technical details, code examples, and instructions to ensure correctness.
  • Problem-Solving Skills: Ability to break down complex systems into digestible components and explain them simply.
  • Collaboration and Communication: Strong interpersonal skills for effective teamwork and information gathering.
  • Version Control Familiarity: Understanding of Git and common platforms like GitHub, GitLab, or Bitbucket.
  • Markup Languages: Proficiency in Markdown, reStructuredText, or similar.

4. Essential Tools & Technologies

API Documentation Writers leverage various tools to create, manage, and publish their content:

  • API Specification Formats:

* OpenAPI Specification (OAS/Swagger): Industry standard for describing RESTful APIs.

* AsyncAPI: For event-driven APIs.

  • Documentation Generators & Frameworks:

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

* Postman/Insomnia: For API testing and generating documentation from collections.

* Stoplight, ReadMe.io, Apigee: Comprehensive API lifecycle management platforms with strong documentation features.

* Static Site Generators: Docusaurus, Next.js (with MDX), Jekyll, Hugo for custom documentation portals.

* MkDocs, Sphinx: Python-based documentation generators.

  • Version Control Systems:

* Git: Distributed version control.

* GitHub, GitLab, Bitbucket: Platforms for collaborative code and documentation management.

  • Text Editors/IDEs:

* Visual Studio Code (VS Code): Popular for its extensions and markdown support.

* Sublime Text, Atom.

  • Collaboration & Project Management Tools:

* Jira, Confluence, Asana, Trello: For tracking tasks and collaborating.

* Slack, Microsoft Teams: For real-time communication.

  • Diagramming Tools:

* Mermaid, PlantUML: For generating diagrams from text.

* draw.io, Lucidchart: For visual diagrams.

5. Best Practices for API Documentation

High-quality API documentation adheres to several key best practices:

  • Clarity and Conciseness: Use plain language, avoid jargon, and get straight to the point.
  • Accuracy and Completeness: Ensure all information is correct, up-to-date, and covers all relevant aspects of the API.
  • Consistency: Maintain a consistent style, tone, terminology, and formatting across all documentation.
  • Abundant Examples and Tutorials: Provide practical, runnable code snippets in multiple languages for common use cases.
  • User-Centric Navigation and Search: Design an intuitive information architecture with effective search capabilities.
  • Interactive Elements: Include "Try-it-out" features, live sandboxes, or interactive consoles where possible.
  • Versioned Documentation: Clearly indicate which API version the documentation pertains to.
  • Error Handling: Provide clear explanations for all possible error codes and how to resolve them.
  • Feedback Mechanism: Offer a way for users to provide feedback, report issues, or ask questions.
  • "Docs as Code" Workflow: Treat documentation like source code, using version control, peer reviews, and automated publishing.

6. Importance of High-Quality API Documentation

The API Documentation Writer role is critical because excellent documentation:

  • Accelerates Developer Adoption: Makes it easier and faster for new users to understand and integrate the API.
  • Improves Developer Experience (DX): A well-documented API is a joy to work with, fostering loyalty and engagement.
  • Reduces Support Burden: Self-service documentation empowers users to find answers independently, reducing the load on support teams.
  • Ensures Correct Usage: Minimizes misinterpretations and errors, leading to more successful implementations.
  • Fosters Innovation: Enables third-party developers to creatively build on your platform, expanding its ecosystem.
  • Enhances Brand Reputation: Professional and user-friendly documentation reflects positively on the company and its products.
  • Facilitates Internal Collaboration: Serves as a reliable source of truth for internal teams, improving consistency.

7. Challenges and Considerations

API Documentation Writers often face specific challenges:

  • Keeping Up with Rapid API Changes: APIs evolve quickly, requiring constant updates to documentation.
  • Balancing Detail with Simplicity: Providing enough information without overwhelming the user.
  • Technical Debt in Documentation: Outdated, inconsistent, or missing information can accumulate over time.
  • Tooling Complexity: Selecting and managing the right set of tools can be a significant undertaking.
  • Getting Developer Buy-In: Ensuring engineers contribute to and prioritize documentation efforts.
  • Measuring Effectiveness: Quantifying the impact of documentation on DX and adoption can be challenging.

8. Actionable Advice for API Documentation

To excel in API documentation, consider the following:

  • Prioritize Developer Experience (DX): Always put the user first. What do they need to succeed?
  • Embrace "Docs as Code": Integrate documentation into your CI/CD pipeline, treating it with the same rigor as source code.
  • Adopt an API Specification Standard: OpenAPI is highly recommended for defining and generating interactive documentation automatically.
  • Invest in the Right Tooling: Choose tools that streamline the writing, publishing, and maintenance processes.
  • Establish a Clear Workflow: Define how documentation is created, reviewed, approved, and published.
  • Gather Continuous Feedback: Implement mechanisms for users to provide input and actively use it for iterative improvements.
  • Provide Diverse Content: Offer a mix of reference, conceptual, and tutorial content to cater to different learning styles and needs.
  • Collaborate Early and Often: Engage with engineers and product managers from the API design phase to ensure accurate and comprehensive documentation.

json

{

"id": "evt_abc789",

"type": "product

gemini Output

This document represents the comprehensive and professionally formatted API documentation, a direct deliverable from the "API Documentation Writer" workflow. It is designed to be clear, concise, and actionable, enabling developers to quickly understand and integrate with the API.


Product Catalog API Documentation

Introduction

Welcome to the Product Catalog API Documentation! This API provides a robust and flexible interface for managing product information, categories, and inventory within your application. Whether you're building an e-commerce platform, an inventory management system, or integrating with third-party services, this API offers the tools you need to interact with your product data programmatically.

Our goal is to provide a seamless developer experience, offering well-defined endpoints, clear data models, and comprehensive examples to get you up and running quickly.

Getting Started

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

1. Obtain Your API Key

All requests to the Product Catalog API must be authenticated using an API Key. You can generate and manage your API keys from your developer dashboard.

  • API Key Location: [Your Developer Dashboard Link]
  • API Key Format: A long, alphanumeric string (e.g., pk_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx).

2. Understand the Base URL

All API requests are made to a common base URL, followed by the specific endpoint path.

  • Base URL: https://api.example.com/v1

3. Make Your First Request

Let's try retrieving a list of products.

Example Request (using curl):


curl -X GET \
  'https://api.example.com/v1/products' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'Content-Type: application/json'

Example Successful Response:


{
  "data": [
    {
      "id": "prod_abc123",
      "name": "Wireless Bluetooth Headphones",
      "description": "High-fidelity audio with noise cancellation.",
      "price": 99.99,
      "currency": "USD",
      "category_id": "cat_audio",
      "stock": 150,
      "created_at": "2023-10-26T10:00:00Z",
      "updated_at": "2023-10-26T10:00:00Z"
    },
    {
      "id": "prod_def456",
      "name": "Smartwatch Series 7",
      "description": "Track your fitness and stay connected.",
      "price": 299.00,
      "currency": "USD",
      "category_id": "cat_wearables",
      "stock": 75,
      "created_at": "2023-10-25T14:30:00Z",
      "updated_at": "2023-10-25T14:30:00Z"
    }
  ],
  "meta": {
    "total": 2,
    "limit": 10,
    "offset": 0
  }
}

Authentication

The Product Catalog API uses Bearer Token Authentication via API Keys.

To authenticate your requests, include your API Key in the Authorization header of your HTTP request, prefixed with Bearer .

Header Example:


Authorization: Bearer YOUR_API_KEY

Failure to provide a valid API Key will result in a 401 Unauthorized error.

Error Handling

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

| HTTP Status Code | Meaning | Description |

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

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

| 201 Created | Resource Created | The request resulted in a new resource being created. |

| 204 No Content | Success, No Content | The request was successful, but there is no content to return (e.g., successful deletion). |

| 400 Bad Request| Invalid Request | The request was malformed or contained invalid parameters. |

| 401 Unauthorized| Authentication Required | No valid API key provided. |

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

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

| 429 Too Many Requests| Rate Limit Exceeded | You have sent too many requests in a given amount of time. |

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

Example Error Response:


{
  "error": {
    "code": "invalid_parameter",
    "message": "The 'price' field must be a positive number.",
    "field": "price",
    "details": "Value provided: -10.50"
  }
}

Rate Limiting

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

  • Limit: 100 requests per minute per API Key.
  • Headers:

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

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

* X-RateLimit-Reset: The UTC epoch timestamp when the current rate limit period will reset.

If you exceed the rate limit, you will receive a 429 Too Many Requests HTTP status code.

API Endpoints

This section details the available endpoints, their methods, parameters, and expected responses.

1. List Products

Retrieves a paginated list of all products.

  • Endpoint: /products
  • Method: GET

Request Parameters:

| Parameter | Type | Location | Description | Required | Default |

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

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

| offset | Integer| Query | The number of products to skip before starting. | Optional | 0 |

| category_id| String| Query | Filter products by a specific category ID. | Optional | N/A |

| search | String | Query | Full-text search across product names and descriptions.| Optional | N/A |

Example Request:


curl -X GET \
  'https://api.example.com/v1/products?limit=5&category_id=cat_audio' \
  -H 'Authorization: Bearer YOUR_API_KEY'

Successful Response (Status: 200 OK):


{
  "data": [
    {
      "id": "prod_abc123",
      "name": "Wireless Bluetooth Headphones",
      "description": "High-fidelity audio with noise cancellation.",
      "price": 99.99,
      "currency": "USD",
      "category_id": "cat_audio",
      "stock": 150,
      "created_at": "2023-10-26T10:00:00Z",
      "updated_at": "2023-10-26T10:00:00Z"
    },
    {
      "id": "prod_xyz789",
      "name": "Studio Monitor Speakers",
      "description": "Professional-grade studio monitors for crystal clear sound.",
      "price": 499.00,
      "currency": "USD",
      "category_id": "cat_audio",
      "stock": 30,
      "created_at": "2023-10-20T11:00:00Z",
      "updated_at": "2023-10-20T11:00:00Z"
    }
  ],
  "meta": {
    "total": 2,
    "limit": 5,
    "offset": 0
  }
}

2. Retrieve a Product

Retrieves details for a single product by its ID.

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

Request Parameters:

| Parameter | Type | Location | Description | Required |

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

| id | String | Path | The unique identifier of the product to retrieve. | Yes |

Example Request:


curl -X GET \
  'https://api.example.com/v1/products/prod_abc123' \
  -H 'Authorization: Bearer YOUR_API_KEY'

Successful Response (Status: 200 OK):


{
  "id": "prod_abc123",
  "name": "Wireless Bluetooth Headphones",
  "description": "High-fidelity audio with noise cancellation.",
  "price": 99.99,
  "currency": "USD",
  "category_id": "cat_audio",
  "stock": 150,
  "created_at": "2023-10-26T10:00:00Z",
  "updated_at": "2023-10-26T10:00:00Z"
}

Error Response (Product Not Found - Status: 404 Not Found):


{
  "error": {
    "code": "not_found",
    "message": "Product with ID 'prod_nonexistent' not found."
  }
}

3. Create a Product

Creates a new product in the catalog.

  • Endpoint: /products
  • Method: POST

Request Body Parameters:

| Parameter | Type | Description | Required |

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

| name | String | The name of the product. Max 255 characters. | Yes |

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

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

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

| category_id | String | The ID of the category the product belongs to. | Yes |

| stock | Integer | The current stock level of the product. Must be non-negative. | Yes |

| image_url | String | URL to the product's primary image. | Optional |

| metadata | Object | A set of key-value pairs that you can attach to a product. | Optional |

Example Request:


curl -X POST \
  'https://api.example.com/v1/products' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
        "name": "Ergonomic Office Chair",
        "description": "Premium office chair with adjustable lumbar support.",
        "price": 349.99,
        "currency": "USD",
        "category_id": "cat_furniture",
        "stock": 50,
        "image_url": "https://example.com/images/chair.jpg",
        "metadata": {
          "color": "black",
          "material": "mesh"
        }
      }'

Successful Response (Status: 201 Created):


{
  "id": "prod_new789",
  "name": "Ergonomic Office Chair",
  "description": "Premium office chair with adjustable lumbar support.",
  "price": 349.99,
  "currency": "USD",
  "category_id": "cat_furniture",
  "stock": 50,
  "image_url": "https://example.com/images/chair.jpg",
  "metadata": {
    "color": "black",
    "material": "mesh"
  },
  "created_at": "2023-10-27T15:30: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);}});}