---
title: "Form Data - FastAPI"
description: "!https://fastapi.tiangolo.com/tutorial/request-forms/#define-form-parameters"
date: 2023-07-28
published: true
tags:
  - dev
  - fatapi
  - thought
  - webdev
template: link
---


<div class="embed-card embed-card-external">
  <a href="https://fastapi.tiangolo.com/tutorial/request-forms/#define-form-parameters" class="embed-card-link" target="_blank" rel="noopener noreferrer">
    <div class="embed-card-content">
      <div class="embed-card-title">Form Data - FastAPI</div>
      <div class="embed-card-description">FastAPI framework, high performance, easy to learn, fast to code, ready for production</div>
      <div class="embed-card-meta">fastapi.tiangolo.com</div>
    </div>
  </a>
</div>


Getting form data inside of fastapi was not intuitive to me at first. Everything I had used in fastapi leaned on pydantic models.  Form data comes in differently and needs collected differently.

``` python
from typing import Annotated

from fastapi import FastAPI, Form

app = FastAPI()


@app.post("/login/")
async def login(username: Annotated[str, Form()], password: Annotated[str, Form()]):
    return {"username": username}
```
