Skip to main content
You can use the require method to import preloaded libraries or global helpers directly inside your Requestly Script Tab in API Client requests. The script environment supports JavaScript-based transformations, validations, and dynamic request logic for HTTP and GraphQL APIs.

require

The require method lets you import supported modules into your script. Declare the result as a variable to access functions or objects from that module.

Syntax

If the module provides functions or objects, assign it to a variable as shown above.

Example

Use Global Objects

Requestly script sandbox provides several global variables and utilities you can access directly.

Available Globals

Use External Libraries

The require method enables you to use preloaded libraries in the Requestly script environment. All supported modules are sandboxed for safe execution.

Supported Libraries

The following external libraries are available:
Coming Soon: We’re adding support to let users import and use libraries directly from npm and jsr, giving even more flexibility to extend Requestly scripts.

If you need immediate support for any specific library, feel free to comment on our GitHub issue and we’ll prioritize adding it.
Example

Use Built-in Globals

Requestly also provides a few helper functions and contextual variables for working with request and response data.

Examples

Notes

  • In addition to the libraries listed above, a set of Node.js built-in modules (such as crypto, buffer, path, url, util, and stream) is available via require().
  • No installation or internet access is needed, all libraries are pre-bundled within the Requestly scripting environment.
  • The sandbox is isolated for security; access to system-level Node APIs or network calls from require() is restricted.
These restrictions apply in Safe Mode, the default. If a package needs a native add-on, file-system access, or asymmetric cryptography, switch the request to Developer Mode. See Script execution modes.