API Endpoints#
This page documents all HTTP endpoints exposed by the _Astra_ FastAPI application.
The API provides programmatic access to observatory control, monitoring, and data retrieval functions.
REST API Endpoints#
The following REST API endpoints are available for interacting with the Astra observatory system.
GET /api/allsky/latest#
Serve the latest All-Sky camera image.
Parameters:
name(str, optional) – Name of the specific all-sky camera. If not provided, returns the first camera.
Returns:
FileResponse: The image file with no-store cache headers.
POST /api/close#
Close observatory and stop all operations safely.
Stops running schedule if active and closes the observatory. Logs all actions for audit trail.
Returns:
dict: JSON response with operation status.
POST /api/complete_headers#
Complete FITS header processing for observatory images.
Returns:
dict: JSON response with operation status.
POST /api/cool_camera/{device_name}#
Initiate camera cooling to configured target temperature.
Gets camera configuration and starts cooling process to the specified set temperature with defined tolerance.
Path Parameters:
device_name(str) – Camera device name to cool.
Returns:
dict: JSON response with operation status and cooling details.
GET /api/db/guiding#
Get autoguider log data for plotting guiding performance.
Retrieves guiding corrections (post_pid_x, post_pid_y) from the autoguider_log table for visualization.
Parameters:
day(float) – Number of days back to retrieve data. Defaults to 1.since(str) – Optional timestamp to get only newer records.telescope(str) – Optional telescope name to filter data.
Returns:
- dict: JSON response with guiding data including datetime,
telescope_name, post_pid_x, and post_pid_y values.
GET /api/db/polling/{device_type}#
Get device polling data from observatory database.
Uses an append-only in-memory cache keyed by device_type:
First request performs a full DB query (up to
daydays) and stores the result.Subsequent requests fetch only the rows newer than
last_cached_timestamp - 2 min, reprocess that overlap window to ensure the most-recent 60 s bucket is complete, merge into the cache, and prune rows older than the requesteddaywindow.Concurrent requests share a single
asyncio.Lockso only one DB fetch runs at a time; any waiter re-uses the freshly-updated cache.
Path Parameters:
device_type(str) – Type of device (e.g. ``’ObservingConditions’``).
Parameters:
day(float) – Days of history to include in the response. Defaults to 1.since(str) – Optional ISO-format UTC timestamp; if supplied the response payload is filtered to rows newer than this value (the cache itself always holds the full window).
Returns:
dict: Processed polling data with safety limits and latest values.
POST /api/editschedule#
Update observatory schedule from web editor.
Parses JSONL schedule data and saves to observatory schedule file.
Parameters:
schedule_data(str) – JSONL formatted schedule data.
Returns:
dict: Status response with success/error information.
GET /api/heartbeat#
Get observatory heartbeat status for health monitoring.
Returns:
dict: JSON response with heartbeat status data.
GET /api/latest_image_preview#
Serve the latest FITS image as a JPEG preview.
Returns the most recent observatory image converted to JPEG format, generated in-memory without disk I/O.
Returns:
StreamingResponse: JPEG image data with appropriate headers.
GET /api/log#
Get observatory log entries before specified datetime.
Parameters:
datetime(str) – Upper limit datetime for log entries.limit(int) – Maximum number of log entries to return. Defaults to 100.
Returns:
list: Log entries as dictionary records.
POST /api/roboticswitch#
Toggle observatory robotic operation mode.
Returns:
dict: JSON response with current robotic switch state.
GET /api/schedule#
Get current observatory schedule with formatted times.
Returns:
- list: Schedule items with start/end times formatted as HH:MM:SS,
or empty list if no schedule exists.
GET /api/sky_data#
Get celestial body positions for all-sky projection.
Returns:
dict: JSON response with observatory location, time, and celestial body positions
POST /api/startschedule#
Start executing the observatory’s observation schedule.
Returns:
dict: JSON response with operation status.
POST /api/startwatchdog#
Start observatory watchdog monitoring system.
Resets error states and starts the watchdog process for continuous observatory health monitoring.
Returns:
dict: JSON response with operation status.
POST /api/stopschedule#
Stop executing the observatory’s observation schedule.
Returns:
dict: JSON response with operation status.
POST /api/stopwatchdog#
Stop observatory watchdog monitoring system.
Returns:
dict: JSON response with operation status.
POST /api/uploadschedule#
Upload schedule file to replace current observatory schedule.
Parameters:
file(UploadFile) – Uploaded schedule file in JSONL format.
Returns:
dict: Upload status response with success/error information.
GET /fits_explorer/#
Serve the static index HTML but inject a <base> tag so relative asset URLs (like static/…) resolve correctly when the router is included under a prefix (for example /fits_explorer). This lets the explorer work both standalone and embedded without requiring the host app to mount the same static paths.
GET /fits_explorer/download/{filename:path}#
GET /fits_explorer/hdu_list/{filename:path}#
GET /fits_explorer/header/{filename:path}#
GET /fits_explorer/list/#
GET /fits_explorer/preview/{filename:path}#
GET /schedule#
Serve schedule editor page with current schedule data.
Loads raw JSONL schedule file preserving original datetime format for the web-based schedule editor interface.
Parameters:
request(Request) – FastAPI request object.
Returns:
TemplateResponse: HTML template with schedule editor and data.
WebSocket Endpoints#
WebSocket endpoints provide real-time bidirectional communication.
WebSocket /ws/log#
WebSocket endpoint for real-time log streaming.
Provides initial log history and streams new log entries as they are added to the database. Also includes schedule modification time.
Parameters:
websocket(WebSocket) – WebSocket connection object.
WebSocket /ws#
Main WebSocket endpoint for real-time observatory status updates.
Streams comprehensive observatory status including device polling data, system health, operational status, and latest images. Handles FITS to JPEG conversion for image display.
Parameters:
websocket(WebSocket) – WebSocket connection object.