The official DigitalOcean Go API client
Godo is a Go client library for accessing the DigitalOcean V2 API.
You can view the client API docs here: http://godoc.org/github.com/digitalocean/godo
You can view Digital Ocean API docs here: https://developers.digitalocean.com/documentation/v2/
import "github.com/digitalocean/godo"
Create a new DigitalOcean client, then use the exposed services to access different parts of the DigitalOcean API.
Currently, Personal Access Token (PAT) is the only method of authenticating with the API. You can manage your tokens at the Digital Ocean Control Panel Applications Page.
You can then use your token to create a new client:
import "code.google.com/p/goauth2/oauth"
pat := "mytoken"
t := &oauth.Transport{
Token: &oauth.Token{AccessToken: pat},
}
client := godo.NewClient(t.Client())
To create a new Droplet:
dropletName := "super-cool-droplet"
createRequest := &godo.DropletCreateRequest{
Name: dropletName,
Region: "nyc3",
Size: "512mb",
Image: godo.DropletCreateImage{
Slug: "ubuntu-14-04-x64",
},
}
newDroplet, _, err := client.Droplets.Create(createRequest)
if err != nil {
fmt.Printf("Something bad happened: %s\n\n", err)
return err
}
by: DigitalOceanMay 11, 2015Visit site
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!
Have you created an Integration, API Wrapper, Service, or other Tool that helps developers build on DigitalOcean? Help users find it by listing it in Community Tools.
Sign up for Infrastructure as a Newsletter.
Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.