# Path parameters vs query parameters

> How does FastAPI tell path parameters apart from query parameters, and how do you declare required and optional ones?

Canonical: https://www.internhack.in/learn/interview/fastapi-interview/fastapi-path-query-params
Last updated: 2026-11-28

Difficulty: Beginner

## Question

How does FastAPI tell path parameters apart from query parameters, and how do you declare required and optional ones?

*The full answer is for InternHack members. Open the page link above to read it.*

## Concepts covered

path parameters, query parameters, type coercion, optional parameters, Annotated

Previous: [Path operations and HTTP methods](https://www.internhack.in/learn/interview/fastapi-interview/fastapi-path-operations) · Next: [Pydantic models and request body](https://www.internhack.in/learn/interview/fastapi-interview/fastapi-pydantic-models) · [All of FastAPI Interview](https://www.internhack.in/learn/interview/fastapi-interview)

## More FastAPI Interview questions

- [Response models and response filtering](https://www.internhack.in/learn/interview/fastapi-interview/fastapi-response-model)
- [Dependency Injection in FastAPI](https://www.internhack.in/learn/interview/fastapi-interview/fastapi-dependency-injection)
- [Async vs sync route handlers](https://www.internhack.in/learn/interview/fastapi-interview/fastapi-async-routes)
- [Authentication and JWT in FastAPI](https://www.internhack.in/learn/interview/fastapi-interview/fastapi-authentication)
- [Error handling and HTTPException](https://www.internhack.in/learn/interview/fastapi-interview/fastapi-error-handling)
- [Middleware in FastAPI](https://www.internhack.in/learn/interview/fastapi-interview/fastapi-middleware)

## Related

- [Learn](https://www.internhack.in/learn)
- [Interview Prep](https://www.internhack.in/learn/interview)
- [FastAPI Interview](https://www.internhack.in/learn/interview/fastapi-interview)
