This page is about the JavaScript interpreter environment inside the Riza Code Interpreter API. If you’re looking to call the API from Node, see the API Client Libraries guide.

Runtime

Our JavaScript engine is powered by Boa. TypeScript transpilation is handled automatically via swc.

Limitations

We inherit all the limitations of the Boa JavaScript engine, and in particular our interpreter is not Node or Deno. We are working on supplementing the Boa environment with node-compatible objects.

See our roadmap for planned future improvements.

Output

You can write to stdout and stderr with the typical console functions. Directly writing to process.stdout or process.stderr will not work, as both are undefined.

console.log("Hello, World!");
console.dir({"foo": "bar"});
console.error("Something went wrong");

Input

You can read from process.stdin, process.argv and process.env to get input data. Note that process.stdin is just a string, not a stream as it is in Node.

var input = process.stdin;
process.argv.forEach((a) => ...);
console.log(JSON.stringify(process.env));

HTTP

You can make HTTP requests using fetch.

const options = {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({foo: "bar"}),
};
const r = await fetch("https://httpbin.org/post", options);
const data = await r.json();
console.log(data.args.foo);

Network access is blocked by default, so you need to allow HTTP traffic to individual hosts using the allow_http_hosts parameter. See the HTTP guide for a full example.

Libraries

JSON

Both JSON.stringify() and JSON.parse() are available.