---
source: https://iinventedlight.com/library/notes/fastapi-apirouter.md
title: "APIRouter splits a FastAPI app across modules and is included with include_router"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "MIT (FastAPI docs); BSD-3-Clause (Starlette docs); prose restates cited source lines in own words"
license_family: mixed-green
attribution: "Summary by iinventedlight (AI-assisted). Sources: fastapi/fastapi (GitHub), Bigger Applications - Multiple Files, MIT (https://raw.githubusercontent.com/fastapi/fastapi/master/LICENSE). Copyright (c) 2018 Sebastián Ramírez; Kludex/starlette (GitHub), HTTP Routing (Starlette), BSD-3-Clause (https://raw.githubusercontent.com/Kludex/starlette/main/LICENSE.md). Copyright (c) 2018, Encode OSS Ltd."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-17
status: published
approved_by: "Cole Withington, 2026-11-20 13:14 PT: \"Publish the full batch and rewrite the 6 live notes\""
checked_on: 2026-11-17
as_of: 2026-11-17
confidence: medium
untested: "Not reproduced (2026-11-17). Official docs and source files were read; no test suite, server, or API call was run for this note."
category: coding-references
topic_area: "code-python: FastAPI APIRouter"
tags: [fastapi, APIRouter, include_router, starlette, routing]
client: Librarian
sources:
  - id: S1
    title: "Bigger Applications - Multiple Files"
    publisher: fastapi/fastapi (GitHub)
    url: https://github.com/fastapi/fastapi/blob/master/docs/en/docs/tutorial/bigger-applications.md
    accessed: 2026-11-17
    license: "MIT"
  - id: S2
    title: "HTTP Routing (Starlette)"
    publisher: Kludex/starlette (GitHub)
    url: https://github.com/Kludex/starlette/blob/main/docs/routing.md
    accessed: 2026-11-17
    license: "BSD-3-Clause"
---
# APIRouter splits a FastAPI app across modules and is included with include_router
**Answer:** Use `APIRouter` to declare path operations in their own modules, then attach those routers to the main `FastAPI` app with `app.include_router()`. Think of `APIRouter` as a mini `FastAPI` class: the same options, such as parameters, responses, dependencies, and tags, are supported.

## Prefixes, tags, and dependencies

You can set a path `prefix`, `tags`, extra `responses`, and `dependencies` on the router so you do not repeat them on every path operation. The prefix must not include a final `/`. You can declare those parameters on `app.include_router()` without having to modify the original `APIRouter`.

## How Starlette splits routes

Starlette has a simple request routing system. A routing table is defined as a list of routes. In large applications you can break out parts of the routing table, based on a common path prefix, using `Mount`.

## See also

- [flask-and-fastapi](https://iinventedlight.com/library/notes/flask-and-fastapi/)
- [fastapi-dependencies](https://iinventedlight.com/library/notes/fastapi-dependencies/)
- [fastapi-lifespan](https://iinventedlight.com/library/notes/fastapi-lifespan/)
- [fastapi-upload-files](https://iinventedlight.com/library/notes/fastapi-upload-files/)

## Claims

- id: C1
  claim: APIRouter is used to declare path operations in a module.
  source: S1
  evidence: "create the *path operations* for that module using `APIRouter`"

- id: C2
  claim: include_router adds an APIRouter to the main FastAPI application.
  source: S1
  evidence: "add each `APIRouter` to the main `FastAPI` application"

- id: C3
  claim: Starlette takes a routing table as a list of routes.
  source: S2
  evidence: "A routing table is defined as a list of routes"

- id: C4
  claim: Starlette can split routes that share a common path prefix.
  source: S2
  evidence: "based on a common path prefix"

## Sources

- [S1] Bigger Applications - Multiple Files. fastapi/fastapi (GitHub). https://github.com/fastapi/fastapi/blob/master/docs/en/docs/tutorial/bigger-applications.md . License: MIT. Accessed 2026-11-17.

- [S2] HTTP Routing (Starlette). Kludex/starlette (GitHub). https://github.com/Kludex/starlette/blob/main/docs/routing.md . License: BSD-3-Clause. Accessed 2026-11-17.

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: fastapi/fastapi (GitHub), Bigger Applications - Multiple Files, MIT (https://raw.githubusercontent.com/fastapi/fastapi/master/LICENSE). Copyright (c) 2018 Sebastián Ramírez; Kludex/starlette (GitHub), HTTP Routing (Starlette), BSD-3-Clause (https://raw.githubusercontent.com/Kludex/starlette/main/LICENSE.md). Copyright (c) 2018, Encode OSS Ltd. Text was condensed and changed from the originals.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
