Repository navigation
Add an API cookbook with curl recipes #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| # API cookbook | ||
|
|
||
| Copy-paste recipes for working with the ToDoRabbit API from a terminal. All examples assume the backend is running on `http://localhost:8000`. See the [API reference](api-reference.md) for every endpoint and field. | ||
|
|
||
| ## Check that the API is up | ||
|
|
||
| ```bash | ||
| curl http://localhost:8000/health | ||
| ``` | ||
|
|
||
| You should see `{"status":"healthy"}`. | ||
|
|
||
| ## Create a todo | ||
|
|
||
| ```bash | ||
| curl -X POST http://localhost:8000/api/todos \ | ||
| -H "Content-Type: application/json" \ | ||
| -d '{"title": "Book flights", "description": "Check the dates with the team first"}' | ||
| ``` | ||
|
|
||
| The response contains the new todo, including the `id` you need for the later recipes. | ||
|
|
||
| ## List open todos | ||
|
|
||
| ```bash | ||
| curl "http://localhost:8000/api/todos?completed=false" | ||
| ``` | ||
|
|
||
| ## Mark a todo as done | ||
|
|
||
| Replace `1` with the `id` of the todo you want to update. | ||
|
|
||
| ```bash | ||
| curl -X PUT http://localhost:8000/api/todo/1 \ | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win Use the implemented update route.
🤖 Prompt for AI Agents |
||
| -H "Content-Type: application/json" \ | ||
| -d '{"completed": true}' | ||
| ``` | ||
|
|
||
| ## Archive a todo | ||
|
|
||
| ```bash | ||
| curl -X POST http://localhost:8000/api/todos/1/archive | ||
| ``` | ||
|
|
||
| Archived todos are hidden from the default list. | ||
|
|
||
| ## List archived todos too | ||
|
|
||
| ```bash | ||
| curl "http://localhost:8000/api/todos?archived=true" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win Use the archived-list query parameter.
🤖 Prompt for AI Agents |
||
| ``` | ||
|
|
||
| ## Delete a todo | ||
|
|
||
| ```bash | ||
| curl -X DELETE http://localhost:8000/api/todos/1 | ||
| ``` | ||
|
|
||
| A successful delete returns `204 No Content` and an empty body. | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Use the registered health endpoint.
The cookbook calls
GET /health, but the backend registersGET /api/health. Copying the command returns a route-not-found response instead of{"status":"healthy"}.Suggested fix
🤖 Prompt for AI Agents