Back to Novu

Plugin API Index

.agents/skills/figma-use/references/plugin-api-standalone.index.md

3.17.029.2 KB
Original Source

Plugin API Index

Full typings: plugin-api-standalone.d.ts (11,292 lines)
Grep by symbol name to jump to definition. All L# line numbers refer to that file.


figma.* — PluginAPI (L24)

Identity & State

MemberType
apiVersion'1.0.0'
editorType'figma' | 'figjam' | 'dev' | 'slides' | 'buzz'
mode'default' | 'textreview' | 'inspect' | 'codegen' | 'linkpreview' | 'auth'
fileKeystring | undefined
rootDocumentNode
currentPagePageNoderead-only; sync setter figma.currentPage = page does NOT work and throws; use await figma.setCurrentPageAsync(page) instead
currentUserUser | null
mixedunique symbol — sentinel for mixed values in selection
skipInvisibleInstanceChildrenboolean
MethodReturns
setCurrentPageAsync(page)Promise<void>MUST use this; sync setter figma.currentPage = page does NOT work
getNodeByIdAsync(id)Promise<BaseNode | null>
getNodeById(id)BaseNode | null
getStyleByIdAsync(id)Promise<BaseStyle | null>
getStyleById(id)BaseStyle | null

Create Nodes

MethodReturns
createFrame()FrameNode
createAutoLayout(direction?)FrameNode
createComponent()ComponentNode
createComponentFromNode(node)ComponentNode
createRectangle()RectangleNode
createEllipse()EllipseNode
createLine()LineNode
createPolygon()PolygonNode
createStar()StarNode
createVector()VectorNode
createText()TextNode
createSection()SectionNode
createPage()PageNode
createSlice()SliceNode
createBooleanOperation()BooleanOperationNode
createTable(rows?, cols?)TableNode
createImage(data: Uint8Array)Image
createNodeFromSvg(svg)FrameNode
createNodeFromJSXAsync(jsx)Promise<SceneNode>
importComponentByKeyAsync(key)Promise<ComponentNode>
importComponentSetByKeyAsync(key)Promise<ComponentSetNode>
importStyleByKeyAsync(key)Promise<BaseStyle>

Styles (Local)

MethodReturns
createPaintStyle()PaintStyle
createTextStyle()TextStyle
createEffectStyle()EffectStyle
createGridStyle()GridStyle
getLocalPaintStyles() / AsyncPaintStyle[]
getLocalTextStyles() / AsyncTextStyle[]
getLocalEffectStyles() / AsyncEffectStyle[]
getLocalGridStyles() / AsyncGridStyle[]

Fonts

MethodNotes
loadFontAsync(fontName)MUST call before any text edit
listAvailableFontsAsync()Promise<Font[]>
hasMissingFontboolean

Plugin Lifecycle

MethodNotes
closePlugin(message?)Auto-called; use return instead to pass results back
closePluginWithFailure(message?)Auto-called on errors; do not call manually
commitUndo()Snapshot to undo history
triggerUndo()Revert to last snapshot
saveVersionHistoryAsync(title, desc?)Promise<VersionHistoryResult>
notify(message, options?)throws "not implemented" in use_figma — do not use
openExternal(url)Opens URL in browser

Sub-APIs (properties on figma)

PropertyInterfaceL#
figma.variablesVariablesAPIL2016
figma.uiUIAPIL2604
figma.utilUtilAPIL2691
figma.constantsConstantsAPIL2809
figma.clientStorageClientStorageAPIL2531
figma.viewportViewportAPIL3086
figma.parametersParametersAPIL3292
figma.teamLibraryTeamLibraryAPIL2372
figma.annotationsAnnotationsAPIL2187
figma.codegenCodegenAPIL2871
figma.textreview?TextReviewAPIL3166
figma.payments?PaymentsAPIL2420
figma.buzzBuzzAPIL2211
figma.timer?TimerAPI (FigJam only)L3053

