With your API, when you create a snapshot it does not return a snapshot ID. It returns an action which is fine, but even the action doesn't contain the snapshot ID only the droplet ID. As a result there is no easy way of detecting the ID of the snapshot.
The only option is to give it a unique name and then loop through the images, the problem with this is running loops significantly slows down page loads.
Either the original request and/or the action should return the snapshot ID.