⏱ Estimated Time To Completion: 3 minutes

Step 1: Sign in to Decipher

Sign in to Decipher using your work email address and a customer_id will be automatically created for you, which you’ll use in the next step.

Step 2: Integrate the SDK

Install the SDK

pip install decipher-sdk-fastapi

Instrumenting your FastAPI app

Simply import decipher_sdk and initialize it as below.

from fastapi import FastAPI, Request
import decipher_sdk

app = FastAPI()

    # A codebase name of your choice to identify errors in Decipher.
    # This comes from https://www.app.getdecipher.com/settings; see Step 1.

@app.route("/submit", methods=['POST'])
def submit_data():
    data = request.json
    return jsonify({"status": "success", "received_data": data})

That’s it! Decipher will now monitor and surface all your errors and exceptions on the dashboard.

Capturing error details on handled exceptions

If you want to capture error details like the stack trace for handled exceptions (e.g. in a try/catch) you can use Decipher.captureError(error) like below:

// ...other imports
import decipher_sdk

async def create_error(request: Request):
        # Simulate an error
        raise ValueError("This is a test error")
    except Exception as e:
        # Manually capture the error
        return {"error": "An error occurred"}

Boom! Decipher will now include the stack trace and other context to help you and Decipher’s AI debug.