API

api~ API

Main class for managing a session with the Voxel51 Vision Services API.

Constructor

new API(tokenPathopt)

Creates a new API instance.

Parameters:
Name Type Attributes Default Description
tokenPath string <optional>
null

an optional path to a valid token JSON file. If no path is provided as an argument, the VOXEL51_API_TOKEN environment variable is checked and, if set, the token is loaded from that path. Otherwise, the token is loaded from ~/.voxel51/api-token.json

Source:

Methods

(async) listAnalytics() → {Array}

Returns a list of all available analytics.

Source:
Throws:

if the request was unsuccessful

Type
APIError

(async) getAnalyticDoc(analyticId) → {object}

Gets documentation about the analytic with the given ID.

Parameters:
Name Type Description
analyticId string

the analytic ID

Source:
Throws:

if the request was unsuccessful

Type
APIError

(async) listData() → {Array}

Returns a list of all user data uploaded to cloud storage.

Source:
Throws:

if the request was unsuccessful

Type
APIError

(async) uploadData(path) → {object}

Uploads data to cloud storage.

Parameters:
Name Type Description
path string

the path to the data file

Source:
Throws:

if the request was unsuccessful

Type
APIError

(async) getDataDetails(dataId) → {object}

Gets details about the data with the given ID.

Parameters:
Name Type Description
dataId string

the data ID

Source:
Throws:

if the request was unsuccessful

Type
APIError

(async) downloadData(dataId, outputPath) → {void}

Downloads the data with the given ID.

Parameters:
Name Type Description
dataId string

the data ID

outputPath string

the output path to write to

Source:
Throws:

if the request was unsuccessful

Type
APIError

(async) deleteData(dataId)

Deletes the data with the given ID from the cloud.

Parameters:
Name Type Description
dataId string

the data ID

Source:
Throws:

if the request was unsuccessful

Type
APIError

(async) listJobs() → {Array}

Returns a list of all jobs in the cloud.

Source:
Throws:

if the request was unsuccessful

Type
APIError

(async) uploadJobRequest(jobRequest, jobName, autoStartopt) → {object}

Uploads a job request to the cloud.

Parameters:
Name Type Attributes Default Description
jobRequest JobRequest

a JobRequest instance describing the job

jobName string

a name for the job

autoStart boolean <optional>
false

whether to automatically start the job upon creation

Source:
To Do:
  • allow jobJSONPath to accept a job JSON object directly
Throws:

if the request was unsuccessful

Type
APIError

(async) getJobDetails(jobId) → {object}

Gets details about the job with the given ID.

Parameters:
Name Type Description
jobId string

the job ID

Source:
Throws:

if the request was unsuccessful

Type
APIError

(async) getJobRequest(jobId) → {JobRequest}

Gets the job request for the job with the given ID.

Parameters:
Name Type Description
jobId string

the job ID

Source:
Throws:

if the request was unsuccessful

Type
APIError

(async) startJob(jobId)

Starts the job with the given ID.

Parameters:
Name Type Description
jobId string

the job ID

Source:
Throws:

if the request was unsuccessful

Type
APIError

(async) getJobState(jobId) → {string}

Gets the state of the job with the given ID.

Parameters:
Name Type Description
jobId string

the job ID

Source:
Throws:

if the request was unsuccessful

Type
APIError

(async) isJobComplete(jobId) → {boolean}

Determines whether the job with the given ID is complete.

Parameters:
Name Type Description
jobId string

the job ID

Source:
Throws:
  • if the job failed

    Type
    JobExecutionError
  • if the underlying API request was unsuccessful

    Type
    APIError

(async) waitUntilJobCompletes(jobId, sleepTimeopt, maxWaitTimeopt) → {Promise}

Waits until the job with the given ID is complete.

Parameters:
Name Type Attributes Default Description
jobId string

the job ID

sleepTime number <optional>
5

the number of seconds to wait between job state checks

maxWaitTime number <optional>
600

the maximum number of seconds to wait for the job to complete

Source:
Throws:
  • if the job failed

    Type
    JobExecutionError
  • if the maximum wait time was exceeded

    Type
    APITimeoutError
  • if an underlying API request was unsuccessful

    Type
    APIError

(async) getJobStatus(jobId) → {object}

Gets the status of the job with the given ID.

Parameters:
Name Type Description
jobId string

the job ID

Source:
Throws:

if the request was unsuccessful

Type
APIError

(async) downloadJobOutput(jobId, outputPathopt) → {void}

Downloads the output of the job with the given ID.

Parameters:
Name Type Attributes Default Description
jobId string

the job ID

outputPath string <optional>
'output.zip'

the output path to write to

Source:
Throws:

if the request was unsuccessful

Type
APIError