https://github.com/hetznercloud/hcloud-go
A Go library for the Hetzner Cloud API
https://github.com/hetznercloud/hcloud-go
api go golang hcloud hetzner hetzner-cloud
Last synced: 6 days ago
JSON representation
A Go library for the Hetzner Cloud API
- Host: GitHub
- URL: https://github.com/hetznercloud/hcloud-go
- Owner: hetznercloud
- License: mit
- Created: 2017-11-29T17:09:45.000Z (over 7 years ago)
- Default Branch: main
- Last Pushed: 2025-04-11T12:15:22.000Z (9 days ago)
- Last Synced: 2025-04-14T11:09:14.792Z (6 days ago)
- Topics: api, go, golang, hcloud, hetzner, hetzner-cloud
- Language: Go
- Homepage: https://pkg.go.dev/github.com/hetznercloud/hcloud-go/v2/hcloud
- Size: 4.71 MB
- Stars: 418
- Watchers: 11
- Forks: 46
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
- awesome-hcloud - hcloud-go
README
# hcloud: A Go library for the Hetzner Cloud API
[](https://github.com/hetznercloud/hcloud-go/actions)
[](https://codecov.io/github/hetznercloud/hcloud-go/tree/main)
[](https://pkg.go.dev/github.com/hetznercloud/hcloud-go/v2/hcloud)Package hcloud is a library for the Hetzner Cloud API.
The library’s documentation is available at [pkg.go.dev](https://godoc.org/github.com/hetznercloud/hcloud-go/v2/hcloud),
the public API documentation is available at [docs.hetzner.cloud](https://docs.hetzner.cloud/).> [!IMPORTANT]
> Make sure to follow our API changelog available at
> [docs.hetzner.cloud/changelog](https://docs.hetzner.cloud/changelog) (or the RSS feed
> available at
> [docs.hetzner.cloud/changelog/feed.rss](https://docs.hetzner.cloud/changelog/feed.rss))
> to be notified about additions, deprecations and removals.## Installation
```sh
go get github.com/hetznercloud/hcloud-go/v2/hcloud
```## Example
```go
package mainimport (
"context"
"fmt"
"log""github.com/hetznercloud/hcloud-go/v2/hcloud"
)func main() {
client := hcloud.NewClient(hcloud.WithToken("token"))server, _, err := client.Server.GetByID(context.Background(), 1)
if err != nil {
log.Fatalf("error retrieving server: %s\n", err)
}
if server != nil {
fmt.Printf("server 1 is called %q\n", server.Name)
} else {
fmt.Println("server 1 not found")
}
}
```## Upgrading
### Support
- `v2` is actively maintained by Hetzner Cloud
- `v1` is unsupported since February 2025.### From v1 to v2
Version 2.0.0 was published because we changed the datatype of all `ID` fields from `int` to `int64`.
To migrate to the new version, replace all your imports to reference the new module path:
```diff
import (
- "github.com/hetznercloud/hcloud-go/hcloud"
+ "github.com/hetznercloud/hcloud-go/v2/hcloud"
)
```When you compile your code, it will show any invalid usages of `int` in your code that you need to fix. We commonly found these changes while updating our integrations:
- `strconv.Atoi(idString)` (parsing integers) needs to be replaced by `strconv.ParseInt(idString, 10, 64)`
- `strconv.Itoa(id)` (formatting integers) needs to be replaced by `strconv.FormatInt(id, 10)`## Go Version Support
The library supports the latest two Go minor versions, e.g. at the time Go 1.19 is released, it supports Go 1.18 and 1.19.
This matches the official [Go Release Policy](https://go.dev/doc/devel/release#policy).
When the minimum required Go version is changed, it is announced in the release notes for that version.
## License
MIT license