The
visualvault-apinpm package source code has moved to vv-rest-api-node. All future package updates, issues, and pull requests should be directed there. The API wrapper code will be removed from this repository in a future update, and this repo will continue to serve as the source for the VisualVault server code.
A Node.js client library that provides convenient access to the VisualVault REST API for server-side applications.
npm install visualvault-api- Node.js 20.0.0 or higher
const vvRestApi = require('visualvault-api');
// Initialize authentication
const auth = new vvRestApi.authorize();
// Get authenticated client
auth.getVaultApi(
'your-client-id',
'your-client-secret',
'username',
'password',
'your-audience',
'https://your-vault-url.com',
'customer-alias',
'database-alias'
).then(client => {
console.log('Successfully authenticated!');
// Use the client for API calls
}).catch(error => {
console.error('Authentication failed:', error);
});If you already have a JWT token:
const auth = new vvRestApi.authorize();
auth.getVaultApiFromJwt(
'your-jwt-token',
'https://your-vault-url.com',
'customer-alias',
'database-alias',
new Date('2024-12-31') // expiration date
).then(client => {
console.log('JWT authentication successful!');
}).catch(error => {
console.error('JWT authentication failed:', error);
});// Get documents from a folder
client.library.getDocuments(params, folderId)
.then(response => {
const documents = JSON.parse(response);
console.log('Documents:', documents.data);
});
// Upload a new document
const documentData = {
fileName: 'example.pdf',
description: 'Example document',
folderId: 'your-folder-id'
};
client.documents.postDocWithFile(documentData, fileBuffer)
.then(response => {
console.log('Document uploaded:', response);
});
// Get document details
client.documents.getDocumentRevision(params, revisionId)
.then(response => {
const document = JSON.parse(response);
console.log('Document details:', document);
});// Get forms by template name
client.forms.getForms(params, 'Your Form Template Name')
.then(response => {
const forms = JSON.parse(response);
console.log('Forms:', forms.data);
});
// Create a new form instance
const formData = {
field1: 'value1',
field2: 'value2'
};
client.forms.postForms(params, formData, 'Your Form Template Name')
.then(response => {
console.log('Form created:', response);
});
// Get form instance by ID
client.forms.getFormInstanceById(templateId, instanceId)
.then(response => {
const form = JSON.parse(response);
console.log('Form instance:', form);
});// Get folders
client.library.getFolders(params)
.then(response => {
const folders = JSON.parse(response);
console.log('Folders:', folders.data);
});
// Create a new folder
const folderData = {
name: 'New Folder',
description: 'Folder description'
};
client.library.postFolderByPath(params, folderData, '/Parent Folder/New Folder')
.then(response => {
console.log('Folder created:', response);
});// Get current user information
client.users.getUser(params)
.then(response => {
const user = JSON.parse(response);
console.log('Current user:', user);
});
// Get users in a site
client.users.getUsers(params, siteId)
.then(response => {
const users = JSON.parse(response);
console.log('Users:', users.data);
});// Execute a custom query by name
client.customQuery.getCustomQueryResultsByName('Your Query Name', params)
.then(response => {
const results = JSON.parse(response);
console.log('Query results:', results.data);
});// Upload a file
const fileData = {
fileName: 'document.pdf',
description: 'My document'
};
client.files.postFile(fileData, fileBuffer)
.then(response => {
console.log('File uploaded:', response);
});
// Download a file
client.files.getFileBytesId(fileId)
.then(fileBuffer => {
// Process the file buffer
console.log('File downloaded, size:', fileBuffer.length);
});// Execute a web service
const serviceData = {
param1: 'value1',
param2: 'value2'
};
client.scripts.runWebService('YourWebServiceName', serviceData)
.then(response => {
console.log('Web service result:', response);
});The client provides access to the following VisualVault API modules:
- documents - Document management operations
- forms - Form template and instance operations
- library - Folder and library management
- users - User management operations
- groups - Group management operations
- sites - Site management operations
- files - File upload/download operations
- scripts - Web service execution
- customQuery - Custom query execution
- email - Email operations
- constants - API constants and enums
- scheduledProcess - Scheduled process management
- customer - Customer management operations
- projects - Project management operations
- indexFields - Document Index field operations
- outsideProcesses - Outside process management
- securityMembers - Security member management
- reports - Report generation
client.documents.getDocuments(params, folderId)
.then(response => {
const result = JSON.parse(response);
if (result.meta && result.meta.statusCode === 200) {
console.log('Success:', result.data);
} else {
console.error('API Error:', result);
}
})
.catch(error => {
console.error('Request failed:', error);
});For more information about the VisualVault API, visit the VisualVault documentation.
For VisualVault micro service debugging assistance see Readme-microservices.
Use of the VisualVault API requires a customer hosting contract which defines all license terms.