SiteDrive REST API

SiteDrive offers an extensive REST API that is used behind the scenes of the app. Certain APIs are only accessible via the site in which the drives are hosted on due to the sensitive data they hold.

The namespace for each route is held in the sitedrive/v1 . So, for a route like drives it would be /wp-json/sitedrive/v1/drives on your WordPress site.

There is also a function (sitedrive_external_request ) to make a REST request from a site using your SiteDrive data. You can pass the drive data into the function with a route, and it will make the request.

$driveId = 1;
$fileId = 1;

// Grab drive data
$drive = sitedrive_drive($driveId);

// Make request
$fileDownload = sitedrive_external_request($drive, 'file-download/' . $fileId, $drive, 'POST' );

When connecting a route not on your same server. You will need to pass in the Drive name and the Connection key if any. Below is a list of REST routes to SiteDrive.


drives

Method: GET

Accessible: only on site hosting

This route will grab all available drives as an array.


drives/{ID?}

Method: POST

Accessible: only on site hosting

This route will either update a Drive or Create a new drive if the ID was not passed in the URL.

id The ID of the drive, or if left empty will create a new drive
name Name of the drive
external Whether this is a local or remote drive
published If a local drive, should it be public and visible
url If this is a remote drive, the url or domain of the WordPress install
settings Object of settings. connection_key for example is the drive password

drives/{ID}

Method: DELETE

Accessible: only on site hosting

This route will delete a drive including all the folders and files.


drive_folders/{ID?}

Method: POST

Accessible: Everywhere

This will grab all folders with the files from a Drive.


drive-image/{ID?}

Method: GET

Accessible: Everywhere

This will grab the drive image / icon for the given drive. This can be used to grab a remote drive from your local drive. If there is an error a special error icon is used.


folders/{ID?}

Method: POST

Accessible: only on site hosting

This route will either update a folder or create a new drive if the ID was not passed in the URL.

id The ID of the folder, or if left empty will create a new folder
*drive_id ID of the Drive the folder belongs to. If the drive is remote this will give you an error
*name Name of the folder

folders/{ID?}

Method: DELETE

Accessible: only on site hosting

This route will delete a folder.


files

Method: POST

Accessible: only on site hosting

This route will add a file to a folder.

*folder_id ID of the Folder the File should belong to
*type Provider type of the file
*type_id The type ID. For instance a type of attachment and a type_id of 1 would be the attachment with ID 1 .

files/{ID}

Method: DELETE

Accessible: only on site hosting

This route will remove a file from a folder. This does not actually delete the file on the WordPress site only removes it from listing in the folder on SiteDrive.


file-download/{ID?}

Method: POST

Accessible: Everywhere

This route will download a file. When importing happens, SiteDrive uses this route to download the file from the remote drive.

direct With this option in place as true, it will download the from certain providers as you would expect. For example the Media provider when importing will also export meta info. But when downloading sometimes you only want the raw media file.

file-import

Method: POST

Accessible: only on site hosting

This route will take a drive_id and an array of file ids in files and import them into your site.

files Array of file ids you wish to import from a remote drive.

files-upload

Method: POST

Accessible: only on site hosting

This route will upload a file in a base64 format and upload it to a specific drive and folder. It takes a drive_id, a folder_id, and an array of files each file item requiring a data key which is the base64 file data, and name of the file.

*files Array of file objects you wish to upload to WordPress and from a remote drive. Each object should have at least a data key which is the base64 data to upload. It can also have a name key which would be the name that should be used by SiteDrive.
*drive_id Drive to upload to
*folder_id Folder to upload to

file-meta/{ID}

Method: POST

Accessible: only on site hosting

This route will update the custom image icon for a specific file on your drive. It takes in an object of parameters keyed by meta. meta['custom_image_url'] is currently the only meta value in place.

*meta Object of meta values to update. Currently only custom_image_url is supported which is an attachment ID or an empty value to use the default image for a file.

Still need help? Contact Us Contact Us