Max JS API
Reference for the API available within the [js], [jsui], [v8], [v8.codebox], and [v8ui] objects
Some classes and interfaces are only available with the v8 engine. For more information, refer to the JavaScript Documentation
Globals
| Item | Engine | Description |
|---|---|---|
| console | v8 | The global console instance, the Max-console-backed console object exposed by the v8 runtime. |
| globalThis | The "this" object in the context of JavaScript in Max. The object is the "this" within the context of any function you define that can be invoked from Max, as well as in your global code. See jsthis for more details. | |
| Jitter3DUtils | The global Jitter3DUtils interface, providing utility functions for 3D vector and matrix operations. See Jitter3dUtilsInterface for more details. | |
| max | Singleton Max object to access and control the Max environment. See Max for more details. In addition to the properties and methods described here, you can also use the global Max object to call methods as defined in Controlling Max with Messages | |
| mgraphics | The global mgraphics instance, for rendering shapes and images in custom Max objects. | |
| sketch | The global sketch instance, for drawing in custom Max objects with an OpenGL-backed drawing context. |
Functions
| Item | Engine | Description |
|---|---|---|
| clearImmediate | v8 | Cancels an immediate previously created with setImmediate(). |
| clearInterval | v8 | Cancels an interval previously created with setInterval(). |
| clearTimeout | v8 | Cancels a timeout previously created with setTimeout(). |
| cpost | Prints a message to the system console window. See post() for more details about arguments and formatting. | |
| error | Prints a message to the Max console with a red tint. See post() for more details about arguments and formatting. | |
| fetch | v8 | Fetches a resource over HTTP or HTTPS. |
| messnamed | Sends a message to the named Max object. | |
| post | Prints a representation of the arguments in the Max window. | |
| queueMicrotask | v8 | Queues a microtask to run after the current task completes and before the next timer callback. |
| setImmediate | v8 | Schedules a callback to run on the next scheduler tick. |
| setInterval | v8 | Schedules a callback to run repeatedly at a fixed interval. |
| setTimeout | v8 | Schedules a one-shot callback to run after a delay. |
Built-In Modules
| Item | Engine | Description |
|---|---|---|
| buffer | v8 | The buffer module exposed by require("buffer"), providing the buffer.IOBuffer class for handling binary data. |
| dgram | v8 | The dgram module exposed by require("dgram"). |
| http | v8 | The http module exposed by require("http") to access HTTP/1.1 clients and servers.This is a minimal http subset, not full Node parity. |
| https | v8 | The https module exposed by require("https"). Mirrors http over TLS, defaulting to https: URLs. |
| net | v8 | The net module exposed by require("net") providing TCP client and server sockets. |
| tls | v8 | The tls module exposed by require("tls"): TLS/SSL client and server sockets. |
Classes
| Item | Engine | Description |
|---|---|---|
| AbortController | v8 | Creates an AbortSignal and the means to abort it. |
| AbortSignal | Signals abortion to abortable operations such as fetch(). | |
| Blob | v8 | An immutable blob of binary data with a MIME type. |
| Buffer | Bind to a Max buffer~ object. | |
| Dict | Bind to a Max dict object. | |
| EventSource | v8 | A Server-Sent Events client. |
| File | The File object provides a means of reading and writing files from JavaScript. | |
| Folder | Iterate through the files in a folder. | |
| FormData | v8 | A multipart/form-data field set. |
| Global | Global object for sharing data between Max JavaScript instances. | |
| Headers | v8 | A case-insensitive multimap of HTTP headers. |
| Image | Bitmap image object handle | |
| JitterListener | A listener for changes in a JitterObject. | |
| JitterMatrix | A named matrix which may be used for data storage and retrieval, resampling, and matrix type and planecount conversion operations. | |
| JitterObject | A JavaScript representation of a Jitter object in a patcher. | |
| LiveAPI | A means of communicating with the Live API from JavaScript. | |
| MaxArray | Bind a Max array object | |
| MaxFFT | Fast Fourier Transform processor | |
| MaxFFT2D | Two-dimensional Fast Fourier Transform processor | |
| Maxobj | A JavaScript representation of a Max object in a patcher. | |
| MaxobjListener | A listener for changes in a Maxobj object. | |
| MaxString | Bind a Max string object | |
| MGraphics | Drawing context for rendering shapes and images. | |
| MGraphicsSVG | SVG object handle | |
| ParameterInfoProvider | Provides a list of named parameter objects within a patcher hierarchy as well as information about specific parameter objects. It can also notify when parameter objects are added or removed from a patcher hierarchy. | |
| ParameterListener | A listener for changes in named parameters. | |
| Patcher | A JavaScript representation of a Max patcher. | |
| PolyBuffer | Bind to a Max polybuffer~ object. | |
| ReadableStream | v8 | A byte-oriented readable stream. Used for Response.body and as a streamed request body. |
| Request | v8 | A request to be sent with fetch(). |
| Response | v8 | A response returned by fetch(). |
| Rx256 | Xoxhiro256+ random number generator | |
| Sketch | Interface to an OpenGL-backed drawing context | |
| SnapshotAPI | Provides access to patcher snapshots. | |
| SQLite | Provides access to the SQLite database system. | |
| SQLResult | A container for results obtained in an SQLite.exec() call. | |
| Task | A function that can be scheduled or repeated. | |
| TextDecoder | v8 | Decodes UTF-8 bytes into a JavaScript string. |
| TextEncoder | v8 | Encodes JavaScript strings into UTF-8 bytes. |
| TransformStream | v8 | A byte-oriented transform stream pairing a writable input with a readable output. |
| URL | v8 | Parses and manipulates URLs. |
| URLSearchParams | v8 | Reads and manipulates URL query strings. |
| WebSocket | v8 | A WebSocket client. |
| WebSocketServer | v8 | A WebSocket server. |
| WritableStream | v8 | A byte-oriented writable stream companion for piping. |
| XMLHttpRequest | XMLHttpRequest provides HTTP client functionality for making network requests from JavaScript in Max. |
Interfaces
| Item | Engine | Description |
|---|---|---|
| AddressInfo | The local or remote endpoint of a socket, as returned by address(). | |
| AttributeOptions | Options accepted by the v8-only forms of declareattribute, describing how an attribute is typed, stored, and presented. | |
| Console | The Max-console-backed console object exposed by the v8 runtime. Output is routed to the Max console: log, info, and debug use normal post rows, warn uses warning rows, and error, assert, and trace use error rows.Formatting is a pragmatic subset: string joining, Error stack/message rendering, JSON-ish object rendering with a circular fallback, and the %s, %d, %i, %f, %j, %o, %O, and %% format tokens. Full Node util.inspect, console.table, grouping, profiling, and configurable output streams are not implemented. | |
| EventSourceMessageEvent | An event delivered to an EventSource. | |
| Jitter3dUtilsInterface | Utilities for Jitter 3D manipulations | |
| JitterEvent | The argument passed to a JitterListener callback function. | |
| jsthis | The "this" object in the context of JavaScript in Max | |
| Max | Interface representing the current Max environment providing access and control. | |
| MaxFFT2DOptions | Options for constructing a MaxFFT2D instance. | |
| MaxFFTOptions | Options for constructing a MaxFFT instance. | |
| MaxobjConnection | A JavaScript representation of a patchcord connection. | |
| MaxobjListenerData | The argument provided to a MaxobjListener callback function. | |
| NetworkError | Networking Error The shape of Error objects delivered to networking 'error' callbacks and promise rejections across fetch(), the net/tls/dgram modules, the http/https modules, WebSocket, and EventSource. | |
| ParameterInfoProviderData | The argument to the ParameterInfoProvider's callback function | |
| ParameterListenerData | The argument provided to a ParameterListener callback function. | |
| Pattern | Pattern object for drawing gradients and patterns. | |
| PointerEvent | Pointer event object passed to onpointer* event handlers | |
| ProgressEvent | ProgressEvent provides information about the progress of a network request. | |
| ReadableStreamDefaultReader | A reader that pulls chunks from a ReadableStream. | |
| ReadableStreamReadResult | The result of a single ReadableStreamDefaultReader.read() call. | |
| RequestInit | Options accepted by fetch() and the Request constructor. | |
| WebSocketCloseEvent | A close event delivered to a WebSocket. | |
| WebSocketConnection | A server-side WebSocket connection accepted by a WebSocketServer. | |
| WebSocketErrorEvent | An error event delivered to a WebSocket. | |
| WebSocketMessageEvent | A message event delivered to a WebSocket. | |
| Wind | A property of the Patcher which represents its window. | |
| WritableStreamDefaultWriter | A writer that pushes chunks to a WritableStream. | |
| XMLHttpRequestUpload | v8 | The upload object of an XMLHttpRequest, exposing progress events for the request body. |
Type Aliases
| Item | Description |
|---|---|
| Basic2dStrokeStyleParameterNames | Stroke parameters for use with Sketch.beginstroke() in the "basic2d" drawing style |
| BodyInit | Acceptable values for an outgoing request or response body. |
| DrawingPrimitiveType | Primitive type to use for drawing shapes. See Sketch.shapeprim(). |
| FileAccess | File access type Used with File |
| FileEndianness | File endianness Used with File |
| FileFourCharacterCode | Four character file codes. Used with File |
| FileLineEndingStyle | File line ending style Used with File |
| HeadersInit | Acceptable initializers for Headers. |
| Jitter3dUtilsMat16 | A 4x4 matrix Used with Jitter3dUtilsInterface |
| Jitter3dUtilsVec3 | A 3D vector Used with Jitter3dUtilsInterface |
| Jitter3dUtilsVec4 | A 4D vector Used with Jitter3dUtilsInterface |
| JitterEventType | Event types Possible event types for a JitterEvent |
| LineStrokeStyleParameterNames | Stroke parameters for use with Sketch.beginstroke() in the "line" drawing style |
| MGraphicsMatrixHandle | Opaque handle for an MGraphics transformation matrix. |
| MGraphicsPathHandle | Opaque handle for an MGraphics path. |
| RequestCredentials | Credentials mode controlling cookie sending/storage for a request. |
| RequestRedirect | Redirect-following mode for a request. |