Scratch Extension Protocol (2.0)
- This article or section documents the current version of Scratch (version 2.0). For this article in Scratch 1.4, see Scratch Extension Protocol (1.4).
Scratch 2.0 Extension Protocol is an experimental extension feature that allows interaction between Scratch 2.0 and other programs.
Scratch 2.0 can be extended to control external devices (e.g. robotics kits, musical instruments) and to access data from external sensor hardware (e.g. sensor boards). A Scratch 2.0 extension extends Scratch with a collection of command and reporter blocks that can be used to interact with a particular device. When an extension is enabled, its blocks appear in the "More Blocks" palette.
Due to browser security restrictions, Scratch 2.0 cannot interact with hardware devices directly. Instead, hardware extensions come with a helper app, a separate application that the user must install and run on their computer. Scratch communicates with the helper app via HTTP requests, and the helper app talks to the hardware. In the future, some extensions may package their helper apps as browser plugins.
A document (last updated: September 2013) has been drafted for Scratch 2.0 extension developers to describe the extension description file format, the protocol used to communicate between Scratch extension helper apps, and the extension development process. This specification is still preliminary and may change.
The Scratch 2.0 extension mechanism is still under development. Eventually, the user will be able to browse and import extensions from a library of published extensions, just as they currently import costumes, backdrops, sprites and sounds from the Scratch media library, but that mechanism is not yet implemented. Meanwhile, to allow extension development and testing, a semi-hidden menu command in Scratch 2.0 Offline Editor can be used to import an extension from a local file.
An extension distribution strategy is still being worked out. The Scratch team will probably host a small library of "supported" extensions. Users will be able to browse and select extensions from this library from within the Scratch editor, and will be able to download the necessary helper app from the Scratch website. Supported extensions would be checked for quality and safety by the Scratch team. There are likely be strict criteria for including an extension in the Scratch-team supported extensions library, such as command set clarity and ease of use, size of the potential audience, widespread availability of any associated hardware, and a long-term commitment to support the extension.
To avoid potential confusion on the Scratch website, projects with unsupported extensions should only be used with the Scratch 2.0 Offline Editor and should be saved only locally, NOT uploaded to the website. Extension developers can share their extensions by distributing copies of the extension description file and helper app. Users would then use the "Import Experimental Extension" command in the Offline editor to import the extension.