Docs / Guides / Full CRUD REST API

Feature 04 · Study guide

Full CRUD REST API

See the exact endpoints tamilPY generates and how to call them from Swagger or HTTP clients.

What you will learn
  • Default REST routes for each model
  • How to try them in /docs
  • Where to customize responses

1. Setup

$ tpy build && tpy migrate
$ tpy serve
# open http://127.0.0.1:8000/docs

2. How routes are named

Model User becomes plural prefix /users:

MethodPathMeaning
GET/users/List records
GET/users/{id}Fetch one
POST/users/Create
PUT/users/{id}Update
DELETE/users/{id}Delete

3. Request flow

  1. HTTP hits the generated FastAPI route.
  2. Controller validates/parses the body (Pydantic schema).
  3. Service runs the use-case.
  4. Repository talks to the database.
  5. JSON returns to the client.

4. Example create

POST /users/
Content-Type: application/json

{
  "name": "Asha",
  "email": "asha@example.com"
}

Prefer wrapping controller returns with ApiResponse when you customize handlers so every client sees the same envelope.

5. Common mistakes

  • Calling /user instead of /users (pluralization).
  • Forgetting required fields from the schema (required / non-nullable).