Question

DO APIv2 feedback - getting available snapshot info associated with deleted droplets

  • Posted January 12, 2015

I noticed that the DO API only allows query of snapshots so long as you have a droplet ID. However, if you delete the droplet, the droplet ID will no longer be available in any of the API queries even though the associated snapshot still exists.

The workaround is to have a local cache of any droplet IDs that have been created and query each one for any snapshots. However, it seems like it makes more sense to query available snapshots based on the account rather than the droplet id. Did I miss something in the API to do this?

Subscribe
Share

Additional note, the “images” query doesn’t have a qualifier like ‘types=snapshot’ to distinguish it from something like ‘backup’, ‘distro’, or ‘all’.


Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

When querying /v2/images , you can look at the public attribute:

  "images": [
    {
      "id": 7555620,
      "name": "Nifty New Snapshot",
      "distribution": "Ubuntu",
      "slug": null,
      "public": false,
      "regions": [
        "nyc2",
        "nyc2"
      ],
      "created_at": "2014-11-04T22:23:02Z",
      "min_disk_size": 20
    }

Your snapshots, as opposed to base distros and One-Click apps, will be "public": false For example using something like the jq utility, you can filter out public images:

curl -X GET -H 'Content-Type: application/json' \
-H 'Authorization: Bearer $TOKEN' \
https://api.digitalocean.com/v2/images?per_page=200 \
| jq '.images[] | select(.public == 'false')'

Though it might make sense to add additional filters directly into the API as we already do with ‘distro’ and ‘application’ We collect API feedback in GitHub issues: