跳到主要内容

HTTP API

网络服务器的端口为 5000,端点如下。

GET /api/<camera_name>

用于调试的 mjpeg 流。请注意,mjpeg 端点仅用于调试,使用时会给系统带来额外负担。

接受以下查询字符串参数:

参数类型描述
fpsintFrame rate
hintHeight in pixels
bboxintShow bounding boxes for detected objects (0 or 1)
timestampintPrint the timestamp in the upper left (0 or 1)
zonesintDraw the zones on the image (0 or 1)
maskintOverlay the mask on the image (0 or 1)
motionintDraw blue boxes for areas with detected motion (0 or 1)
regionsintDraw green boxes for areas where object detection was run (0 or 1)

您可以通过在端点添加 h=height-in-pixels 来访问更高分辨率的 mjpeg 流。例如 http://localhost:5000/api/back?h=1080。您还可以通过在 URL 上添加 fps=frame-rate 来提高 FPS,例如 http://localhost:5000/api/back?fps=10 或同时添加 ?fps=10&h=1000

GET /api/<camera_name>/latest.jpg[?h=300]

Frigate 处理完毕的最新帧。默认为全分辨率图像。

接受以下查询字符串参数:

参数类型描述
hintHeight in pixels
bboxintShow bounding boxes for detected objects (0 or 1)
timestampintPrint the timestamp in the upper left (0 or 1)
zonesintDraw the zones on the image (0 or 1)
maskintOverlay the mask on the image (0 or 1)
motionintDraw blue boxes for areas with detected motion (0 or 1)
regionsintDraw green boxes for areas where object detection was run (0 or 1)
qualityintJpeg encoding quality (0-100). Defaults to 70.

参数示例:

  • h=300: 将图像调整为 300 像素高

GET /api/stats

包含一些细粒度调试信息,可用于Home Assistant中的传感器。

响应样本:

{
/* Per Camera Stats */
"back": {
/***************
* Frames per second being consumed from your camera. If this is higher
* than it is supposed to be, you should set -r FPS in your input_args.
* camera_fps = process_fps + skipped_fps
***************/
"camera_fps": 5.0,
/***************
* Number of times detection is run per second. This can be higher than
* your camera FPS because Frigate often looks at the same frame multiple times
* or in multiple locations
***************/
"detection_fps": 1.5,
/***************
* PID for the ffmpeg process that consumes this camera
***************/
"capture_pid": 27,
/***************
* PID for the process that runs detection for this camera
***************/
"pid": 34,
/***************
* Frames per second being processed by Frigate.
***************/
"process_fps": 5.1,
/***************
* Frames per second skip for processing by Frigate.
***************/
"skipped_fps": 0.0
},
/***************
* Sum of detection_fps across all cameras and detectors.
* This should be the sum of all detection_fps values from cameras.
***************/
"detection_fps": 5.0,
/* Detectors Stats */
"detectors": {
"coral": {
/***************
* Timestamp when object detection started. If this value stays non-zero and constant
* for a long time, that means the detection process is stuck.
***************/
"detection_start": 0.0,
/***************
* Time spent running object detection in milliseconds.
***************/
"inference_speed": 10.48,
/***************
* PID for the shared process that runs object detection on the Coral.
***************/
"pid": 25321
}
},
"service": {
/* Uptime in seconds */
"uptime": 10,
"version": "0.10.1-8883709",
"latest_version": "0.10.1",
/* Storage data in MB for important locations */
"storage": {
"/media/frigate/clips": {
"total": 1000,
"used": 700,
"free": 300,
"mnt_type": "ext4"
},
"/media/frigate/recordings": {
"total": 1000,
"used": 700,
"free": 300,
"mnt_type": "ext4"
},
"/tmp/cache": {
"total": 256,
"used": 100,
"free": 156,
"mnt_type": "tmpfs"
},
"/dev/shm": {
"total": 256,
"used": 100,
"free": 156,
"mnt_type": "tmpfs"
}
}
}
}

GET /api/config

Frigate 配置的 json 表示

GET /api/version

版本信息

GET /api/events

数据库中的事件。接受以下查询字符串参数:

参数类型描述
beforeintEpoch time
afterintEpoch time
camerasstr, separated list of cameras
labelsstr, separated list of labels
zonesstr, separated list of zones
limitintLimit the number of events returned
has_snapshotintFilter to events that have snapshots (0 or 1)
has_clipintFilter to events that have clips (0 or 1)
include_thumbnailsintInclude thumbnails in the response (0 or 1)
in_progressintLimit to events in progress (0 or 1)
time_rangestrTime range in format after,before (00:00,24:00)
timezonestrTimezone to use for time range
min_scorefloatMinimum score of the event
max_scorefloatMaximum score of the event
min_lengthfloatMinimum length of the event
max_lengthfloatMaximum length of the event

GET /api/timeline

数据库中事件关键时刻的时间轴。接受以下查询字符串参数:

参数类型描述
camerastrName of camera
source_idstrID of tracked object
limitintLimit the number of events returned

GET /api/events/summary

返回数据库中事件的摘要数据。由 Home Assistant 集成使用。

GET /api/events/<id>

