Categories
Featured Guides
Photos via Pexels
Photos via Pexels
| Name | Type | Required | Description |
|---|---|---|---|
| project_id | string | Yes | Project that owns the instances. |
| zone | string | No | Only return instances in this zone. |
| status | enum | No | RUNNING, STOPPED or PROVISIONING. |
| limit | integer | No | Page size, 1–100. Defaults to 25. |
{
"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"
}
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