> ## Documentation Index
> Fetch the complete documentation index at: https://crsdk.app/llms.txt
> Use this file to discover all available pages before exploring further.

# Subscribe to all camera events (SSE)

> **SDK generation note:** marked `x-fern-ignore: true` because
Server-Sent Events don't map cleanly onto synchronous SDK methods.
The TypeScript and Swift SDKs ship hand-written SSE clients that
consume this endpoint and expose typed `EventStream` APIs.

***

Server-Sent Events stream for all connected cameras. The server sends a
keepalive comment (`: keepalive`) every 30 seconds and immediately fires
an initial `connected` event with the subscription's camera ID payload
(see the quirk note below).

## Event Types

| Event | SDK Callback | Payload | Description |
|-------|-------------|---------|-------------|
| `connected` | `OnConnected` (or initial handshake) | `{cameraId, ...}` | Camera connection established **OR** initial SSE handshake (see quirk) |
| `disconnected` | `OnDisconnected` | `{cameraId, reason?}` | Camera disconnected (real or synthetic — server emits one before clearing callbacks during a clean disconnect) |
| `propertyChanged` | `OnPropertyChangedCodes` | `{cameraId, codes: [...]}` | One or more property values changed on the camera |
| `afStatus` | `OnWarning` (`CrWarningExt_AFStatus`) | `{state: "focused" \| "unlocked" \| "tracking", source?}` | Autofocus state changed |
| `downloadComplete` | `OnCompleteDownload` | `{cameraId, filename, savedPath}` | Auto-transferred image saved to host (remote mode + matching `still-image-store-destination`) |
| `transferProgress` | `OnNotifyRemoteTransferResult` (or filesystem polling fallback) | `{cameraId, contentId, fileId, percent, savedPath?}` | Explicit file-pull progress (remote-transfer mode). On macOS V2.01 the SDK callback is unreliable; the server falls back to filesystem polling and emits synthetic events |
| `contentsTransfer` | `OnContentsTransfer` | `{cameraId, files: [...]}` | Contents-transfer mode file list update (printable-ASCII filenames only) |
| `operationResult` | `OnCompleteOperation` | `{cameraId, operation, result}` | Generic SDK operation completed (e.g. control codes, non-shutter commands) |
| `error` | `OnError` | `{cameraId, code, message}` | SDK error occurred |

## ⚠ The dual `connected` event quirk

Two distinct conditions emit an event named `connected`:

1. **Initial SSE handshake** — fired immediately when the EventSource
   connects, with payload `{"cameraId":"<subscription-id-or-*>"}`. Use
   it to confirm the SSE channel is open. NOT a camera state change.
2. **Real camera connect** — fired when the SDK's `OnConnected`
   callback fires for a camera, with the full camera info payload.

Discriminate by payload shape if you need to distinguish them. The
cleanest pattern is to ignore the first `connected` event after
opening the EventSource and treat any subsequent `connected` as a
real camera-state change.

## Example

```javascript
const events = new EventSource("http://localhost:8080/api/events");
events.addEventListener("downloadComplete", (e) => {
  console.log("File saved:", JSON.parse(e.data).savedPath);
});
events.addEventListener("propertyChanged", (e) => {
  const { codes } = JSON.parse(e.data);
  // Refresh affected properties via getProperty / getAllProperties
});
```




## OpenAPI

````yaml /openapi.yaml get /api/events
openapi: 3.1.0
info:
  title: Alpha Camera REST API
  version: 3.0.0
  description: >
    RESTful control for Sony cameras — shooting, settings, live view with OSD
    overlay,

    focus control, and file transfer through a clean HTTP interface.


    Built on the Sony Camera Remote SDK. Supports USB and network camera
    connections

    with multi-camera simultaneous operation.


    ## Connection Modes


    | Mode | Description |

    |------|-------------|

    | `remote` | Full camera control: shooting, settings, live view.
    Auto-transfer images to host PC. |

    | `remote-transfer` | Camera control + explicit SD card file access. Most
    capable mode. |

    | `contents` | SD card file access only. No shooting or settings control. |


    ## Quick Start


    1. `GET /api/cameras` — discover cameras

    2. `POST /api/cameras/{id}/connection` — connect

    3. `PUT /api/cameras/{id}/priority-key` — set to `pc-remote`

    4. `PUT /api/cameras/{id}/properties/{name}` — configure settings

    5. `POST /api/cameras/{id}/actions/af-shutter` — shoot

    6. `DELETE /api/cameras/{id}/connection` — disconnect


    ## Priority Key Requirement


    The camera's priority key **must** be set to `pc-remote` before it accepts
    any

    remote property changes or shooting commands.
  license:
    name: Proprietary
  contact:
    name: Camera Remote SDK
    url: https://github.com/ocjlee888/camera-remote-sdk-project
