REST-API-server-in-FreePascal
- Active · last change 4-4-2026
- ★ 1 on GitHub
README
Pascal REST API — Todo App
A minimal REST API written in FreePascal using the Horse web framework.
Features
- Full CRUD for a Todo resource
- JSON request/response
- In-memory storage (easy to swap for a DB)
- Runs on port
9000
Requirements
- Free Pascal Compiler (FPC) 3.2+
- Lazarus IDE (optional, but recommended)
- Horse framework
Install Horse
Using the Online Package Manager in Lazarus:
- Open Lazarus →
Package→Online Package Manager - Search for Horse and install it
Or manually clone it:
git clone https://github.com/HashLoad/horse.gitThen add the Horse source path to your project's compiler options.
Build & Run
With Lazarus:
- Open
pascal-rest-api.lpi - Press
F9to compile and run
With FPC directly:
fpc server.pas
./serverAPI Endpoints
| Method | Endpoint | Description |
|---|---|---|
| GET | /todos | List all todos |
| GET | /todos/:id | Get one todo |
| POST | /todos | Create a todo |
| PUT | /todos/:id | Update a todo |
| DELETE | /todos/:id | Delete a todo |
Example Requests
# List all
curl http://localhost:9000/todos
# Create
curl -X POST http://localhost:9000/todos \
-H "Content-Type: application/json" \
-d '{"title": "Buy milk"}'
# Update
curl -X PUT http://localhost:9000/todos/1 \
-H "Content-Type: application/json" \
-d '{"done": true}'
# Delete
curl -X DELETE http://localhost:9000/todos/1Project Structure
pascal-rest-api/
????????? server.pas # Entry point
????????? models.todo.pas # Todo model + in-memory store
????????? routes.todos.pas # Route handlers
????????? pascal-rest-api.lpi # Lazarus project file
????????? README.mdLicense
MIT

