@run-cloud/sdk is the API-key client for iOS simulator sessions, Android
emulator sessions, microVM sandboxes, snapshots, account state, and reusable
app assets. It requires Node.js 20 or newer.
See the latest SDK reference for the complete class, method,
option, and response-type index.
Install
Authenticate
Create an API key in the run.cloud dashboard, then expose it to the process that runs your application:RUN_CLOUD_API_KEY automatically. You can also pass the key
directly when your application loads secrets another way:
RUN_CLOUD_API_URL or pass apiUrl to use a non-default API host. Do not
put API keys in source code, browser bundles, logs, or committed environment
files.
Run the complete example
The runnable example checks account access, creates iOS and Android sessions, opens a URL on each platform, and releases both sessions even when the run is interrupted or fails:Create and release sessions
Use the platform client when the platform is known. Always release metered sessions infinally so a failed test does not leave them running:
cloud.ios and cloud.android both provide:
The iOS client also provides:
screenshot(id), which returns PNG bytes as aUint8Array.uploadVideo(id, video, options), which accepts an MP4 or QuickTimeBloband imports it into Photos. The uploaded file remains incloud.assetsfor reuse or deletion.uploadMicrophoneAudio(id, audio, options), which accepts AAC, M4A, MP3, MP4-audio, or WAV and loops it through the foreground app’s microphone input. PassbundleIdwhen the intended app is not currently in front.
cloud.android.
Use the generic simulator client
Usecloud.simulators when the platform is selected at runtime. Pass the
session platform back to methods that operate on an existing session:
cloud.simulators.list() returns every platform unless platform is supplied. Other generic
simulator lifecycle methods default to iOS when platform is omitted.
Check account state
Useaccount() before starting a larger test matrix when you want to surface
access or organization information early:
Upload and reuse assets
Upload an artifact once, then reference its id from one or more sessions:cloud.assets provides upload, list, and delete. Artifact contents must
match the target platform: iOS needs a simulator-compatible build, while
Android needs an Android-compatible artifact such as an APK.
Handle API errors
Non-successful responses throwRunCloudError with the HTTP status and the API
detail: