# Testing an API with TestClient

FastAPI's TestClient hands a request straight to your app, with no server running and no port, so a pytest test can check the status code, a header and the JSON body that come back, for a GET and for a POST with a body.

![Cheat sheet: Testing an API with TestClient](https://fsdtrainingmedia.blob.core.windows.net/public/images/2026/11/c745822674724ea8bf0edc0c098b04d2.webp)

- Category: FastAPI
- Level: Journeyman
- Tags: Content-Type, End-to-End Test, fastapi, rest-api, TestClient, Unit Test (unit-testing)
- Author: Gregor Dzierzon
- Updated: November 23, 2026

Source: https://www.ask-codey.com/cheat-sheets/fastapi-testing-testclient-cheat-sheet
