json

Get a list of all available images in the DigitalOcean v2 API

I frequently need to check the slug or id of a particular Droplet image (or in AWS parlance, an AMI) that I can use to launch new DigitalOcean droplets via Ansible. And seeing as tonight I had to search for 'how to get a list of all DigitalOcean images' about the hundredth time, I figured I'd publish this in a blog post so I can find it more easily in the future.

Without further ado:

curl -X GET --silent "https://api.digitalocean.com/v2/images?per_page=999" -H "Authorization: Bearer $DO_API_TOKEN"

This assumes you have exported a valid $DO_API_TOKEN previously. If not, just paste your DigitalOcean API token in place of $DO_API_TOKEN, and then run the command.

It dumps out a ton of JSON, so you can either paste it through something like http://jsonprettyprint.com, or try reading it in all it's unformatted glory. And if the latter, are you a robot?

Migrate a custom JSON feed in Drupal 8 with Migrate Source JSON

June 2016 Update: Times change fast! Already, the migrate_source_json module mentioned in the post has been (mostly) merged directly into the migrate_plus module, so if you're building a new migration now, you should use the migrate_plus JSON plugin if at all possible. See Mike Ryan's blog post Drupal 8 plugins for XML and JSON migrations for more info.

Recently I needed to migrate a small set of content into a Drupal 8 site from a JSON feed, and since documentation for this particular scenario is slightly thin, I decided I'd post the entire process here.

I was given a JSON feed available over the public URL http://www.example.com/api/products.json which looked something like: