title: Optional query parameters in FastAPI
body: <p>I don't understand <a href="https://fastapi.tiangolo.com/tutorial/query-params/#optional-parameters" rel="nofollow noreferrer">optional query parameters</a> in FastAPI. How is it different from <a href="https://fastapi.tiangolo.com/tutorial/query-params/#defaults" rel="nofollow noreferrer">default query parameters</a> with a default value of <code>None</code>?</p>
  <p>What is the difference between arg1 and arg2 in the example below where arg2 is made an optional query parameter as described in the above link?</p>
  <pre class="lang-py prettyprint-override"><code>@app.get(&quot;/info/&quot;)
  async def info(arg1: int = None, arg2: int | None = None):
      return {&quot;arg1&quot;: arg1, &quot;arg2&quot;: arg2}
  </code></pre>