Skip to content

Using the SDK

Quick Start

  1. Set the FOREVERVM_TOKEN environment variable:

    FOREVERVM_TOKEN=***
  2. Connect to a machine and run some code:

    from forevervm_sdk import Repl
    with Repl() as repl:
    instruction = repl.exec('4 + 4')
    print(instruction["result"])

Example

Below, you can see a short example of how to use the ForeverVM SDK.

import os
from forevervm_sdk import ForeverVM
token = os.getenv('FOREVERVM_TOKEN')
# Initialize ForeverVM
fvm = ForeverVM(token)
# Connect to a new machine
with fvm.repl() as repl:
# Execute some code
exec_result = repl.exec('4 + 4')
# Get the result
print('result:', exec_result.result)
# Execute code with output
exec_result = repl.exec('for i in range(10):\n print(i)')
for output in exec_result.output:
print(output["stream"], output["data"])

Reference

Continue to the next section to see a reference of the SDK classes and methods.