Adobe XD provides several categories of APIs:
APIs for interacting with XD itself, especially its document model, the scenegraph
The UXP runtime, which provides all the capabilities that aren't XD-specific:
- A browser-like HTML and CSS engine which drives actual XD native UI components -- it is not a complete browser engine, but lets you build your UI using familiar web APIs and frameworks.
- Network APIs similar to the web standard XHR,
fetch, and WebSocket found in browsers.
storageAPI, offering sandboxed filesystem access.
A simple module-loader
Read below for how to access XD and UXP APIs...
Most XD APIs are accessed by loading a module via
require(), but some are passed directly to your plugin's handler functions. See the XD specific APIs page for a full list of modules. Below are some examples of modules available via the API:
- selection - Indicates the selected nodes and related context
- This object is passed as an argument to your command handler function (see above)
- scenegraph - APIs available on document nodes
- Typically you use scenegraph objects by simply accessing the arguments passed to your command's handler function
- To create new nodes in the document, load this module explicitly to access the constructor functions:Copied to your clipboard1let Rectangle = require("scenegraph").Rectangle;2let node = new Rectangle();
- Typically you use scenegraph objects by simply accessing the arguments passed to your command's handler function (
- commands - Invoke commands to change the document structure and perform other complex operations.
let commands = require("commands");
- interactions - Data model for interactive prototyping features (also accessible from scenegraph nodes).
let interactions = require("interactions");
- application - APIs for exporting content, initiating edits from panel UI, and getting version / locale info.
let application = require("application");
- clipboard - Copy text to the clipboard.
let clipboard = require("clipboard");
HTML DOM APIs -- access just as in a browser, via the global
document. Each plugin in XD gets its own
Network APIs -- access just as in a browser, via the global classes
WebSocket, and the global function
Storage APIs -- access via
const fs = require("uxp").storage.localFileSystem;