Managing Archives

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));

Renaming and Moving a File or a Folder

The following example of a PATCH request shows how to rename/move a file or folder. To achieve this, you need to make a PATCH request with the details to the /files/<ID> endpoint.

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.