HTTP GET retrieves data from an API endpoint. A GET route defines where a client can ask for a resource; the route then returns a representation, commonly JSON. For a file service, GET /files can return a list of available files. section 4.3.1
Start with a small endpoint before connecting real storage. In FastAPI, @router.get("/files/") associates the URL with an asynchronous handler. The handler can initially return fixed data, giving the frontend, QA process, and tests a stable contract to exercise. section 4.3.1
Retrieve a file list
A client calls GET /files and expects HTTP 200 plus a JSON array such as [{"file":"File_1"},{"file":"File_2"}]. A TestClient test calls client.get("/files"), then checks both the status code and returned JSON. section 4.3.1
Validate a GET endpoint at more than one level:
- Use an automated test to verify that the URL accepts GET and returns the expected status and payload. section 4.3.1
- Use a behavior scenario to express that calling /files with GET should produce status 200. section 4.3.1
- Use Postman to send GET http://localhost:8000/files, inspect formatted JSON, and add response tests. section 4.7
- Avoid tests that depend on array position when order is not guaranteed; search the returned array for the required item instead. section 4.7
Listing 4.3 Our first API route
@router.get("/files/") #1
async def read_files(): #2
return [{"file": "File_1"}, {"file": "File_2"}] #2
This minimal route connects GET /files to an async handler and returns a temporary JSON file list. section 4.3.1
Listing 4.13 Sample Postman test
pm.test("Response should be JSON and have a 200 status code", function () {
pm.response.to.be.json; #1
pm.response.to.have.status(200); #2
});
This Postman test checks that a GET response is JSON and has HTTP status 200. section 4.7













