Skip to content
KKBOX Open API SDK for Golang.
Go Makefile
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
example
.drone.yml
.gitignore
.revive.toml
LICENSE
Makefile
README.md
albums.go
artist.go
category.go
charts.go
config.go
feature.go
genre.go
go.mod
go.sum
hits.go
kkbox.go
kkbox_test.go
model.go
mood.go
release.go
search.go
shared.go
tracks.go

README.md

go-kkbox

GoDoc Build Status codecov Go Report Card

KKBOX Open API SDK for Golang.

Features

  • Tracks
    • /tracks/{track_id}
  • Albums
    • /albums/{album_id}
    • /albums/{album_id}/tracks
  • Artists
    • /artists/{artist_id}
    • /artists/{artist_id}/albums
    • /artists/{artist_id}/top-tracks
    • /artists/{artist_id}/related-artists
  • Shared Playlists
    • /shared-playlists/{playlist_id}
    • /shared-playlists/{playlist_id}/tracks
  • Featured Playlists
    • /featured-playlists
    • /featured-playlists/{playlist_id}
    • /featured-playlists/{playlist_id}/tracks
  • Featured Playlist Categories
    • /featured-playlist-categories
    • /featured-playlist-categories/{category_id}
    • /featured-playlist-categories/{category_id}/playlists
  • Mood Stations
    • /mood-stations
    • /mood-stations/{station_id}
  • Genre Stations
    • /genre-stations
    • /genre-stations/{station_id}
  • New Release Categories
    • /new-release-categories
    • /new-release-categories/{category_id}
    • /new-release-categories/{category_id}/albums
  • Search
    • /search
  • New Hits Playlists
    • /new-hits-playlists
    • /new-hits-playlists/{playlist_id}
    • /new-hits-playlists/{playlist_id}/tracks
  • Charts
    • /charts
    • /charts/{playlist_id}
    • /charts/{playlist_id}/tracks

Install

Install SDK library

$ go get -u github.com/appleboy/go-kkbox

Inital the KKBox client:

package main

import (
	"log"
	"os"

	"github.com/appleboy/go-kkbox"
)

var clientID = os.Getenv("CLIENT_ID")
var clientSecret = os.Getenv("CLIENT_SECRET")

func main() {
	if clientID == "" || clientSecret == "" {
		log.Fatal("missing client id or secret")
	}
	k, err := kkbox.New(clientID, clientSecret)

	if err != nil {
		log.Fatal(err)
	}

	fmt.Println("====== kkbox client ======")
	spew.Dump(k)
	fmt.Println("====== kkbox end ======")

	// fetch charts
	charts, err := k.FetchCharts()
	if err != nil {
		fmt.Printf("%#v\n", err)
	}

	fmt.Printf("%#v\n", charts)

	ranks, err := k.FetchChartPlayList("4nUZM-TY2aVxZ2xaA-")
	if err != nil {
		fmt.Printf("%#v\n", err)
	}

	spew.Dump(ranks)

	tracks, err := k.FetchChartPlayListTrack("4nUZM-TY2aVxZ2xaA-", kkbox.Param{
		PerPage:   1,
		Page:      2,
		Territory: "HK",
	})
	if err != nil {
		fmt.Printf("%#v\n", err)
	}

	spew.Dump(tracks)
	log.Println("length: ", len(tracks.Data))
}

Run program:

$ CLIENT_ID=xxx CLIENT_SECRET=xxx go run main.go
You can’t perform that action at this time.