Photos via Pexels

Compute Service gives you resizable virtual machines that boot in seconds. Pick a machine type, choose a zone, and pay only while an instance is running — persistent disks and images make it easy to rebuild identical environments on demand.
  • Instances — on-demand VMs with configurable vCPU, memory and disks.
  • Machine types — preset profiles from micro to compute-optimized.
  • Zones & regions — isolated locations for latency and failover.
  • Images & snapshots — reusable templates and point-in-time backups.
  1. Create a project and enable the Compute API for it.
  2. Generate an API key from the console credentials page.
  3. Launch an instance from a public image in your zone.
  4. Connect over SSH and deploy your first app.
GET /v1/instances
Lists the Compute instances in your project. Results are paginated and can be filtered by zone or lifecycle status.
NameTypeRequiredDescription
project_idstringYesProject that owns the instances.
zonestringNoOnly return instances in this zone.
statusenumNoRUNNING, STOPPED or PROVISIONING.
limitintegerNoPage size, 1–100. Defaults to 25.
GET · /v1/instances
{
  "method": "GET",
  "host": "api.example.com",
  "path": "/v1/instances",
  "query": {
    "zone": "us-east-1a",
    "limit": 25
  },
  "headers": {
    "Authorization": "Bearer $API_KEY"
  }
}
{
  "instances": [
    {
      "id": "inst-8f2c41",
      "name": "web-server-01",
      "zone": "us-east-1a",
      "machine_type": "c2-standard-4",
      "status": "RUNNING"
    }
  ],
  "next_page_token": "b2Zmc2V0PTI1"
}
ListInstances.swift SWIFT
import Foundation

// Call GET /v1/instances from iOS
let url = URL(string:
  "https://api.example.com/v1/instances")!

var request = URLRequest(url: url)
request.httpMethod = "GET"
request.setValue("Bearer \(apiKey)",
  forHTTPHeaderField: "Authorization")

let task = URLSession.shared.dataTask(
  with: request) { data, response, error in
  guard error == nil,
        let data = data else { return }

  // Handle response
  let list = try? JSONDecoder().decode(
    InstanceList.self, from: data)
}

task.resume()

Runs the request on a background session and decodes the instance list.

Photos via Pexels