Skip to content
master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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

About

KKBOX Open API SDK for Golang.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published