OpenVeo REST NodeJS client API

API Docs for: 4.0.0
Show:

OpenVeoClient

Summary

Creates a client to connect to OpenVeo web service.

It aims to facilitate the interaction with OpenVeo web service. All authentication aspects are managed by the client and are transparent to the user. Requesting an end point, without being authenticated, will automatically authenticate first before calling the end point. If token expired, a new authentication is made automatically.

Constructor

OpenVeoClient

Syntax

OpenVeoClient

(
  • webServiceUrl
  • clientId
  • clientSecret
  • [certificate]
)

Summary

Parameters:

  • webServiceUrl String

    The complete URL of the OpenVeo Web Service (with protocol and port)

  • clientId String

    Application's client id

  • clientSecret String

    Application's client secret

  • [certificate] String optional

    Absolute path to the web service server full chain certificate file

Example:

const OpenVeoClient = require('@openveo/rest-nodejs-client').OpenVeoClient;
const client = new OpenVeoClient(
            'https://www.openveo-web-service:443',
            'client id',
            'client secret',
            '/absolute/path/to/fullchain/certificate.crt'
);

Methods

authenticate

Syntax

authenticate

() Promise private async

Summary

Authenticates the client to the web service.

Returns:

Promise:
Promise resolving when the client is authenticated, promise is rejected if authentication failed

buildRequest

Syntax

buildRequest

(
  • [options]
  • [body]
  • [timeout=10000]
  • [multiparted=false]
  • resolve
  • reject
)
Request private

Summary

Builds a request.

Parameters:

  • [options] Object optional
    The list of http(s) options as described by NodeJS http.request documentation
  • [body] Object | String optional
    The request body
  • [timeout=10000] Number optional
    Maximum execution time for the request (in ms), set it to Infinity for a request without limits
  • [multiparted=false] Boolean optional
    true to send body as multipart/form-data
  • resolve Function
    The function to call with request's result
  • reject Function
    The function to call if request fails

Returns:

Request:
The request, ready to be executed

delete

Syntax

delete

(
  • endPoint
  • [options]
  • [timeout=10000]
)
Promise async

Summary

Executes a DELETE request. If client is not authenticated or access token has expired, a new authentication is automatically performed.

Parameters:

  • endPoint String
    The web service end point to reach with query parameters
  • [options] Object optional
    The list of http(s) options as described by NodeJS http.request documentation
  • [timeout=10000] Number optional
    Maximum execution time for the request (in ms), set it to Infinity for a request without limits

Returns:

Promise:
Promise resolving with results as an Object

executeRequest

Syntax

executeRequest

(
  • method
  • endPoint
  • [options]
  • [body]
  • [timeout=10000]
  • [multiparted=false]
)
Promise private async

Summary

Executes a REST request after making sure the client is authenticated. If client is not authenticated or access token has expired, a new authentication is automatically performed and request is retried.

Parameters:

  • method String
    The HTTP method to use (either get, post, delete or put)
  • endPoint String
    The web service end point to reach with query parameters
  • [options] Object optional
    The list of http(s) options as described by NodeJS http.request documentation
  • [body] Object | String optional
    The request body
  • [timeout=10000] Number optional
    Maximum execution time for the request (in ms), set it to Infinity for a request without limits
  • [multiparted=false] Boolean optional
    true to send body as multipart/form-data

Returns:

Promise:
Promise resolving with request's response

get

Syntax

get

(
  • endPoint
  • [options]
  • [timeout=10000]
)
Promise async

Summary

Executes a GET request. If client is not authenticated or access token has expired, a new authentication is automatically performed.

Parameters:

  • endPoint String
    The web service end point to reach with query parameters
  • [options] Object optional
    The list of http(s) options as described by NodeJS http.request documentation
  • [timeout=10000] Number optional
    Maximum execution time for the request (in ms), set it to Infinity for a request without limits

Returns:

Promise:
Promise resolving with result as an Object

getAuthenticationHeaders

Syntax

getAuthenticationHeaders

() Object private

Summary

Gets the list of headers to send with each request.

Returns:

Object:

The list of headers to add to all requests sent to the server

getRequestHeaders

Syntax

getRequestHeaders

() Object private

Summary

Gets the list of headers to send with each request.

Returns:

Object:
The list of headers to add to all requests sent to the server

isAuthenticated

Syntax

isAuthenticated

() Boolean private

Summary

Indicates if the client is authenticated to the web service or not.

Returns:

Boolean:
true if the client is authenticated, false otherwise

patch

Syntax

patch

(
  • endPoint
  • [body]
  • [options]
  • [timeout=10000]
  • [multiparted=false]
)
Promise async

Summary

Executes a PATCH request. If client is not authenticated or access token has expired, a new authentication is automatically performed.

Parameters:

  • endPoint String
    The web service end point to reach with query parameters
  • [body] Object | String optional
    The request body
  • [options] Object optional
    The list of http(s) options as described by NodeJS http.request documentation
  • [timeout=10000] Number optional
    Maximum execution time for the request (in ms), set it to Infinity for a request without limits
  • [multiparted=false] Boolean optional
    true to send body as multipart/form-data

Returns:

Promise:
Promise resolving with results as an Object

post

Syntax

post

(
  • endPoint
  • [body]
  • [options]
  • [timeout=10000]
  • [multiparted=false]
)
Promise async

Summary

Executes a POST request. If client is not authenticated or access token has expired, a new authentication is automatically performed.

Parameters:

  • endPoint String
    The web service end point to reach with query parameters
  • [body] Object | String optional
    The request body
  • [options] Object optional
    The list of http(s) options as described by NodeJS http.request documentation
  • [timeout=10000] Number optional
    Maximum execution time for the request (in ms), set it to Infinity for a request without limits
  • [multiparted=false] Boolean optional
    true to send body as multipart/form-data

Returns:

Promise:
Promise resolving with results as an Object

put

Syntax

put

(
  • endPoint
  • [body]
  • [options]
  • [timeout=10000]
  • [multiparted=false]
)
Promise async

Summary

Executes a PUT request. If client is not authenticated or access token has expired, a new authentication is automatically performed.

Parameters:

  • endPoint String
    The web service end point to reach with query parameters
  • [body] Object | String optional
    The request body
  • [options] Object optional
    The list of http(s) options as described by NodeJS http.request documentation
  • [timeout=10000] Number optional
    Maximum execution time for the request (in ms), set it to Infinity for a request without limits
  • [multiparted=false] Boolean optional
    true to send body as multipart/form-data

Returns:

Promise:
Promise resolving with results as an Object

Properties

accessToken

Syntax

accessToken

String

Summary

Application access token provided by the web service.

authenticateRequest

Syntax

authenticateRequest

Request final

Summary

The authenticate request to get an access token.

certificate

Syntax

certificate

String final

Summary

Path to the web service server certificate file.

clientId

Syntax

clientId

String final

Summary

Application client id.

clientSecret

Syntax

clientSecret

String final

Summary

Application client secret.

credentials

Syntax

credentials

String final

Summary

Encoded credentials ready for OAuth authentication.

hostname

Syntax

hostname

String final

Summary

Web service server host name.

maxAuthenticationAttempts

Syntax

maxAuthenticationAttempts

Number

Summary

Maximum number of authentication attempts to perform on a request in case of an invalid or expired token.

Default: 1

path

Syntax

path

String final

Summary

Web service URL path.

port

Syntax

port

Number final

Summary

Web service server port.

protocol

Syntax

protocol

String final

Summary

Web service protocol, either "http" or "https".

queuedRequests

Syntax

queuedRequests

Set

Summary

The collection of queued requests waiting to be executed.