# AttributeError: 'FastAPI' object has no attribute 'router'

- **ID:** `python/fastapi-attribute-error-router`
- **Domain:** python
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

Calling app.router incorrectly or using an older API pattern where the router attribute is accessed on a non-app object.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 3.x | active | — | — |

## Workarounds

1. **** (94% success)
   ```
   from fastapi import APIRouter
router = APIRouter()
app.include_router(router)
   ```
2. **** (88% success)
   ```
   for r in app.routes:
    print(r.path)
   ```

## Dead Ends

- **** — Attribute name exists but internal structure differs; downstream calls fail. (85% fail)
- **** — Reintroduces other incompatibilities and is unsupported. (80% fail)
