A (Unpkg / CDN) module importer, and a request API


These scripts have been made for my own use, but you are welcome to use them as well.

The first is a request API that aims to be closer to fetch.

The API exposes POST, PUT and GET operations with the most common defaults (JSON content, etc.).


const { get, post, put } = importModule("requests");

// post, put and get also accept `headers`
const postResult = await post({ url: "https://...", body: {...} });

const putResult = await put({ url: "https://...", body: {...} });

const getResult = await get({ url: "https://..." });

You can get it here:


The second is a module requirement script that allows sourcing Unpkg or other CDN modules, and caches the modules on iCloud for future use.


const require = importModule("require");

// also accepts `forceDownload` to always use online version
const _ = await require({ moduleName: "lodash", url: "https://unpkg.com/lodash/lodash.min.js" });

// lodash.js is created in the Scriptable iCloud folder

// use _

The goal of this script is to allow you to embed third party libraries in your scripts easily and share them without having to source the actual libraries, and to be able to maintain / update third party scripts in Scriptable.

Note that the current implementation uses the Scriptable iCloud folder, but could be modified to use another folder.

An update script could also be created to download and maintain multiple modules.

The script is divided into 3 modules:




All three of which need to be added as scripts to use require.js.


This is very cool! Thanks for sharing! :smiley:

1 Like

Hi — I’m trying to figure out how to use a module from the web (at GitHub and non) in scriptable. This seems like it should work, but I’m clearly doing something wrong.

The github repo is at https://github.com/eemeli/yaml and the instructions for installing via npm (which I’m not sure will work here) is https://eemeli.org/yaml/#yaml

Any suggestions? Thanks!