Archived Files

Introduction

Eagle Eye Networks users can archive part of their recorded videos in the archive storage associated with their account. Archived videos are protected from being overwritten by the system according to the retention time configuration. Using the /files API, you can access a list of archived files, and, if necessary, rename, move, and delete them.

Before you begin

  • Login to your account and receive an access token.
  • Get our Base URL from here

Archiving Video

You can archive any recorded video using the /export API. This creates an export job that processes the video and saves it in the archive for long-term storage or downloading to your local machine.

curl --request POST \
     --url https://api.c030.eagleeyenetworks.com/api/v3.0/exports \
     --header 'accept: application/json' \
     --header 'content-type: application/json' \
     --data '
{
  "type": "video",
  "period": {
    "startTimestamp": "2023-03-19T09:08:07.542Z",
    "endTimestamp": "2023-03-20T09:08:07.542Z"
  },
  "info": {
    "directory": "/exports",
    "name": "sun_going_under_on_the_7th"
  },
  "deviceId": "10058b7a"
}
'
import requests

url = "https://api.c030.eagleeyenetworks.com/api/v3.0/exports"

payload = {
    "type": "video",
    "period": {
        "startTimestamp": "2023-03-19T09:08:07.542Z",
        "endTimestamp": "2023-03-20T09:08:07.542Z"
    },
    "info": {
        "name": "sun_going_under_on_the_7th",
        "directory": "/exports"
    },
    "deviceId": "10058b7a"
}
headers = {
    "accept": "application/json",
    "content-type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
using RestSharp;


var options = new RestClientOptions("https://api.c030.eagleeyenetworks.com/api/v3.0/exports");
var client = new RestClient(options);
var request = new RestRequest("");
request.AddHeader("accept", "application/json");
request.AddJsonBody("{\"type\":\"video\",\"period\":{\"startTimestamp\":\"2023-03-19T09:08:07.542Z\",\"endTimestamp\":\"2023-03-20T09:08:07.542Z\"},\"info\":{\"name\":\"sun_going_under_on_the_7th\",\"directory\":\"/exports\"},\"deviceId\":\"10058b7a\"}", false);
var response = await client.PostAsync(request);

Console.WriteLine("{0}", response.Content);

const url = 'https://api.c030.eagleeyenetworks.com/api/v3.0/exports';
const options = {
  method: 'POST',
  headers: {accept: 'application/json', 'content-type': 'application/json'},
  body: JSON.stringify({
    type: 'video',
    period: {
      startTimestamp: '2023-03-19T09:08:07.542Z',
      endTimestamp: '2023-03-20T09:08:07.542Z'
    },
    info: {name: 'sun_going_under_on_the_7th', directory: '/exports'},
    deviceId: '10058b7a'
  })
};

fetch(url, options)
  .then(res => res.json())
  .then(json => console.log(json))
  .catch(err => console.error(err));

On success, the response includes the ID of the new export job. The job will process asynchronously, and you can check its status using the /exports/{id} endpoint.

{
  "id": "f2d4ad7b-bada-4c44-9f70-9c4b85e46b7d"
}

📘

Note

The id of the export job is not the same as the id of the archived file. To identify the file id, you need to wait for the job to complete and then call the /files with query parameters that match the directory and name you specified in the request above.

Listing the Files

By calling the GET /files endpoint you can retrieve a list of the available files and folders in the archive storage.

curl --location 'https://<base-URL>/api/v3.0/files' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer <access-token>'
import requests

url = "https://api.c030.eagleeyenetworks.com/api/v3.0/files?sort=%2BcreateTimestamp&pageSize=100"

headers = {"accept": "application/json"}

response = requests.get(url, headers=headers)

print(response.text)
using RestSharp;


var options = new RestClientOptions("https://api.c030.eagleeyenetworks.com/api/v3.0/files?sort=%2BcreateTimestamp&pageSize=100");
var client = new RestClient(options);
var request = new RestRequest("");
request.AddHeader("accept", "application/json");
var response = await client.GetAsync(request);

Console.WriteLine("{0}", response.Content);

const url = 'https://api.c030.eagleeyenetworks.com/api/v3.0/files?sort=%2BcreateTimestamp&pageSize=100';
const options = {method: 'GET', headers: {accept: 'application/json'}};

fetch(url, options)
  .then(res => res.json())
  .then(json => console.log(json))
  .catch(err => console.error(err));

The response to the above request is the following:

{
    "nextPageToken": "",
    "prevPageToken": "",
    "results": [
        {
            "id": "4272a107-a9f1-4f45-bc95-3882a285205c",
            "mimeType": "application/directory",
            "directory": "/",
            "name": "Test"
        },
        {
            "id": "36230c7b-f827-49b8-a76a-d8620f899dae",
            "mimeType": "video/mp4",
            "directory": "/",
            "name": "Video CAM 1 2023-05-22 15-10-39.mp4"
        },
        {
            "id": "2c236d24-79e3-44d5-adeb-4d370221217d",
            "mimeType": "video/mp4",
            "directory": "/Test",
            "name": "Video CAM 1 2023-05-22 15-10-39.mp4"
        }
    ]
}

By using the /files/{id} endpoint it is possible to get detailed information about a specific ID.

curl --location 'api.cxxx.eagleeyenetworks.com/api/v3.0/files/2c236d24-79e3-44d5-adeb-4d370221217d?include=publicShare&include=createTimestamp' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer <access-token>'
import requests

url = "https://api.cxxx.eagleeyenetworks.com/api/v3.0/files/2c236d24-79e3-44d5-adeb-4d370221217d"

headers = {"accept": "application/json"}

response = requests.get(url, headers=headers)

print(response.text)
using RestSharp;


var options = new RestClientOptions("https://api.c030.eagleeyenetworks.com/api/v3.0/files/2c236d24-79e3-44d5-adeb-4d370221217d");
var client = new RestClient(options);
var request = new RestRequest("");
request.AddHeader("accept", "application/json");
var response = await client.GetAsync(request);

Console.WriteLine("{0}", response.Content);

const url = 'https://api.c030.eagleeyenetworks.com/api/v3.0/files/2c236d24-79e3-44d5-adeb-4d370221217d';
const options = {method: 'GET', headers: {accept: 'application/json'}};

fetch(url, options)
  .then(res => res.json())
  .then(json => console.log(json))
  .catch(err => console.error(err));

📘

Note

You can retrieve more information about a file by including different parameters. To maximize the performance and minimize the response time, it is recommended to limit the parameters you include.

Deleting a File

To delete a file or folder make a DELETE call to the /files/{id} endpoint:

curl --location --request DELETE 'https://api.cxxx.eagleeyenetworks.com/api/v3.0/files/2c236d24-79e3-44d5-adeb-4d370221217d' \
--header 'Authorization: Bearer <access-token>'
import requests

url = "https://api.cxxx.eagleeyenetworks.com/api/v3.0/files/2c236d24-79e3-44d5-adeb-4d370221217d"

headers = {"accept": "application/json"}

response = requests.delete(url, headers=headers)

print(response.text)
using RestSharp;


var options = new RestClientOptions("https://api.cxxx.eagleeyenetworks.com/api/v3.0/files/2c236d24-79e3-44d5-adeb-4d370221217d");
var client = new RestClient(options);
var request = new RestRequest("");
request.AddHeader("accept", "application/json");
var response = await client.DeleteAsync(request);

Console.WriteLine("{0}", response.Content);

const url = 'https://api.cxxx.eagleeyenetworks.com/api/v3.0/files/2c236d24-79e3-44d5-adeb-4d370221217d';
const options = {method: 'DELETE', headers: {accept: 'application/json'}};

fetch(url, options)
  .then(res => res.json())
  .then(json => console.log(json))
  .catch(err => console.error(err));

Downloading a File

To download a file add the alt=media parameters to the /files/{id} endpoint as shown below:

curl --location 'https://<base_URL>/api/v3.0/files/<ID>?alt=media' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer <access-token>'
--output <local-path>\<file-name>.mp4

import requests

url = "https://api.cxxx.eagleeyenetworks.com/api/v3.0/files/2c236d24-79e3-44d5-adeb-4d370221217d:download"

headers = {"accept": "application/octet-stream"}

response = requests.get(url, headers=headers)

print(response.text)
using RestSharp;


var options = new RestClientOptions("https://api.cxxx.eagleeyenetworks.com/api/v3.0/files/2c236d24-79e3-44d5-adeb-4d370221217d:download");
var client = new RestClient(options);
var request = new RestRequest("");
request.AddHeader("accept", "application/octet-stream");
var response = await client.GetAsync(request);

Console.WriteLine("{0}", response.Content);

const url = 'https://api.cxxx.eagleeyenetworks.com/api/v3.0/files/2c236d24-79e3-44d5-adeb-4d370221217d:download';
const options = {method: 'GET', headers: {accept: 'application/octet-stream'}};

fetch(url, options)
  .then(res => res.json())
  .then(json => console.log(json))
  .catch(err => console.error(err));

If you run the above request by CURL, the media file is downloaded to the <local-path> with .mp4 extension.

Uploading a File

Uploading a file to the archive storage is a multi-step process. To start, you need to make a POST request to the /files endpoint. In the request body, you'll need to include the name of the file with the file extension included. Optionally, you can include the directory parameter to specify the folder where the file will be uploaded or the mimeType parameter to explicitly specify the type of the file.

curl --request POST \
     --url https://api.cxxx.eagleeyenetworks.com/api/v3.0/files \
     --header 'accept: application/json' \
     --header 'content-type: application/json' \
     --data '
{
    "mimeType": "video/mp4",
    "directory": "/uploads",
    "name": "Video CAM 1 2023-05-22 15-10-39.mp4"
}
'
import requests

url = "https://api.cxxx.eagleeyenetworks.com/api/v3.0/files?name=Video%20CAM%201%202023-05-22%2015-10-39.mp4&directory=%2Fuploads&mimeType=video%2Fmp4"

headers = {
    "accept": "application/json",
    "content-type": "application/octet-stream"
}

response = requests.post(url, headers=headers)

print(response.text)
using RestSharp;


var options = new RestClientOptions("https://api.cxxx.eagleeyenetworks.com/api/v3.0/files?name=Video%20CAM%201%202023-05-22%2015-10-39.mp4&directory=%2Fuploads&mimeType=video%2Fmp4");
var client = new RestClient(options);
var request = new RestRequest("");
request.AddHeader("accept", "application/json");
request.AddHeader("content-type", "application/octet-stream");
var response = await client.PostAsync(request);

Console.WriteLine("{0}", response.Content);

const url = 'https://api.cxxx.eagleeyenetworks.com/api/v3.0/files?name=Video%20CAM%201%202023-05-22%2015-10-39.mp4&directory=%2Fuploads&mimeType=video%2Fmp4';
const options = {
  method: 'POST',
  headers: {accept: 'application/json', 'content-type': 'application/octet-stream'}
};

fetch(url, options)
  .then(res => res.json())
  .then(json => console.log(json))
  .catch(err => console.error(err));

If successful, the response to the above will include the id of the newly created file. You can then use this id to find the uploadUrl of the file by sending a request to the /files/{file_id} endpoint. You'll need to set the include parameter to uploadUrl in the request.

curl --request GET \
     --url 'https://api.cxxx.eagleeyenetworks.com/api/v3.0/files/36230c7b-f827-49b8-a76a-d8620f899dae?include=uploadUrl' \
     --header 'accept: application/json'
import requests

url = "https://api.cxxx.eagleeyenetworks.com/api/v3.0/files/36230c7b-f827-49b8-a76a-d8620f899dae"

headers = {"accept": "application/json"}

response = requests.get(url, headers=headers)

print(response.text)
using RestSharp;


var options = new RestClientOptions("https://api.cxxx.eagleeyenetworks.com/api/v3.0/files/36230c7b-f827-49b8-a76a-d8620f899dae");
var client = new RestClient(options);
var request = new RestRequest("");
request.AddHeader("accept", "application/json");
var response = await client.GetAsync(request);

Console.WriteLine("{0}", response.Content);

const url = 'https://api.cxxx.eagleeyenetworks.com/api/v3.0/files/36230c7b-f827-49b8-a76a-d8620f899dae';
const options = {method: 'GET', headers: {accept: 'application/json'}};

fetch(url, options)
  .then(res => res.json())
  .then(json => console.log(json))
  .catch(err => console.error(err));

Once you have the uploadUrl, you can use it to upload the file to the archive storage.

curl --upload-file 'Video CAM 1 2023-05-22 15-10-39.mp4' 'https://een-drivefs-c025.s3.amazonaws.com/....'

Renaming and Moving a File or a Folder

The following example of a PATCH request shows how to rename/move a file or folder. You need to make a PATCH request with the detailed /files/<ID> endpoint for this purpose.

curl --location --request PATCH 'https://<base_URL>/api/v3.0/files/36230c7b-f827-49b8-a76a-d8620f899dae' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer <access-token>' \
--data '{
    "directory": "/new-folder",
    "name": "New Name.mp4"
}'
import requests

url = "https://api.cxxx.eagleeyenetworks.com/api/v3.0/files/36230c7b-f827-49b8-a76a-d8620f899dae"

payload = {
    "directory": "/new-folder",
    "name": "New Name.mp4"
}
headers = {
    "accept": "application/json",
    "content-type": "application/json"
}

response = requests.patch(url, json=payload, headers=headers)

print(response.text)
using RestSharp;


var options = new RestClientOptions("https://api.cxxx.eagleeyenetworks.com/api/v3.0/files/36230c7b-f827-49b8-a76a-d8620f899dae");
var client = new RestClient(options);
var request = new RestRequest("");
request.AddHeader("accept", "application/json");
request.AddJsonBody("{\"directory\":\"/new-folder\",\"name\":\"New Name.mp4\"}", false);
var response = await client.PatchAsync(request);

Console.WriteLine("{0}", response.Content);

const url = 'https://api.cxxx.eagleeyenetworks.com/api/v3.0/files/36230c7b-f827-49b8-a76a-d8620f899dae';
const options = {
  method: 'PATCH',
  headers: {accept: 'application/json', 'content-type': 'application/json'},
  body: JSON.stringify({directory: '/new-folder', name: 'New Name.mp4'})
};

fetch(url, options)
  .then(res => res.json())
  .then(json => console.log(json))
  .catch(err => console.error(err));

As shown above, you can change the name of a file or folder. You can also use the same name, but a different directory value to move the file or folder. If the directory does not exist, it is automatically created and the move operation is performed.