VariablesAPI — figma.variables (L2016)

getVariableByIdAsync(id)                 Promise<Variable | null>    ← preferred; sync deprecated
getVariableCollectionByIdAsync(id)       Promise<VariableCollection | null>    ← preferred; sync deprecated
getLocalVariablesAsync(type?)            Promise<Variable[]>         ← preferred; filter by VariableResolvedDataType; sync deprecated
getLocalVariableCollectionsAsync()       Promise<VariableCollection[]>    ← preferred; sync deprecated
createVariable(name, collection, type)   Variable
createVariableCollection(name)           VariableCollection
createVariableAlias(variable)            VariableAlias
importVariableByKeyAsync(key)            Promise<Variable>
setBoundVariableForPaint(paint, field, variable)    → returns NEW paint — reassign
setBoundVariableForEffect(effect, field, variable)  → returns NEW effect — reassign
setBoundVariableForLayoutGrid(grid, field, variable)

Variable (L10204): name, resolvedType, codeSyntax, scopes, hiddenFromPublishing, valuesByMode, variableCollectionId

  • setVariableCodeSyntax(platform, value) — platform: 'WEB' | 'ANDROID' | 'iOS'
  • setValueForMode(collectionId, modeId, value)
  • remove()

VariableCollection (L10418): name, modes, variableIds, defaultModeId, hiddenFromPublishing

  • addMode(name)modeId; removeMode(modeId); renameMode(modeId, name)

Node Types

Concrete Scene Nodes

NodeL#Key characteristics
DocumentNodeL8960Root; children: PageNode[]
PageNodeL9119children, local styles, backgrounds
FrameNodeL9311DefaultFrameMixin — auto-layout, clips, children
GroupNodeL9321Children only, no auto-layout
ComponentNodeL9678Like Frame + publishable
ComponentSetNodeL9653Variant set container
InstanceNodeL9719Like Frame; mainComponent, detach()
RectangleNodeL9378DefaultShapeMixin + corners
EllipseNodeL9410+ arcData
LineNodeL9396
PolygonNodeL9430
StarNodeL9450
VectorNodeL9476Vector paths
TextNodeL9493Rich text, fonts, segments
TextPathNodeL9564Text along path
BooleanOperationNodeL9792booleanOperation property
SliceNodeL9368Export only
SectionNodeL10754Grouping + fills
TableNodeL9862TableCellNode children

FigJam only: StickyNode L9812, ConnectorNode L10121, ShapeWithTextNode L9999, StampNode L9838, CodeBlockNode L10080, EmbedNode L10661, LinkUnfurlNode L10701, MediaNode L10721

Slides only: SlideNode L10784, SlideRowNode L10809, SlideGridNode L10822

Union types:

type SceneNode  (L10917) = FrameNode | GroupNode | SliceNode | RectangleNode | LineNode
  | EllipseNode | PolygonNode | StarNode | VectorNode | TextNode | ComponentSetNode
  | ComponentNode | InstanceNode | BooleanOperationNode | SectionNode | ...
type BaseNode   (L10913) = DocumentNode | PageNode | SceneNode

Mixin Interfaces

MixinL#Provides
BaseNodeMixinL5284id, name, type, parent, remove(), plugin data
SceneNodeMixinL5561visible, locked, opacity, variable bindings
ChildrenMixinL5773children, appendChild(), insertChild(), findAll(), findOne(), findAllWithCriteria()
LayoutMixinL6135x, y, width, height, rotation, resize(), rescale()
AutoLayoutMixinL6436layoutMode, axis alignment, padding, itemSpacing, layoutSizingHorizontal/Vertical
AutoLayoutChildrenMixinL7064layoutAlign, layoutGrow, sizing — set AFTER appendChild()
GridLayoutMixinL6939CSS Grid tracks, gap, template
GridChildrenMixinL7127grid child positioning
GeometryMixinL7485fills, strokes, strokeWeight, strokeAlign
MinimalFillsMixinL7328fills only
MinimalStrokesMixinL7246strokes, strokeWeight
BlendMixinL6339opacity, blendMode, isMask, effects
CornerMixinL7537cornerRadius, cornerSmoothing
RectangleCornerMixinL7560Per-corner radii
ExportMixinL7577exportSettings, exportAsync()
ReactionMixinL7704reactions (prototyping)
PublishableMixinL7875description, key, getPublishStatusAsync()
VariantMixinL8182variantProperties
ComponentPropertiesMixinL8229componentProperties, addComponentProperty()
PluginDataMixinL5443getSharedPluginData(), setSharedPluginData() supported; getPluginData(), setPluginData() NOT supported
FramePrototypingMixinL7651overflowDirection, numberOfFixedChildren
BaseFrameMixinL7939ChildrenMixin + LayoutMixin + AutoLayoutMixin + GeometryMixin + …
DefaultFrameMixinL7997BaseFrameMixin + FramePrototypingMixin + ReactionMixin
DefaultShapeMixinL7928BlendMixin + GeometryMixin + LayoutMixin + ExportMixin + ReactionMixin
ExplicitVariableModesMixinL9084setExplicitVariableModeForCollection()

Paint & Fill (L4302)

TypeL#Notes
SolidPaintL4302type:'SOLID', color: RGB, opacity, visible, blendMode
GradientPaintL4357type: 'GRADIENT_LINEAR|RADIAL|ANGULAR|DIAMOND', gradientStops: ColorStop[]
ImagePaintL4377type:'IMAGE', imageHash, scaleMode
VideoPaintL4413type:'VIDEO'
PatternPaintL4449type:'PATTERN'
type PaintL4481Union of all five
ColorStopL4271{ position: number, color: RGBA }
ImageFiltersL4290exposure, contrast, saturation, etc.

CRITICAL: Fills/strokes are read-only arrays — clone, modify, reassign.


Effects (L3966)

TypeL#
DropShadowEffectL3966
InnerShadowEffectL4009
BlurEffect (Normal/Progressive)L4048
NoiseEffect (Mono/Duo/Multitone)L4105
TextureEffectL4180
GlassEffectL4209
type EffectL4250

Typography

TypeL#Notes
FontNameL3697{ family: string, style: string }
TextNodeL9493characters, textAlignHorizontal, fontSize, fontName, getStyledTextSegments()
StyledTextSegmentL4882Per-range text properties
LetterSpacingL4826{ value, unit: 'PIXELS'|'PERCENT' }
LineHeightL4830{ value, unit } | { unit: 'AUTO' }
TextCaseL3701'ORIGINAL'|'UPPER'|'LOWER'|'TITLE'|'SMALL_CAPS'
TextDecorationL3702'NONE'|'UNDERLINE'|'STRIKETHROUGH'
OpenTypeFeatureL3728Ligatures, numerals, etc.

Variables & Bindings

TypeL#Notes
VariableL10204Core variable object
VariableCollectionL10418Collection of variables + modes
VariableAliasL10172Reference to another variable
VariableValueL10176boolean | string | number | RGB | RGBA | VariableAlias
VariableResolvedDataTypeL10171'BOOLEAN' | 'COLOR' | 'FLOAT' | 'STRING'
VariableDataTypeL5023Includes 'VARIABLE_ALIAS' | 'EXPRESSION'
VariableScopeL10177Where variable can be applied
CodeSyntaxPlatformL10203'WEB' | 'ANDROID' | 'iOS'
VariableBindableNodeFieldL5712Node fields that accept variable binding
VariableBindableTextFieldL5739Text-specific bindable fields
VariableBindablePaintFieldL5748'color'
VariableBindableEffectFieldL5751'color'|'radius'|'spread'|'offsetX'|'offsetY'

Styles

