Skip to content

API Reference

Complete API documentation for Annota, supporting both React and Svelte.

Choose your framework to view framework-specific APIs:

React Hooks

Hooks for accessing annotations, selection, and tools. View Hooks →

These APIs are identical for both React and Svelte:

Tools

Built-in annotation tools (PointTool, RectangleTool, etc.). View Tools →

These types are shared between React and Svelte.

interface Annotation {
id: string;
shape: Shape;
properties?: Record<string, unknown>;
style?: AnnotationStyle;
}
type Shape =
| PointShape
| RectangleShape
| PolygonShape
| MultiPolygonShape
| CircleShape
| LineShape
| FreehandShape
| PathShape
| ImageShape;

PointShape:

interface PointShape {
type: "point";
point: { x: number; y: number };
bounds: Bounds;
}

RectangleShape:

interface RectangleShape {
type: "rectangle";
x: number;
y: number;
width: number;
height: number;
bounds: Bounds;
}

PolygonShape:

interface PolygonShape {
type: "polygon";
points: Array<{ x: number; y: number }>;
closed: boolean;
bounds: Bounds;
}
interface AnnotationStyle {
fill?: string;
fillOpacity?: number;
stroke?: string;
strokeWidth?: number;
strokeOpacity?: number;
}
interface Layer {
id: string;
name: string;
visible: boolean;
opacity?: number;
locked?: boolean;
filter?: Filter;
style?: AnnotationStyle;
}

Annota includes several annotation tools (shared between frameworks):

import { PointTool, RectangleTool, PolygonTool } from "annota";
const pointTool = new PointTool();
const rectangleTool = new RectangleTool();
const polygonTool = new PolygonTool();

See the Tools Guide for detailed usage.

import { loadH5Masks, loadH5Coordinates } from "annota";
import { loadJSONFile, exportJSON } from "annota";

See the Loaders Guide for more details.

HookPurpose
useAnnotator()Access annotator instance
useAnnotations()Get all annotations
useSelection()Get selected annotations
useTool()Activate annotation tool
useLayers()Get all layers
useLayerManager()Manage layers
StorePurpose
getAnnotator()Access annotator instance
annotations()Get all annotations
selection()Get selected annotations
tool()Activate annotation tool
layers()Get all layers
layerManager()Manage layers
ComponentReactSvelte
ProviderAnnotaProviderAnnotaProvider
ViewerAnnotaViewerViewer
AnnotatorAnnotatorAnnotator
PopupAnnotationPopupPopup
Context MenuContextMenuContextMenu