u
This commit is contained in:
54
docs/api/routes/serper/images.md
Normal file
54
docs/api/routes/serper/images.md
Normal file
@@ -0,0 +1,54 @@
|
||||
# `POST /serper/images`
|
||||
|
||||
Protected. Requires a valid session cookie (`credentials: 'include'`).
|
||||
|
||||
Search images via Serper.dev and stream WebP thumbnails (SSE)
|
||||
|
||||
Queries Google Image search via `https://google.serper.dev/images` using the
|
||||
company setting `keys.serper` (or server `SERPER_API_KEY`), and streams the
|
||||
results via Server-Sent Events (`text/event-stream`).
|
||||
|
||||
1. First emits an `images` event with the full search result list (including `imageUrl`).
|
||||
2. Then streams `thumb` events with WebP base64 thumbnails (max 200×200) as they are generated.
|
||||
3. Emits `done` when all thumbnails have completed (or `error` on failure).
|
||||
|
||||
|
||||
## Body (JSON)
|
||||
|
||||
```json
|
||||
{
|
||||
"q": "Purize logo",
|
||||
"gl": "de",
|
||||
"hl": "de",
|
||||
"num": 100
|
||||
}
|
||||
```
|
||||
|
||||
## SSE Events
|
||||
|
||||
The response is a `text/event-stream`. Events are emitted in order until the stream closes.
|
||||
|
||||
| Event | Description | Payload |
|
||||
|-------|-------------|---------|
|
||||
| `images` | First event; list of search result images with id, url, width, and height | `{ "images": [ { "id": 0, "url": "…", "width": 1000, "height": 800 } ] }` |
|
||||
| `thumb` | Emitted for each image as its 200×200 max WebP thumbnail is generated | `{ "id": 0, "dataUrl": "data:image/webp;base64,…" }` |
|
||||
| `done` | Emitted after all thumbnails have finished streaming; closes the SSE stream | `{ "total": 100 }` |
|
||||
| `error` | Emitted when an error occurs during Serper request or processing | `{ "error": "…" }` |
|
||||
|
||||
## Response `200`
|
||||
|
||||
`text/event-stream` — emits `images`, `thumb`, `done` (and `error` on failure).
|
||||
|
||||
|
||||
## Errors
|
||||
|
||||
| Status | Description |
|
||||
|--------|-------------|
|
||||
| 400 | Query missing, invalid input, or Serper API key not configured — `{"error":"…"}` |
|
||||
| 401 | Unauthorized — `{"error":"…"}` |
|
||||
| 403 | Not authorized — `{"error":"…"}` |
|
||||
| 404 | Company not found — `{"error":"…"}` |
|
||||
|
||||
---
|
||||
|
||||
_Generated from `@openapi` JSDoc. Do not edit by hand — run `npm run docs:api`._
|
||||
Reference in New Issue
Block a user