InterfaceL#Notes
BaseStyleMixinL10977name, id, key, type, description, remove()
PaintStyleL11002type:'PAINT', paints: Paint[]
TextStyleL11018type:'TEXT', font properties
EffectStyleL11087type:'EFFECT', effects: Effect[]
GridStyleL11103type:'GRID', layoutGrids
type BaseStyleL11119Union of all four
type StyleTypeL10955'PAINT' | 'TEXT' | 'EFFECT' | 'GRID'

Primitives & Geometry

TypeL#Shape
VectorL3667{ x: number, y: number }
RectL3671{ x, y, width, height }
RGBL3680{ r, g, b }0–1 range, not 0–255
RGBAL3688{ r, g, b, a }0–1 range
TransformL3666[[a,b,tx],[c,d,ty]] 2×3 affine matrix
ArcDataL3958{ startingAngle, endingAngle, innerRadius }
ConstraintsL4264{ horizontal, vertical }: ConstraintType
ConstraintTypeL4260'MIN'|'CENTER'|'MAX'|'STRETCH'|'SCALE'
VectorPathL4792{ windingRule, data: string }
VectorNetworkL4775vertices + segments + regions
GuideL4482{ axis, offset }

Prototyping

TypeL#Notes
ReactionL5015trigger + action pair
TriggerL5146what initiates the reaction
ActionL5064what happens
TransitionL5145SimpleTransition | DirectionalTransition
EasingL5182easing curve definition
NavigationL5178'NAVIGATE'|'SWAP'|'OVERLAY'|'SCROLL_TO'|'CHANGE_TO'
OverflowDirectionL5215'NONE'|'HORIZONTAL'|'VERTICAL'|'BOTH'
OverlayPositionTypeL5219overlay placement

Events & Changes

TypeL#Notes
ArgFreeEventTypeL11'selectionchange'|'currentpagechange'|'close'|timer events
RunEventL3321plugin run with parameters
DropEventL3339drag-and-drop
DocumentChangeEventL3359any document change
NodeChangeEventL3626node property changes
NodeChangePropertyL3499all watchable property names
StyleChangeEventL3365style create/delete/update
DocumentChangeL3489CreateChange | DeleteChange | PropertyChange
TextReviewEventL3657text review mode

Export

TypeL#Notes
ExportSettingsImageL4561PNG/JPG/WEBP/BMP
ExportSettingsSVGL4634
ExportSettingsPDFL4653
ExportSettingsRESTL4667
ExportSettingsConstraintsL4554{ type: 'SCALE'|'WIDTH'|'HEIGHT', value }

Key Sub-API Surfaces

ClientStorageAPI (L2531): getAsync(key), setAsync(key, value), keysAsync(), deleteAsync(key)

ViewportAPI (L3086): center: Vector, zoom: number, scrollAndZoomIntoView(nodes), bounds: Rect

UtilAPI (L2691): solidPaint(hex, opacity?), rgba(r,g,b,a?), rgb(r,g,b), colorToHex(color), loadImageAsync(url), clone(val)

TeamLibraryAPI (L2372): getAvailableLibraryVariableCollectionsAsync(), importVariableByKeyAsync(key)

Image (L11120): hash, getBytesAsync(), getSizeAsync()


All Symbols (flat — grep these against the .d.ts file)

To find any symbol: grep -n "^interface Foo\|^type Foo\|^declare type Foo" plugin-api-standalone.d.ts

PluginAPI               VariablesAPI            AnnotationsAPI          TeamLibraryAPI
UIAPI                   UtilAPI                 ViewportAPI             ClientStorageAPI
ConstantsAPI            CodegenAPI              PaymentsAPI             TextReviewAPI
ParametersAPI           TimerAPI                BuzzAPI                 DevResourcesAPI

DocumentNode            PageNode                FrameNode               GroupNode
ComponentNode           ComponentSetNode        InstanceNode            RectangleNode
EllipseNode             LineNode                PolygonNode             StarNode
VectorNode              TextNode                TextPathNode            BooleanOperationNode
SliceNode               SectionNode             TableNode               TableCellNode
StickyNode              ConnectorNode           ShapeWithTextNode       StampNode
CodeBlockNode           EmbedNode               LinkUnfurlNode          MediaNode
WidgetNode              SlideNode               SlideRowNode            SlideGridNode
TransformGroupNode      HighlightNode           WashiTapeNode

