Whiteboard Team
Whiteboard Team is a visual collaboration platform. The API brings the power of the whiteboard to your app or platform.
Adding Whiteboard Team to your site is quick and easy. Just add this code to your HTML document:
<body>
<div style="width: 600px; height: 550px;" id="wt-container"></div>
<script src="https://www.whiteboard.team/dist/api.js"></script>
<script type="text/javascript">
var wt = new api.WhiteboardTeam('#wt-container', {
clientId: '<your clientId>',
boardCode: '<board code>'
});
</script>
</body>
clientId: To use Whiteboard Team API, you need a client ID. Get your client credential
boardCode: Each board is identified by a unique string code. It should be a unique and unguessable string
Creating a whiteboard makes a remote request to Whiteboard Team, so it may take hundreds of milliseconds or more before the SDK emits the ready event. To find out when the whiteboard is ready to use, you can use one of two mechanisms: events or promises.
The ready event emits when the whiteboard has been loaded and ready to use. It is a good place to have all other function callings.
wt.addListener("ready", ctx => console.log("The whiteboard is ready and user is: ", ctx.uid ))
Or, you can use a promise instead of an event.
wt.waitUntilReady()
.then(ctx => console.log("The whiteboard is ready and user is: ", ctx.uid ))
.catch(error => console.log(error));
IMPORTANT: Do not download the script to your site and host them yourself, this will break the functionality.
To create a whiteboard, create a new instance of api.WhiteboardTeam() with a container element and preferred options.
new api.WhiteboardTeam(element, {options})
clientId: '42c8014a89e6ad83a13e26538f1a63b6'
boardCode: '361249e0-feca-4acb-8483-66cf47dad409'
With this option, you can set the role of participant. valid roles are 'facilitator' and 'editor' who can edit and 'viewer' who can view only.
participant: {
role : 'editor'
}
With this option, you can set the display name of the user.
participant: {
name : 'DisplayName'
}
With this option, you can set permissions of the user. view_templates adds templates to the toolbar and view_chat adds chat to the board.
participant: {
permissions : ["view_templates", "view_chat"]
}
With this option you can set a default tool, valid tools are pan, pen, line, arrow, circle, filledCircle, rectangle, filledRectangle, text, stickyNote or select. Default of this option is pen. Here is an example:
board: {
tool: 'pen'
}
With this option you can set a default thickness, thickness use for pen or border of shapes. Default of this option is 2. Here is an example:
board: {
thickness: 1
}
With this option you can replace your color sub-menu colors. It should be a array of hex colors. The default of this option is null. Here is an example:
board: {
colors: ['#FF5733', '#3498DB', '#5B2C6F', '#212F3C']
}
With this option you can set a default color that will appear as the color button on the main menu. It doesn't have to be a part of your color sub-menu colors. It should be a hex color format. The default of this option is black. Here is an example:
board: {
color: '#000000'
}
With this option you can set a background color for the board. It should be a hex color format. Here is an example:
board: {
bgColor: '#00AA5F'
}
With this option you can set a default background for the board. The default of this option is 'Dot'. Valid backgrounds are 'None', 'Dot', 'Graph paper', 'Large grid', 'Small grid', 'Line' Here is an example:
board: {
bg : 'Small grid'
}
Zooms the board in by one step.
wt.zoomIn()
Zooms the board out by one step.
wt.zoomOut()
Zooms the board to 100%
wt.resetZoom()
Does undo of the previous own operation.
wt.undo()
Does redo of the previous own undo.
wt.redo()
clear the content of the board. It's undoable.
wt.board.clear()
Repositions zoom level and pan position so that the entire content on the board is visible.
wt.fitToScreen()
Removes objects from the board.
wt.removeCommand(commands);
Shows a notification on the whiteboard.
wt.notify(message);
Fullsscreens the whiteboard.
wt.fullscreen()
Draws a line or arrow on the board.
wt.drawLine(points, color, lineWidth, type);
Draws shape defined as array of points
wt.drawPen(points, color, lineWidth);
Draws a rectangle on the board
wt.drawRectangle(x, y, w, h, stroke, lineWidth, fill);
Draws a circle on the board
wt.drawCircle(x, y, r, stroke, lineWidth, fill);
Draws a text on the board
wt.drawText(x, y, text, color, font, size);
Draws a sticky note on the board
wt.drawStickyNote(x, y, w, h, text, color, size);
Place an image on the board.
wt.drawImage(url,x,y);
Place an image in the center of the viewport.
wt.drawImage(url);
Place an image in the center of the viewport and zoom to the image.
wt.drawImage(url)
.then(image=> {
wt.viewport.zoomTo(image);
});
A promise contains the image's object.
Draws a frame on the board
wt.drawFrame(x, y, w, h, title, color );
Get the image of board.
wt.getImage(background).then(img => console.log(img));
Promise with base65 image.
Get the current user of the board.
wt.getCurrentUser().then(user => console.log(user));
Promise with an object containing the user id.
returns all shapes on the board.
wt.board.get().then(shapes => console.log(shapes));
Array of shapes.
Destroy the instance of the whiteboard.
wt.destroy();
The callback will call when the board has been loaded. Here's an example:
wt.onReady(ctx => console.log(ctx));
The callback will call when any error occurred. Here's an example:
wt.onError(error => {
console.log(error.type, error.message);
})
The event will emit when the board is fully loaded and ready to use.
wt.addListener('ready', ctx => console.log('ready', ctx));
The event will emit when the board fails to load.
wt.addListener('error', error => console.log('error', error));
Returns a promise that tracks the whiteboard creation status.
wt.waitUntilReady()
.then(ctx => console.log("The whiteboard is ready and user is: ", ctx.uid ))
.catch(error => console.log(error));
The event will emit when any other participant joins the board.
wt.addListener('user-joined', user => console.log('joined', user));
The event will emit when any other participant leaves the board.
wt.addListener('user-left', user => console.log('left', user));
The event will emit when a user mentioned on comment
wt.addListener('user-mentioned', mention => console.log('user-mentioned', mention));
Using client secret for REST API requests.
You can pass client secret in Api-Key header
Gets all boards and returns an array of board objects
curl -H "Api-Key: <SECRET_KEY>" -X GET "https://www.whiteboard.team/api/v1/boards"
returns an array of board objects
{
"data": [
{
"id": "9725c0f7-8a4e-43ee-c87b-08d7a3020e76",
"name": "Sample Board",
"code": "8331612C-B0E7-466F-8F50-D2B90ADB42A9",
"createdDate": "2020-01-27T12:00:49.1113226",
"lastUse": "2020-01-30T08:07:23.383282",
"lastChange": "2020-01-29T15:12:11.6749696",
"shareType": 1
}
],
"totalCount": 1
}
Gets a board by id and returns a board objects
curl -H "Api-Key: <SECRET_KEY>" -X GET "https://www.whiteboard.team/api/v1/boards/<BORAD_ID>"
BORAD_ID [string] - board id
returns a board object
{
"name": "Sample Board",
"code": "8331612C-B0E7-466F-8F50-D2B90ADB42A9",
"createdDate": "2020-01-27T12:00:49.1113226",
"lastUse": "2020-01-29T19:17:15.5687596",
"lastChange": "2020-01-29T15:12:11.6749696",
"shareType": 1,
"members": [
{
"uid": "68ea8ac4-e21d-4c8b-9e3b-d977feee177e",
"username": null,
"joinedDate": "2020-01-27T12:00:49.1180617",
"isActive": true,
"isOwner": false
},
]
}
Delete a board by Id.
curl -H "Api-Key: <SECRET_KEY>" -X DELETE "https://www.whiteboard.team/api/v1/boards/<BORAD_ID>"
BORAD_ID [string] - board id
Upload an image to the board.
curl -H "Api-Key: <SECRET_KEY>" -F Uid=<USER_ID> -F file=@<FILENAME> https://www.whiteboard.team/api/v1/boards/<BORAD_ID>/upload"
There is no separation between board id and code in API 2. So, 'Id' is the same 'code' you assigned in the JavaScript API.
Pass client secret in Api-Key header:
Gets all boards
curl -H "Api-Key: <SECRET_KEY>" -X GET "https://www.whiteboard.team/api/v2/boards?take=<take>&skip=<skip>"
returns an object containing an array of boards and total counts of boards.
{
"data": [
{
"id": "9725c0f7-8a4e-43ee-c87b-08d7a3020e76",
"name": "Sample Board",
"createdDate": "2020-01-27T12:00:49.1113226",
"lastUse": "2020-01-30T08:07:23.383282",
"lastChange": "2020-01-29T15:12:11.6749696",
}
],
"totalCount": 1
}
Gets a board.
curl -H "Api-Key: <SECRET_KEY>" -X GET "https://www.whiteboard.team/api/v2/boards/<BORAD_ID>"
BORAD_ID [string] - board id
returns a board object
{
"id":"<BORAD_ID>",
"name": "Sample Board",
"createdDate": "2020-01-27T12:00:49.1113226",
"lastUse": "2020-01-29T19:17:15.5687596",
"lastChange": "2020-01-29T15:12:11.6749696",
"members": [
{
"id": "68ea8ac4-e21d-4c8b-9e3b-d977feee177e",
"joinedDate": "2020-01-27T12:00:49.1180617",
"isActive": true,
"role": "Editor"
},
]
}
Gets board comments.
curl -H "Api-Key: <SECRET_KEY>" -X GET "https://www.whiteboard.team/api/v2/boards/<BORAD_ID>/comments/"
BORAD_ID [string] - board id
returns an array of comments grouped by threads.
[
{
"threadId": "63579364a81262d7d9eb7d82",
"comments": [
{
"id": "63579364a81262d7d9eb7d81",
"createdBy": "29174542-6827-441e-adbc-3af3475a15c1",
"createdDate": "2022-10-25T07:42:28.587+00:00",
"message": "a comment",
"name": "Editor"
}
]
}
]
Duplicates a board
curl -H "Api-Key: <SECRET_KEY>" -H "Content-Type: application/json" -d "{\"newId\":\"<NEW_BORAD_ID>\",\"name\":\"<NEW_NAME>\",\"memberId\":\"<MEMBER_ID>\"}" -X POST "https://www.whiteboard.team/api/v2/boards/<BORAD_ID>/duplicate/"
returns id of the board.
{
"id": "appname-uauhOfzESiilU3x5IF4YydB3W"
}
uploads an image
curl -H "Api-Key: <SECRET_KEY>" -F MemberId=<MEMBER_ID> -F file=@<FILENAME> -X POST "https://www.whiteboard.team/api/v2/boards/<BORAD_ID>/upload/"
creates a new board
curl -H "Api-Key: <SECRET_KEY>" -H "Content-Type: application/json" -d "{\"newId\":\"<NEW_BORAD_ID>\",\"name\":\"<NAME>\","members\":<MEMBERS>}" -X POST "https://www.whiteboard.team/api/v2/boards"
returns id of the board.
{
"id": "appname-uauhOfzESiilU3x5IF4YydB3W"
}
Deletes a board
curl -H "Api-Key: <SECRET_KEY>" -X DELETE "https://www.whiteboard.team/api/v2/boards/<BORAD_ID>/"
Deletes a board's content
curl -H "Api-Key: <SECRET_KEY>" -X DELETE "https://www.whiteboard.team/api/v2/boards/<BORAD_ID>/commands/"