API endpoints return data instead of rendering a page. Create a +server.js file and export a handler for each HTTP method you want to support.
In this example, we'll read and update a public demonstration todo list.
Provide your own database module in src/lib/server/db.js. Its async getTodos() returns an array of { id, task, completed } objects with string IDs. createTodo(task) saves and returns a new todo with completed: false. deleteTodo(id) returns whether a todo was deleted, and getTodo(id) returns a todo or null. These are application helpers, not SvelteKit APIs.
These request-time database reads and writes need a server adapter and runtime, not static hosting. This documentation only displays the code. For real private todos, authenticate every request and check ownership before reading or changing data.