import Riza from '@riza-io/api';

const pythonCode = `
import requests

r = requests.get("https://api.ipify.org")
print(r.text)
`;

const riza = new Riza();

async function main() {
  const resp = await riza.command.exec({
    language: "PYTHON",
    code: pythonCode,
    allowHttpHosts: [
      "api.ipify.org",
    ],
  });
  console.log(resp);
}

main();
{
    "exit_code": 0,
    "stdout": "192.108.121.165",
}

Your script can send outbound HTTP requests using popular HTTP packages for your given language.

Send outbound HTTP requests

Currently only supported in our JavaScript and Python runtimes.

The execute code endpoint support outbound HTTP requests. By default, all HTTP requests are blocked. Allowed HTTP hosts must be specified in the API request.

Allowed host patterns

The allowed_http_host parameter supports two types of pattern matching.

  • * matches all hosts
  • *.example.com matches all subdomains of example.com, but not example.com itself
import Riza from '@riza-io/api';

const pythonCode = `
import requests

r = requests.get("https://api.ipify.org")
print(r.text)
`;

const riza = new Riza();

async function main() {
  const resp = await riza.command.exec({
    language: "PYTHON",
    code: pythonCode,
    allowHttpHosts: [
      "api.ipify.org",
    ],
  });
  console.log(resp);
}

main();
{
    "exit_code": 0,
    "stdout": "192.108.121.165",
}