You can access most of the Plugin API through the
figma global object. You’ll find properties and functions that allow you to view, create, and update the contents of files.
- View and update file-level properties, like thumbnails, undo history, and version history
- Create, copy, or combine layers
- Adjust properties of existing layers
- Create, use, and manage local styles
- Access users in the file
- Import styles and component from external libraries
figma global object is available in every Figma window. This means you can open the developer console in any file and access the API. This is a great way to explore the functionality of the API without having to create a plugin. You can also use this approach to test and debug your plugin code.
There are six other global objects available, you can access these from methods on the
figma global object:
figma.uito create a custom interface for your plugin
figma.timerto control the timer object in FigJam files
figma.viewportto control the viewport: the area of the canvas that’s visible on screen
figma.clientStorageto store data on a user’s local machine
figma.parametersto accept parameters as input
figma.textreviewto interact with features only available to text review plugins
There are also global variables available across the Plugin API:
If you assigned a file name to the
"ui" field in your
manifest.json file, you can use this variable to access the file’s contents.
figma.showUI(__html__) . As the HTML is in a separate file, your text editor will render the HTML with syntax highlighting.
If you assigned a map to the
"ui" field in your
you can use this variable to access each file's contents. You can then call
fetch(url: string, init?: FetchOptions): Promise<FetchResponse>
Fetch a resource from the network, and return a promise with the response.View more →