@bluescape/bluescape-sdk-js v1.2.3
Bluescape API SDK for Javascript
The official Bluescape SDK for JavaScript, available for browsers and Node.js backends.
In the Browser
Installing
To use the SDK in the browser, simply download dist/bluescape.min.js
and add the following script tag to your HTML pages:
<script src="bluescape.min.js"></script>
Library Usage
const options = {
authorization: `Bearer ${accessToken}`
};
const client = new Bluescape(options);
client.getAuthenticatedUser()
.then((response) => {
console.log(response);
})
.catch((err) => {
console.log(err);
});
Form Data Parameters
Form data parameters should be provided as a FormData object. A sample:
const workspaceId = 'k1i2RERHtNvc8tD76u1r';
const formData = new FormData();
formData.append('x', 1000);
formData.append('y', 1000);
formData.append('url', 'https://myapp.com/logo.png');
client.addImageToWorkspace(workspaceId, formData)
.then((response) => {
console.log(response);
})
.catch((err) => {
console.log(err);
});
Node.js
Installing
The preferred way to install the Bluescape API SDK for Node.js is to use the npm package manager. Simply type the following into a terminal window:
npm install @bluescape/bluescape-sdk-js --save
Library Usage
const options = {
authorization: `Bearer ${accessToken}`
};
const Bluescape = require('@bluescape/bluescape-sdk-js');
const client = new Bluescape(options);
client.getAuthenticatedUser()
.then((response) => {
console.log(response);
})
.catch((err) => {
console.log(err);
});
Form Data Parameters
Form data parameters should be provided in Node.js using the Form-Data project which creates readable "multipart/form-data"
streams in Node that behave just like FormData objects in the browser. A sample:
const FormData = require('form-data');
const workspaceId = 'k1i2RERHtNvc8tD76u1r';
const formData = new FormData();
formData.append('x', 1000);
formData.append('y', 1000);
formData.append('url', 'https://myapp.com/logo.png');
client.addImageToWorkspace(workspaceId, formData);
Uploading an Image File
const fs = require('fs');
const path = require('path');
const FormData = require('form-data');
const imagePath = path.resolve(__dirname, 'image.jpg');
const imageData = fs.createReadStream(imagePath);
const workspaceId = 'k1i2RERHtNvc8tD76u1r';
const formData = new FormData();
formData.append('x', 0);
formData.append('y', 0);
formData.append('image', imageData);
client.addImageToWorkspace(workspaceId, formData);
Node style callback & Promise-based interfaces
Providing a callback function is supported for all methods, but is optional, and when omitted, methods will return a promise.
Errors
Errors are reported with the following format. They include the request configuration for help in debugging.
{
"status": 401,
"statusText": "Unauthorized",
"error": {
"message": "Authentication failed"
},
"request": {
"method": "POST",
"url": "https://api.apps.us.bluescape.com/session/user",
"headers": {
"Authorization": "Bearer ..."
},
"data": {}
}
}
Getting Started with the Bluescape API
You can find a getting started guide at:
https://developer.bluescape.com/overview
You can find our API reference documentation at:
https://developer.bluescape.com/reference
Getting Help
Please use these community resources for getting help. We use the GitHub issues for tracking bugs and feature requests and have limited bandwidth to address them.
- Ask a question on StackOverflow and tag it with
bluescape-sdk-js
- Open a support ticket with Bluescape API Support
- If it turns out that you may have found a bug, please open an issue
Opening Issues
If you encounter a bug with the Bluescape API SDK for Node we would like to hear about it. Search the existing issues and try to make sure your problem doesn’t already exist before opening a new issue. It’s helpful if you include the version of the SDK, Node.js and OS you’re using. Please include a stack trace and a simple way to reproduce the problem when appropriate, too.
The GitHub issues are intended for bug reports and feature requests. For help and questions with using the Bluescape API SDK for Node please make use of the resources listed on our Developer Portal. There are limited resources available for handling issues and by keeping the list of open issues lean we can respond in a timely manner.
Method List
Browsers
addBrowserToWorkspace(workspace_id, body, [callback])
deleteBrowser(workspace_id, browser_id, [callback])
updateBrowser(workspace_id, browser_id, body, [callback])
Canvases
addCanvasToWorkspace(workspace_id, body, [callback])
deleteCanvas(workspace_id, canvas_id, [callback])
updateCanvas(workspace_id, canvas_id, body, [callback])
Comments
addCommentToObject(workspace_id, object_type, object_id, body, [callback])
Documents
addDocumentToWorkspace(workspace_id, formData, [callback])
deleteDocument(workspace_id, document_id, [callback])
updateDocument(workspace_id, document_id, body, [callback])
Images
addImageToWorkspace(workspace_id, formData, [callback])
deleteImage(workspace_id, image_id, [callback])
updateImage(workspace_id, image_id, body, [callback])
Listeners
createListener(body, [callback])
deleteListener(listener_id, [callback])
getAllListeners([query], [callback])
getListener(listener_id, [callback])
updateListener(listener_id, body, [callback])
Notes
addNoteToWorkspace(workspace_id, body, [callback])
deleteNote(workspace_id, note_id, [callback])
updateNote(workspace_id, note_id, body, [callback])
Organizations
addOrganizationUser(organization_id, body, [callback])
getOrganization(organization_id, [callback])
getOrganizationUsers(organization_id, [query], [callback])
removeOrganizationUser(organization_id, user_id, [callback])
updateOrganizationUser(organization_id, user_id, body, [callback])
Permissions
listMemberRoles([callback])
listWorkspaceRoles([callback])
Strokes
deleteStrokeFromWorkspace(workspace_id, stroke_id, [callback])
drawStrokeOnObject(workspace_id, object_type, object_id, body, [callback])
drawStrokeOnWorkspace(workspace_id, body, [callback])
Text
addTextToWorkspace(workspace_id, body, [callback])
deleteText(workspace_id, text_id, [callback])
updateText(workspace_id, text_id, body, [callback])
Users
getAuthenticatedUser([callback])
getUser(user_id, [callback])
getUserOrganizations(user_id, [query], [callback])
getUserWorkspaces(user_id, [query], [callback])
getUserWorkspacesInOrganization(user_id, organization_id, [query], [callback])
updateUser(user_id, body, [callback])
Workspaces
addWorkspaceUser(workspace_id, body, [callback])
copyWorkspace(workspace_id, body, [callback])
createWorkspace(organization_id, body, [callback])
deleteWorkspace(workspace_id, body, [callback])
favoriteWorkspace(workspace_id, body, [callback])
getActiveUsersInWorkspace(workspace_id, [query], [callback])
getWorkspace(workspace_id, [callback])
getWorkspaceUsers(workspace_id, [query], [callback])
publishWorkspace(workspace_id, [callback])
removeWorkspaceUser(workspace_id, user_id, [callback])
unpublishWorkspace(workspace_id, [callback])
updateWorkspace(workspace_id, body, [callback])
updateWorkspaceUserRole(workspace_id, user_id, body, [callback])