A Go port of maximilianvoss/toniebox-api
A Go library for interacting with the Toniebox Cloud API. Control your Creative-Tonies, upload audio files, manage chapters, and more - all from your Go applications.
The Toniebox is a popular audio player designed for children. It uses figurines called "Tonies" that play stories, songs, and other audio content. Creative-Tonies are special figurines that allow you to upload your own audio content.
- π Authentication - Secure login with your Toniebox account credentials
- π€ User Management - Retrieve your personal account information
- π Household Access - List and manage multiple households
- π Creative-Tonie Control - Access and control all your Creative-Tonies
- π€ File Upload - Upload audio files to your Creative-Tonies
- π Chapter Management - Add, remove, and organize chapters
- π Real-time Updates - Refresh to get the latest state from the cloud
- π Proxy Support - Optional proxy configuration for network environments
go get github.com/mikeboe/toniebox-api-gopackage main
import (
"fmt"
"log"
toniebox "github.com/mikeboe/toniebox-api-go"
)
func main() {
// Create a new client
client := toniebox.NewClient()
// Login
if err := client.Login("user@example.com", "password"); err != nil {
log.Fatal(err)
}
// Get your households
households, err := client.GetHouseholds()
if err != nil {
log.Fatal(err)
}
// Get Creative-Tonies
tonies, err := client.GetCreativeTonies(&households[0])
if err != nil {
log.Fatal(err)
}
// Work with a Tonie
tonie := &tonies[0]
fmt.Printf("Tonie: %s has %d chapters\n", tonie.Name, tonie.ChaptersPresent)
}// Create a client
client := toniebox.NewClient()
// Or with proxy support
client, err := toniebox.NewClientWithProxy("http://proxy.example.com:8080")
// Login
err := client.Login("user@example.com", "password")me, err := client.GetMe()
if err != nil {
log.Fatal(err)
}
fmt.Printf("User: %s %s\n", me.FirstName, me.LastName)// Get all households
households, err := client.GetHouseholds()
if err != nil {
log.Fatal(err)
}
// Get Creative-Tonies from a household
tonies, err := client.GetCreativeTonies(&households[0])
if err != nil {
log.Fatal(err)
}
for _, tonie := range tonies {
fmt.Printf("Tonie: %s (Chapters: %d)\n", tonie.Name, tonie.ChaptersPresent)
}tonie := &tonies[0]
// Upload a file
err := tonie.UploadFile("My Story", "/path/to/audio.mp3")
if err != nil {
log.Fatal(err)
}
// Commit changes
err = tonie.Commit()
if err != nil {
log.Fatal(err)
}// Find a chapter by title
chapter := tonie.FindChapterByTitle("Old Story")
if chapter != nil {
// Delete the chapter
tonie.DeleteChapter(chapter)
// Commit changes
tonie.Commit()
}tonie.Name = "New Name"
err := tonie.Commit()
if err != nil {
log.Fatal(err)
}// Refresh to get the latest state from the cloud
err := tonie.Refresh()
if err != nil {
log.Fatal(err)
}
fmt.Printf("Current chapters: %d\n", tonie.ChaptersPresent)A complete example application is included in the examples directory:
# Set your credentials
export TONIEBOX_USERNAME="your-email@example.com"
export TONIEBOX_PASSWORD="your-password"
# Run the example
cd examples
go run main.goFor detailed API documentation, see the GoDoc.
- Client - Main API client for authentication and accessing resources
- CreativeTonie - Represents a Creative-Tonie figurine with methods for managing content
- Household - Represents a household/family group
- Chapter - Represents an audio chapter/track on a Creative-Tonie
- Me - User account information
NewClient()- Create a new API clientNewClientWithProxy(proxyURL)- Create a client with proxy supportLogin(username, password)- Authenticate with your Toniebox accountGetMe()- Get your user informationGetHouseholds()- List all households you belong toGetCreativeTonies(household)- List Creative-Tonies in a household
UploadFile(title, filePath)- Upload an audio fileCommit()- Save changes to the cloudRefresh()- Reload the latest stateFindChapterByTitle(title)- Find a chapter by its titleDeleteChapter(chapter)- Remove a chapter
- Go 1.21 or higher
- Active Toniebox account
- Internet connection
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.
This is a Go port of the original Java implementation by Maximilian Voss.
This is an unofficial library and is not affiliated with, endorsed by, or connected to Boxine GmbH or the Toniebox brand. Use at your own risk.