dicebear-go
is a package that wraps around DiceBear's API.
This allows you to easily generate tons of unique avatars in Go.
The API can generate more than 1 sexdecillion (that's 17 zeroes!) unique avatars!
If you want to use Dicebear avatars but don't use Golang, you can use the dicebear Python package or the official JS/TS package.
- Official Dicebear: https://dicebear.com/
- Go package: https://pkg.go.dev/github.com/jvherck/dicebear-go
- Docs: https://dicebear-go.vhjan.me/#section-documentation
- GitHub: https://github.com/jvherck/dicebear-go
- Python package: https://github.com/jvherck/dicebear
- JS/TS library: https://github.com/dicebear/dicebear
Install the dicebear-go
package using the following command:
go get -u github.com/jvherck/dicebear-go
package main
import (
"fmt"
"log"
"github.com/jvherck/dicebear-go"
)
func main() {
// Create a new avatar with the "adventurer" style and a random seed
avatar, err := dicebear.NewAvatar(dicebear.Adventurer, "", nil, nil)
if err != nil {
log.Fatalf("Failed to create avatar: %v", err)
}
// Get the avatar URL
fmt.Println("Avatar URL:", avatar.URL())
// Save the avatar as an SVG file
outputPath := "avatar.svg"
_, err = avatar.Save(dicebear.SVG, outputPath, false)
if err != nil {
log.Fatalf("Failed to save avatar: %v", err)
}
fmt.Println("Avatar saved to:", outputPath)
}
/*
Output:
Avatar URL: https://api.dicebear.com/9.x/adventurer/svg?seed=random-seed
Avatar saved to: avatar.svg
*/
We welcome contributions from the community! Whether you're fixing a bug, adding a feature, or improving documentation, your help is appreciated. Find out in our Contributing Guide how to contribute to this project.
Special thanks to Dicebear (Florian Körner) for making this amazing API and to all artists for creating all the awesome avatars and artwork!
Disclaimer: this repository and its owner are not affiliated with DiceBear.
- Dicebear Licenses: https://dicebear.com/licenses
- Dicebear Privacy Policy: https://dicebear.com/legal/privacy-policy
- Dicebear Go package (this project): https://dicebear-go.vhjan.me/license