---
title: "💭 Form Data - FastAPI"
description: "!https://fastapi.tiangolo.com/tutorial/request-forms/#define-form-parameters"
date: 2023-07-28
published: true
tags:
  - fatapi
  - webdev
  - thought
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-image">
      <img src="https://fastapi.tiangolo.com/assets/images/social/tutorial/request-forms.png" alt="Form Data - FastAPI — FastAPI framework, high performance, easy to learn, fast to code, ready for production" loading="lazy">
    </div>
    <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}
```

!!! note

    This post is a <a href="/thoughts/" class="wikilink" data-title="Thoughts" data-description="These are generally my thoughts on a web page or some sort of url, except a rare few don&#39;t have a link. These are dual published off of my..." data-date="2024-04-01">thought</a>. It's a short note that I make
    about someone else's content online <a href="/tags/thoughts/" class="hashtag-tag" data-tag="thoughts" data-count=2 data-reading-time=3 data-reading-time-text="3 minutes">#thoughts</a>
