---
title: "FastAPI and Starlette Sentry Integrations Have Arrived"
url: "https://blog.sentry.io/fastapi-and-starlette-sentry-integrations-have-arrived/"
canonical_url: "https://blog.sentry.io/fastapi-and-starlette-sentry-integrations-have-arrived/"
authors: ["Sarah Guthals"]
published: "2022-09-01"
category: "Product Updates"
---

# FastAPI and Starlette Sentry Integrations Have Arrived

[FastAPI](https://fastapi.tiangolo.com/) is known for building REST APIs, middleware services, and simple integration for adding authentications and more. And it’s known for doing all of that…you guessed it, fast. It’s used by [tech giants and scientists alike](https://twitter.com/tiangolo/status/1546983811421962240), and according to [Stack Overflow’s Developer Survey 2022](https://survey.stackoverflow.co/2022/#most-popular-technologies-webframe) more developers are using FastAPI than Ruby on Rails. With less than 4 years of being published, it’s impressive that it’s even creeping up on the traditional Python heavyweights Django and Flask.

![FastAPI on StackOverflow 2022](https://blog.sentry.io/_vercel/image?url=_astro%2Finline-0.DGalWEZH.png&w=828&q=100)

So if you’re one of those developers, or maybe even one of the 240 (and counting) developers on this specific [Python SDK GitHub issue](https://github.com/getsentry/sentry-python/issues/829), or just love all things Python, checkout our recently released [FastAPI](https://docs.sentry.io/platforms/python/integrations/fastapi/) and [Starlette](https://docs.sentry.io/platforms/python/integrations/starlette/) integrations.

## FastAPI Support

If you’re already using our Sentry Python SDK, with auto-enabling you shouldn’t have to change anything to begin using FastAPI Sentry support. The Sentry SDK will automatically detect your usage of FastAPI and set up everything for you.

```plaintext
from fastapi import FastAPI

import sentry_sdk

sentry_sdk.init(
    dsn="https://examplePublicKey@o0.ingest.sentry.io/0",

    # Set traces_sample_rate to 1.0 to capture 100%
    # of transactions for performance monitoring.
    # We recommend adjusting this value in production,
    traces_sample_rate=1.0,
)

app = FastAPI()
```

## Starlette Support

FastAPI at its base is built around [Starlette](https://www.starlette.io/), another Python web framework with over 7.2k stars on GitHub. So along with our new FastAPI support, we released support for Starlette.

The support for Starlette is, again, the same as for FastAPI and all of our other support within our Python SDKs. With just a couple lines of code you can be up and running:

```plaintext
from starlette.applications import Starlette

import sentry_sdk

sentry_sdk.init(
    dsn="https://examplePublicKey@o1.ingest.sentry.io/1",

    # Set traces_sample_rate to 1.0 to capture 100%
    # of transactions for performance monitoring.
    # We recommend adjusting this value in production,
    traces_sample_rate=1.0,
)

app = Starlette(routes=[...])
```

## Leveraging Sentry

Support for FastAPI and Starlette opens the ability to use Sentry to improve your application monitoring. For example, you can use Sentry Performance with trace view to connect your FastAPI middleware to frontend, backend, and other middleware, microservices, etc. as was [discussed on the Starlette repo](https://github.com/encode/starlette/discussions/1787#discussioncomment-3311717).

You might also want to check out Sentry’s transaction focus/routes within Performance, because you’re working on building performant APIs or developing machine learning models, these “out of the box” Sentry features will reduce the complexity of your ecosystem and get more out of your application monitoring.

## Building with @tiangolo (aka Sebastián) and Tom

What makes this release unique is that we collaborated with the FastAPI and Starlette creators; [Sebastián Ramírez](https://twitter.com/tiangolo) and [Tom Christie](https://twitter.com/starletdreaming), respectively. Sebastián and Tom are both major open source contributors, even beyond FastAPI and Starlette, and it was great getting the chance to work with them.

Being able to get reviews from the creators of the frameworks that you’re building an integration for is a special [experience](https://github.com/getsentry/sentry-python/pull/1441). Thank you, Sebastián.

![FastAPI comment with tiangolo](https://blog.sentry.io/_vercel/image?url=_astro%2Finline-1.BPa3OnAz.png&w=1080&q=100)

![Tiangolo tweet](https://blog.sentry.io/_vercel/image?url=_astro%2Finline-2.Cr42O2Kk.png&w=640&q=100)

> I’ve been using Sentry to help me with debugging for years. As a big fan of Sentry, I was thrilled to learn about their planned support for FastAPI. With major FastAPI features being available out-of-the-box through the Sentry integration, I’m excited to see how FastAPI developers will use the Sentry integration to debug and make their apps even faster.

— Sebastián Ramírez

Have questions about the new release? Share your feedback on [GitHub](https://github.com/getsentry/sentry-python/blob/master/sentry_sdk/integrations/fastapi.py), join us on [Twitter](https://twitter.com/getsentry) or in the Python channel in our [Discord](https://discord.gg/s9dWyMEBuU). And if you’re new to Sentry, you can try it for [free today](https://sentry.io/orgredirect/try-business/) or request [a demo](https://sentry.io/demo/) to get started.