返回单个事件的数据。

DELETE /api/events/<id>

永久删除事件和所有剪辑/抓拍。

POST /api/events/<id>/retain

事件(id)留存设为 true。

DELETE /api/events/<id>/retain

事件(id)留存设为 false(事件删除后可以很快被删除)。

POST /api/events/<id>/sub_label

为事件(id)设置子标签。例如,如果他们被面部识别系统识别出来,则更新 person -> person's name。 子标签必须为 100 个字符或更短。

{
"subLabel": "some_string",
"subLabelScore": 0.79,
}

GET /api/events/<id>/thumbnail.jpg

返回事件 (id) 的缩略图,该缩略图已针对通知进行了优化。在事件进行中和完成后均有效。如果传递 ?format=android,缩略图将转换为 2:1 宽高比。

GET /api/<camera_name>/<label>/thumbnail.jpg

根据给定的摄像机和标签组合,返回最新事件的缩略图。使用 any 作为标签将返回最新与类型无关的缩略图。

GET /api/events/<id>/clip.mp4

返回事件 (id) 的剪辑。在事件结束后工作。

GET /api/events/<id>/snapshot.jpg

返回事件 (id) 的抓拍图像。在事件进行中和结束后均有效。

接受以下查询字符串参数,但它们只在事件进行时应用。事件结束后,保存的抓拍不会对硬盘文件做任何修改:

参数类型描述
hintHeight in pixels
bboxintShow bounding boxes for detected objects (0 or 1)
timestampintPrint the timestamp in the upper left (0 or 1)
cropintCrop the snapshot to the (0 or 1)
qualityintJpeg encoding quality (0-100). Defaults to 70.

GET /api/<camera_name>/<label>/snapshot.jpg

根据给定的摄像机和标签组合,返回最新事件的抓拍图。使用 any 作为标签将返回最新与类型无关的缩略图。

GET /api/<camera_name>/recordings/<frame_time>/snapshot.png

返回摄像机录像中特定点的抓拍图像。

GET /api/<camera_name>/grid.jpg

返回叠加了区域网格的最新摄像机图像。

参数类型描述
colorstrThe color of the grid (red,green,blue,black,white). Defaults to "green".
font_scalefloatFont scale. Can be used to increase font size on high resolution cameras. Defaults to 0.5.

GET /clips/<camera>-<id>.jpg

给定摄像机和事件 id 的 JPG 抓拍。

GET /vod/<year>-<month>/<day>/<hour>/<camera>/master.m3u8

指定时间和摄像机的 HTTP 实时流媒体视频点播 URL。可在 VLC 等应用程序中观看。

GET /vod/event/<event-id>/index.m3u8

指定事件的 HTTP 实时流媒体视频点播 URL。可在 VLC 等应用程序中观看。

GET /vod/<camera>/start/<start-timestamp>/end/<end-timestamp>/index.m3u8

指定时间范围内摄像机的 HTTP 实时流媒体视频点播 URL。可在 VLC 等应用程序中查看。

POST /api/export/<camera>/start/<start-timestamp>/end/<end-timestamp>

以单个 mp4 文件形式导出从 start-timestampend-timestamp 的摄像机录像。这些录像将导出到 /media/frigate/exports 文件夹。

还可以将此录像导出为缩时录像。

Optional Body:

{
"playback": "realtime", // playback factor: realtime or timelapse_25x
}

DELETE /api/export/<export_name>

从磁盘中删除导出。

PATCH /api/export/<export_name_current>/<export_name_new>

重命名导出。

GET /api/<camera_name>/recordings/summary

Hourly summary of recordings data for a camera.

GET /api/<camera_name>/recordings

摄像机的每小时录像数据摘要。

参数类型描述
afterintUnix timestamp for beginning of range
beforeintUnix timestamp for end of range

GET /api/ffprobe

获取摄像机 feed 路径的 ffprobe 输出。

参数类型描述
pathsstring, separated list of camera paths

GET /api/<camera_name>/ptz/info

获取摄像机的 PTZ 信息。

POST /api/events/<camera_name>/<label>/create

创建带有给定 label (例如:按门铃)的手动事件,以捕捉除检测到目标之外的特定事件。

警告

录像留存配置仍适用于手动事件,如果 Frigate 配置了 mode: motion ,那么手动事件只会保留发生动态时的录像片段。

Optional Body:

{
"sub_label": "some_string", // add sub label to event
"duration": 30, // predetermined length of event (default: 30 seconds) or can be to null for indeterminate length event
"include_recording": true, // whether the event should save recordings along with the snapshot that is taken
"draw": {
// optional annotations that will be drawn on the snapshot
"boxes": [
{
"box": [0.5, 0.5, 0.25, 0.25], // box consists of x, y, width, height which are on a scale between 0 - 1
"color": [255, 0, 0], // color of the box, default is red
"score": 100 // optional score associated with the box
}
]
}
}

Success Response:

{
"event_id": "1682970645.13116-1ug7ns",
"message": "Successfully created event.",
"success": true
}

PUT /api/events/<event_id>/end

结束一个没有预定长度的特定手动事件。

POST /api/restart

重启 Frigate 进程。