By itzforuhere
Hello,
I am trying to write a shell script to take snapshot of a droplet. Is there any option to get droplet name from droplet ID using curl?
Thanks in advance.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
You should check out the full API documentation as well as this tutorial. They should point you in the right direction.
The /v2/droplets endpoint will return a list of of droplet objects with information about each one. The droplet’s id is included in this information. An abridged droplet object might look like:
{
"id": 14,
"name": "test.example.com",
"memory": 512,
"vcpus": 1,
"disk": 20,
"region": {
....
If you’re doing this with a shell script, I’d suggest looking into jq to parse the json objects. For instance, if you know the name of a droplet you can find its id with:
curl -X GET "https://api.digitalocean.com/v2/droplets" -H "Authorization: Bearer $TOKEN" \
| jq '.droplets[] | select(.name=="test.example.com") | .id'
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.