feat: add POST support and compatibility params to /api/search

- Switch @router.get to @router.api_route with methods=[GET, POST]
- Add pageNumber alias for page (takes precedence when provided)
- Add numResults, format, imageProxy, safesearch params (accepted for
  compatibility with external clients)
- Update README.md, agents.md, FEATURES.md with param reference tables
- Add CHANGELOG 1.8.1 entry

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
2026-02-24 10:53:35 +11:00
co-authored by Copilot
parent 417d87e813
commit efc237ae52
4 changed files with 65 additions and 18 deletions
+12 -1
View File
@@ -1,6 +1,17 @@
# Changelog
## 1.8.0
## 1.8.1
### Added
- **POST support on `/api/search`** — the search endpoint now accepts both GET and POST requests, enabling compatibility with clients that send search queries via POST
- **Compatibility query parameters** on `/api/search`:
- `pageNumber` — alias for `page` (takes precedence when both are provided)
- `numResults` — requested result count hint (accepted and ignored; backend controls pagination)
- `format` — response format hint (e.g. `json`)
- `imageProxy` — client image-proxy preference flag (informational)
- `safesearch` — safe search level (`0` off, `1` moderate, `2` strict; accepted for compatibility)
### Added
+4
View File
@@ -21,6 +21,8 @@
## REST API
- Full REST API for search, autocomplete, and engine management
- `/api/search` accepts both **GET and POST** requests with query string parameters
- Compatibility parameters on `/api/search`: `pageNumber` (alias for `page`), `numResults`, `format`, `imageProxy`, `safesearch`
- OpenAPI specification with interactive docs via [Swagger UI](https://swagger.io/tools/swagger-ui/) (`/docs`) and [Redoc](https://github.com/Redocly/redoc) (`/redoc`)
## Engine Management
@@ -80,6 +82,8 @@
## REST API
- Full REST API for search, autocomplete, and engine management
- `/api/search` accepts both **GET and POST** requests with query string parameters
- Compatibility parameters on `/api/search`: `pageNumber` (alias for `page`), `numResults`, `format`, `imageProxy`, `safesearch`
- Every result includes `result_id`, `rank`, `engine`, and `timestamp` for agent integration
- `has_next` and `total_results` fields for cursor-aware pagination
- Standardized error schema (`code`/`message`/`details`/`retry_hint`) on all error responses
+25 -9
View File
@@ -78,15 +78,31 @@ The `/app/data` volume stores the SQLite database (engine settings, excluded dom
## API Endpoints
| Method | Path | Description |
| ------ | --------------------------- | --------------------------- |
| GET | `/api/search?q=&category=` | Search web or images |
| GET | `/api/autocomplete?q=` | Autocomplete suggestions |
| GET | `/api/engines` | List all search engines |
| PUT | `/api/engines/{name}` | Enable/disable an engine |
| GET | `/api/settings` | Get app settings (cache TTL)|
| PUT | `/api/settings` | Update settings |
| DELETE | `/api/cache` | Flush search cache |
| Method | Path | Description |
| ---------- | --------------------------- | --------------------------- |
| GET, POST | `/api/search` | Search web or images |
| GET | `/api/autocomplete?q=` | Autocomplete suggestions |
| GET | `/api/engines` | List all search engines |
| PUT | `/api/engines/{name}` | Enable/disable an engine |
| GET | `/api/settings` | Get app settings (cache TTL)|
| PUT | `/api/settings` | Update settings |
| DELETE | `/api/cache` | Flush search cache |
### Search endpoint parameters
| Parameter | Default | Description |
| ------------ | -------- | ---------------------------------------------------- |
| `q` | required | Search query string |
| `category` | `web` | `web` or `images` |
| `page` | `1` | Page number (150) |
| `pageNumber` | — | Alias for `page` (takes precedence when provided) |
| `numResults` | — | Requested result count hint (informational) |
| `format` | — | Response format hint (e.g. `json`) |
| `imageProxy` | — | Client image-proxy preference flag (informational) |
| `safesearch` | — | Safe search level: `0` off, `1` moderate, `2` strict |
| `engines` | — | Comma-separated engine names to restrict (e.g. `google,bing`) |
| `image_size` | — | `large`, `medium`, or `small` (images only) |
| `sort` | `default`| `default`, `date_asc`, or `date_desc` |
## Features
+24 -8
View File
@@ -106,11 +106,27 @@ docker build -t hey-search . && docker run -p 8000:8000 hey-search
## API Endpoints
| Method | Path | Description |
| ------ | -------------------------- | ------------------------ |
| GET | `/api/search` | Metasearch (web/images) |
| GET | `/api/autocomplete` | Search suggestions |
| GET | `/api/engines` | List engines |
| PUT | `/api/engines/{name}` | Toggle engine on/off |
| GET | `/docs` | Swagger UI |
| GET | `/redoc` | Redoc API docs |
| Method | Path | Description |
| --------- | -------------------------- | ------------------------ |
| GET, POST | `/api/search` | Metasearch (web/images) |
| GET | `/api/autocomplete` | Search suggestions |
| GET | `/api/engines` | List engines |
| PUT | `/api/engines/{name}` | Toggle engine on/off |
| GET | `/docs` | Swagger UI |
| GET | `/redoc` | Redoc API docs |
#### `/api/search` query parameters
| Parameter | Default | Description |
| ------------ | -------- | -------------------------------------------------------------- |
| `q` | required | Search query string |
| `category` | `web` | `web` or `images` |
| `page` | `1` | Page number (150) |
| `pageNumber` | — | Alias for `page` (takes precedence when provided) |
| `numResults` | — | Requested result count hint (informational) |
| `format` | — | Response format hint (e.g. `json`) |
| `imageProxy` | — | Client image-proxy preference flag (informational) |
| `safesearch` | — | Safe search level: `0` off, `1` moderate, `2` strict |
| `engines` | — | Comma-separated engine names (e.g. `google,bing`) |
| `image_size` | — | `large`, `medium`, or `small` (images only) |
| `sort` | `default`| `default`, `date_asc`, or `date_desc` |