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

const client = new Riza({
  apiKey: process.env['RIZA_API_KEY'], // This is the default and can be omitted
});

async function main() {
  const response = await client.command.execFunc({
    code: 'def execute(input): return { "name": input["name"], "executed": True }',
    language: 'python',
  });

  console.log(response.execution);
}

main();
{
  "output": {
    "name": "John",
    "executed": true
  },
  "output_status": "valid",
  "execution": {
    "exit_code": 0,
    "stdout": "",
    "stderr": ""
  }
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

application/json
code
string
required

The function to execute. Your code must define a function named "execute" that takes in a single argument and returns a JSON-serializable value.

language
enum<string>
required

The interpreter to use when executing code.

Available options:
python,
javascript,
typescript
env
object

Set of key-value pairs to add to the function's execution environment.

files
object[]

List of input files.

http
object

Configuration for HTTP requests and authentication.

input
any

The input to the function. This must be a valid JSON-serializable object. If you do not pass an input, your function will be called with None (Python) or null (JavaScript/TypeScript) as the argument.

limits
object

Configuration for execution environment limits.

runtime_revision_id
string

The ID of the runtime revision to use when executing code.

Response

200
application/json
OK
execution
object
required
output
any
required

The output of the function.

output_status
enum<string>
required

The status of the output. "valid" means your function executed successfully and returned a valid JSON-serializable object, or void. "json_serialization_error" means your function executed successfully, but returned a nonserializable object. "error" means your function failed to execute.

Available options:
error,
json_serialization_error,
valid