BaseNodeMixin           SceneNodeMixin          ChildrenMixin           LayoutMixin
AutoLayoutMixin         AutoLayoutChildrenMixin GridLayoutMixin         GridChildrenMixin
GeometryMixin           MinimalFillsMixin       MinimalStrokesMixin     BlendMixin
MinimalBlendMixin       CornerMixin             RectangleCornerMixin    ExportMixin
ReactionMixin           PublishableMixin        VariantMixin            ComponentPropertiesMixin
PluginDataMixin         DevResourcesMixin       DevStatusMixin          StickableMixin
ConstraintMixin         DimensionAndPositionMixin AspectRatioLockMixin  FramePrototypingMixin
BaseFrameMixin          DefaultFrameMixin       DefaultShapeMixin       OpaqueNodeMixin
VectorLikeMixin         ComplexStrokesMixin     IndividualStrokesMixin  ContainerMixin
AnnotationsMixin        MeasurementsMixin       ExplicitVariableModesMixin

Variable                VariableCollection      VariableAlias           ExtendedVariableCollection
LibraryVariableCollection LibraryVariable
VariableValue           VariableResolvedDataType VariableDataType       VariableScope
CodeSyntaxPlatform      VariableBindableNodeField VariableBindableTextField
VariableBindablePaintField VariableBindableEffectField VariableBindableLayoutGridField

SolidPaint              GradientPaint           ImagePaint              VideoPaint
PatternPaint            Paint                   ColorStop               ImageFilters
DropShadowEffect        InnerShadowEffect       BlurEffect              NoiseEffect
TextureEffect           GlassEffect             Effect
LayoutGrid              RowsColsLayoutGrid      GridLayoutGrid

PaintStyle              TextStyle               EffectStyle             GridStyle
BaseStyle               BaseStyleMixin          StyleType

FontName                Font                    LetterSpacing           LineHeight
TextCase                TextDecoration          TextDecorationStyle     FontStyle
OpenTypeFeature         StyledTextSegment       LeadingTrim

Vector                  Rect                    RGB                     RGBA
Transform               ArcData                 Constraints             ConstraintType
VectorPath              VectorNetwork           VectorVertex            VectorSegment
VectorRegion            Guide                   BlendMode               MaskType

Reaction                Trigger                 Action                  Transition
Easing                  Navigation              OverflowDirection       OverlayPositionType
OverlayBackground       PublishStatus

ArgFreeEventType        RunEvent                DropEvent               DocumentChangeEvent
NodeChangeEvent         NodeChangeProperty      StyleChangeEvent        DocumentChange
TextReviewEvent         SlidesViewChangeEvent   CanvasViewChangeEvent

ExportSettingsImage     ExportSettingsSVG       ExportSettingsPDF       ExportSettingsREST
ExportSettingsConstraints

User                    ActiveUser              BaseUser                Image
Video                   VersionHistoryResult    FindAllCriteria

Additional APIs (available via use_figma)

Node Methods

Method / PropertyReturns / TypeDescription
node.query(selector)QueryResultCSS-like selector search within subtree
node.matches(selector)booleanTest if node matches a selector
node.set(props)thisSet multiple properties at once, chainable
await node.screenshot(opts?)Promise<void>Capture PNG inline in tool response
node.placeholderbooleanShow/hide shimmer overlay

figma.io Namespace

MethodReturnsDescription
figma.io.write(path, data)voidWrite image/data to be returned in tool response

Types

TypeDescription
QueryResultIterable result from node.query() with .first(), .last(), .each(), .map(), .filter(), .values(), .set(), .query()
ScreenshotOptions{ scale?: number, contentsOnly?: boolean }