Skip to main content

Simple API Example

This article demonstrates the steps required to run an API Example that completes the following:

  1. Log in to AVH.
  2. Retrieves the available projects on that account.
  3. Retrieves the available instances on the desired project.
  4. Creates a new instance of a virtual device.
  5. Uploads a custom kernel to that virtual device.
  6. Takes a snapshot of that virtual device.

Check out the Corellium API Documentation for a list of supported flavors and more.

Setting Up

There are two ways to get set up for this tutorial. You can either:

  1. Clone the entire Corellium-API GitHub Repository and run the example within your cloned repository.

  2. Or, you can clone the device_example folder and run the example on its own.

You will also need a device tree file to upload to your device. If you don't have one handy, install our example file and put it in the corellium-api/examples/device_example subdirectory.

Tutorial

  1. Run the following command inside the device_example directory:
npm install @corellium/corellium-api
  1. Now, in main.js replace the values assigned to the myEndPoint, myUserName, myPassword, and myProject variables with your account credentials and project name.
let myEndPoint = "https://app.avh.corellium.com";
let myUserName = "user@name.foo";
let myPassword = "<password>";
let myProject = "Example Project Name";
  1. Optionally, you can replace the values in myDeviceName, myFlavor, and myOS. Currently, the example creates a Ranchu (Generic Android) device named API Android with the 11.0.0 OS.
let myDeviceName = "API Android";
let myflavor = "ranchu";
let myOS = "11.0.0";
  1. Optionally, if you would like to upload a different image, edit myFirmware and myFirmwarePath.
let myfile = "devicetree";
let myfilePath = "/devicetree";
  1. If you would like to upload a different type of image, such as a kernel choose a different upload function.
// Upload the custom devicetree
console.log("[+] Uploading custom device tree...");
await instance.uploadDeviceTree(myFilePath, myFile);
  1. Run the example by entering the following command into your command line
node main.js.
  1. Check your console to see the output.

output

Note: if you haven't named your devices, the example will return "Found instance named null" as seen above.

Next Steps