API initializer. Will be called as soon as the webKnossos API is ready.

apiReady
Parameters
version (number)
Example
window.webknossos.apiReady(3).then((api) => {
  // Your cool user script / wK plugin
  const nodes = api.tracing.getAllNodes();
  ...
});

All tracing related API methods. This is the newest version of the API (version 3).

new TracingApi(model: OxalisModel)
Version: 3
Parameters
model (OxalisModel)
Example
window.webknossos.apiReady(3).then(api => {
  api.tracing.getActiveNodeId();
  api.tracing.getActiveTreeId();
  ...
}
Instance Members
getActiveNodeId()
getActiveTreeId()
getActiveGroupId()
setActiveNode(id)
getAllNodes()
getAllTrees()
deleteNode(nodeId, treeId)
centerActiveNode()
deleteTree(treeId)
resetSkeletonTracing()
setCommentForNode(commentText, nodeId, treeId)
getCommentForNode(nodeId, treeId, tree)
setTreeName(name, treeId)
setActiveTree(treeId)
setActiveTreeByName(treeName)
setActiveGroup(groupId)
setTreeColorIndex(treeId, colorIndex)
setTreeVisibility(treeId, isVisible)
getTreeGroups()
setTreeGroup(treeId, groupId)
renameGroup(groupId, newName)
getTreeName(treeId)
save()
finishAndGetNextTask()
restart(newAnnotationType, newAnnotationId, newControlMode, versions)
hardReload()
setNodeRadius(delta, nodeId, treeId)
centerNode
centerTDView
measureTreeLength(treeId)
measureAllTrees()
measurePathLengthBetweenNodes(sourceNodeId, targetNodeId)
centerPositionAnimated(position, skipDimensions, rotation)
getCameraPosition()
setCameraPosition(position)
getActiveCellId()
setActiveCell(id)
getAnnotationTool()
setAnnotationTool(tool)
getVolumeTool()
setVolumeTool(tool)
downsampleSegmentation()

All binary data / layer related API methods.

new DataApi(model: OxalisModel)
Parameters
model (OxalisModel)
Example
window.webknossos.apiReady(3).then(api => {
  api.data.getLayerNames();
  api.data.reloadBuckets(...);
  ...
}
Instance Members
getLayerNames()
getVolumeTracingLayerName()
reloadBuckets(layerName)
reloadAllBuckets()
setMapping(layerName, mapping, options)
setMappingEnabled(isEnabled)
getMappingNames(layerName)
getActiveMapping()
activateMapping(mappingName, mappingType)
isMappingEnabled()
getBoundingBox(layerName)
getDataValue(layerName, position, _zoomStep)
downloadRawDataCuboid(layerName, topLeft, bottomRight)
labelVoxels(voxels, label)
getConfiguration(key)
setConfiguration(key, value)

All user configuration related API methods.

new UserApi(model: OxalisModel)
Parameters
model (OxalisModel)
Example
window.webknossos.apiReady(3).then(api => {
  api.user.getConfiguration(...);
  api.user.setConfiguration(...);
  ...
}
Instance Members
getConfiguration(key)
setConfiguration(key, value)

Utility API methods to control wK.

new UtilsApi(model: OxalisModel)
Parameters
model (OxalisModel)
Example
window.webknossos.apiReady(3).then(api => {
  api.utils.sleep(...);
  api.utils.showToast(...);
  ...
}
Instance Members
sleep(milliseconds)
showToast(type, message, timeout)
registerOverwrite(actionName, overwriteFunction)
registerKeyHandler(key, handler)