# Convert cURL to FastAPI

Paste any curl command and get Python code you can drop into a FastAPI project. Async endpoints with httpx AsyncClient. Runs entirely client-side.

## Example

```bash
curl -X POST https://api.example.com/users \
  -H "Content-Type: application/json" \
  -d '{"name":"Ada","email":"ada@example.com"}'
```

## What the converter handles

- Generated code uses the requests primitive that fits FastAPI's idioms — you can drop it into a controller, action, or service.
- Errors and timeouts propagate naturally so you can wrap the call in FastAPI's middleware and observability layer.
- Environment variables replace inline secrets when you run the output through the Clean panel first.

## Common mistakes

- Blocking a request-scoped FastAPI handler on a slow upstream — always set a timeout in the generated call.
- Recreating an HTTP client per request instead of reusing a module-level one — kills keep-alive performance.
- Leaking request-scoped headers (auth, tracing) to upstream calls — the generator only forwards what you paste.

## FAQ

### Which Python library does the FastAPI output use?

requests, because it's the idiomatic choice inside FastAPI. Switch libraries in the language dropdown any time.

### Can I use this in a serverless function?

Yes. The generated code is a plain Python function; deploy it on FastAPI's serverless target of choice.

### Is any data sent to Toolpaper's servers?

No. Parsing and code generation run entirely in your browser.

---

Source: https://toolpaper.manavdev.site/how-to/curl-in-fastapi · Language hub: https://toolpaper.manavdev.site/curl-to-python