There are a few end points to view or download Recordings via the Compass API. First you will need to generate a Compass API token under Settings > API TOKEN. Please see API Authentication above to properly utilize this token in your request.

Screenshot 2023-03-03 at 12.23.42.png

You may send a GET request to the endpoints below to obtain information of recordings residing on the current server for specified Video Name/Year/Month or Video Name/Year/Month/Day.

Once you have found the recording you would like to download send a GET request to the endpoint https://<ip>/api/recordings/<name>/<year>/<month>/<day>/<hour>/<min>/<second>. The hour/min/second can be obtained from the GET requests prior to this step. Upon a successful GET request, you will be presented with a file stream of the recording, at which point you may write that to a file.

const axios = require('axios')
const https = require('https')
const fs = require('fs')
require('dotenv').config()

const axiosSecure = axios.create({
	httpsAgent: new https.Agent({
		rejectUnauthorized: false
	}),
	headers: {'Authorization': `Bearer ${process.env.Compass_TOKEN}`}
})

const writer = fs.createWriteStream('./test.ts')
const fileDownloader = async () => {
	const url = '<https://10.10.20.40/api/recordings/test/2023/03/03/16/31/25>'
	const res = await axiosSecure({
		method: 'get',
		url,
		responseType: 'stream',
	})
	res.data.pipe(writer)
	writer.on('finish', () => console.log('finished'))
	writer.on('error', () => console.log('error'))
}
fileDownloader()