| name | create-api-endpoint |
| description | Create a new FastAPI router and endpoints for the MAS system. Use when adding new API endpoints, creating new routers, or extending the MAS API surface. |
Create a New FastAPI API Endpoint
Pattern
All API routers use FastAPI's APIRouter with prefix and tags, and are registered in myca_main.py.
Steps
API Endpoint Creation Progress:
- [ ] Step 1: Create router file
- [ ] Step 2: Register in myca_main.py
- [ ] Step 3: Update API catalog
- [ ] Step 4: Test endpoints
Step 1: Create the router file
Create mycosoft_mas/core/routers/your_api.py:
"""Your API - Brief description of these endpoints."""
from fastapi import APIRouter, HTTPException, Depends
from pydantic import BaseModel
from typing import Any, Dict, List, Optional
router = APIRouter(prefix="/api/your-domain", tags=["your-domain"])
class YourRequest(BaseModel):
"""Request model."""
field: str
optional_field: Optional[str] = None
class ():
status:
data: [, ]
():
{: , : }
():
:
result = {: request.field}
YourResponse(status=, data=result)
Exception e:
HTTPException(status_code=, detail=(e))
():
{: [], : }