pydo.snapshots.list()

Description

To list all of the snapshots available on your account, send a GET request to /v2/snapshots.

The response will be a JSON object with a key called snapshots. This will be set to an array of snapshot objects, each of which will contain the standard snapshot attributes.

Filtering Results by Resource Type

It’s possible to request filtered results by including certain query parameters.

List Droplet Snapshots

To retrieve only snapshots based on Droplets, include the resource_type query parameter set to droplet. For example, /v2/snapshots?resource_type=droplet.

List Volume Snapshots

To retrieve only snapshots based on volumes, include the resource_type query parameter set to volume. For example, /v2/snapshots?resource_type=volume.

Parameters

Name Type Required Description Default Value
per_page integer False Number of items returned per page 20
page integer False Which ‘page’ of paginated results to return. 1
resource_type string False Used to filter snapshots by a resource type.

Request Sample

import os
from pydo import Client

client = Client(token=os.environ.get("DIGITALOCEAN_TOKEN"))

resp = client.snapshots.list()

Responses

See the API spec for this endpoint to view additional detail on responses, headers, parameters, and more.

A JSON object with a key of snapshots.

Click to expand an example response for All Snapshots.
{
  "value": {
    "snapshots": [
      {
        "id": "6372321",
        "name": "web-01-1595954862243",
        "created_at": "2020-07-28T16:47:44Z",
        "regions": [
          "nyc3",
          "sfo3"
        ],
        "resource_id": "200776916",
        "resource_type": "droplet",
        "min_disk_size": 25,
        "size_gigabytes": 2.34,
        "tags": [
          "web",
          "env:prod"
        ]
      },
      {
        "id": "fbe805e8-866b-11e6-96bf-000f53315a41",
        "name": "pvc-01-1595954862243",
        "created_at": "2019-09-28T23:14:30Z",
        "regions": [
          "nyc1"
        ],
        "resource_id": "89bcc42f-85cf-11e6-a004-000f53315871",
        "resource_type": "volume",
        "min_disk_size": 2,
        "size_gigabytes": 0.1008,
        "tags": [
          "k8s"
        ]
      }
    ],
    "links": {},
    "meta": {
      "total": 2
    }
  }
}
Click to expand an example response for Droplets Snapshots.
{
  "value": {
    "snapshots": [
      {
        "id": "6372321",
        "name": "web-01-1595954862243",
        "created_at": "2020-07-28T16:47:44Z",
        "regions": [
          "nyc3",
          "sfo3"
        ],
        "resource_id": "200776916",
        "resource_type": "droplet",
        "min_disk_size": 25,
        "size_gigabytes": 2.34,
        "tags": [
          "web",
          "env:prod"
        ]
      }
    ],
    "links": {},
    "meta": {
      "total": 1
    }
  }
}
Click to expand an example response for Volume Snapshots.
{
  "value": {
    "snapshots": [
      {
        "id": "fbe805e8-866b-11e6-96bf-000f53315a41",
        "name": "pvc-01-1595954862243",
        "created_at": "2019-09-28T23:14:30Z",
        "regions": [
          "nyc1"
        ],
        "resource_id": "89bcc42f-85cf-11e6-a004-000f53315871",
        "resource_type": "volume",
        "min_disk_size": 2,
        "size_gigabytes": 0.1008,
        "tags": [
          "k8s"
        ]
      }
    ],
    "links": {},
    "meta": {
      "total": 1
    }
  }
}

Unauthorized

Click to expand an example response.
{
  "id": "unauthorized",
  "message": "Unable to authenticate you."
}

API Rate limit exceeded

Click to expand an example response.
{
  "id": "too_many_requests",
  "message": "API Rate limit exceeded."
}

Server error.

Click to expand an example response.
{
  "id": "server_error",
  "message": "Unexpected server-side error"
}

Unexpected error

Click to expand an example response.
{
  "id": "example_error",
  "message": "some error message"
}