servers:
  - url: http://{host}:{port}
    description: |
      Local camera server. The server binary runs on the host that has the
      camera physically connected (USB or network). Defaults to
      `http://localhost:8080`; override `host` and `port` when the server
      runs on a different machine (e.g. a Raspberry Pi next to the camera).
    variables:
      host:
        default: localhost
        description: Host running the camera server binary
      port:
        default: '8080'
        description: Port the camera server is listening on
security: []
tags:
  - name: Connection
    description: Camera discovery, connection, and disconnection
  - name: Properties
    description: Read and write camera properties (ISO, aperture, shutter speed, etc.)
  - name: Actions
    description: Shooting commands and motor control (shutter, zoom, focus)
  - name: Live View
    description: Live view streaming and OSD overlay control
  - name: Events
    description: Server-Sent Events for real-time camera callbacks
  - name: SD Card
    description: SD card file browsing and download
  - name: Settings
    description: Save path configuration and camera settings file management
  - name: Server
    description: Server health, status, and log retrieval
paths:
  /api/events:
    get:
      tags:
        - Events
      summary: Subscribe to all camera events (SSE)
      description: >
        **SDK generation note:** marked `x-fern-ignore: true` because

        Server-Sent Events don't map cleanly onto synchronous SDK methods.

        The TypeScript and Swift SDKs ship hand-written SSE clients that

        consume this endpoint and expose typed `EventStream` APIs.


        ***


        Server-Sent Events stream for all connected cameras. The server sends a

        keepalive comment (`: keepalive`) every 30 seconds and immediately fires

        an initial `connected` event with the subscription's camera ID payload

        (see the quirk note below).


        ## Event Types


        | Event | SDK Callback | Payload | Description |

        |-------|-------------|---------|-------------|

        | `connected` | `OnConnected` (or initial handshake) | `{cameraId, ...}`
        | Camera connection established **OR** initial SSE handshake (see quirk)
        |

        | `disconnected` | `OnDisconnected` | `{cameraId, reason?}` | Camera
        disconnected (real or synthetic — server emits one before clearing
        callbacks during a clean disconnect) |

        | `propertyChanged` | `OnPropertyChangedCodes` | `{cameraId, codes:
        [...]}` | One or more property values changed on the camera |

        | `afStatus` | `OnWarning` (`CrWarningExt_AFStatus`) | `{state:
        "focused" \| "unlocked" \| "tracking", source?}` | Autofocus state
        changed |

        | `downloadComplete` | `OnCompleteDownload` | `{cameraId, filename,
        savedPath}` | Auto-transferred image saved to host (remote mode +
        matching `still-image-store-destination`) |

        | `transferProgress` | `OnNotifyRemoteTransferResult` (or filesystem
        polling fallback) | `{cameraId, contentId, fileId, percent, savedPath?}`
        | Explicit file-pull progress (remote-transfer mode). On macOS V2.01 the
        SDK callback is unreliable; the server falls back to filesystem polling
        and emits synthetic events |

        | `contentsTransfer` | `OnContentsTransfer` | `{cameraId, files: [...]}`
        | Contents-transfer mode file list update (printable-ASCII filenames
        only) |

        | `operationResult` | `OnCompleteOperation` | `{cameraId, operation,
        result}` | Generic SDK operation completed (e.g. control codes,
        non-shutter commands) |

        | `error` | `OnError` | `{cameraId, code, message}` | SDK error occurred
        |


        ## ⚠ The dual `connected` event quirk


        Two distinct conditions emit an event named `connected`:


        1. **Initial SSE handshake** — fired immediately when the EventSource
           connects, with payload `{"cameraId":"<subscription-id-or-*>"}`. Use
           it to confirm the SSE channel is open. NOT a camera state change.
        2. **Real camera connect** — fired when the SDK's `OnConnected`
           callback fires for a camera, with the full camera info payload.

        Discriminate by payload shape if you need to distinguish them. The

        cleanest pattern is to ignore the first `connected` event after

        opening the EventSource and treat any subsequent `connected` as a

        real camera-state change.


        ## Example


        ```javascript

        const events = new EventSource("http://localhost:8080/api/events");

        events.addEventListener("downloadComplete", (e) => {
          console.log("File saved:", JSON.parse(e.data).savedPath);
        });

        events.addEventListener("propertyChanged", (e) => {
          const { codes } = JSON.parse(e.data);
          // Refresh affected properties via getProperty / getAllProperties
        });

        ```
      operationId: subscribeAllEvents
      responses:
        '200':
          description: SSE event stream
          content:
            text/event-stream:
              schema:
                type: string
                description: |
                  Server-Sent Events stream. Each event uses the standard SSE
                  framing: `event: <name>\\ndata: <json>\\n\\n`. See the
                  description for the full event catalog and payload shapes.

````