#resp form spotify.Recommendation is always empty

9 messages · Page 1 of 1 (latest)

static yarrow
#

import (
    "fmt"
    "log"

    "github.com/zmb3/spotify"
)

type Seeds struct {
    Artists []string
    Tracks  []string
    Genres  []string
}

func Recommendation() {
    client := Token()
    seedArtists := []spotify.ID{"4NHQUGzhtTLFvgF5SZesLK"}
    seedTracks := []spotify.ID{"3n3Ppam7vgaVa1iaRUc9Lp"}
    seedGenres := []string{"pop"}

    limit := 20

    trackAttributes := spotify.NewTrackAttributes().
        MaxAcousticness(0.15).
        TargetDanceability(0.8).
        MinEnergy(0.5).
        TargetTempo(120)

    seeds := spotify.Seeds{
        Artists: seedArtists,
        Tracks:  seedTracks,
        Genres:  seedGenres,
    }

    recommendations, err := client.GetRecommendations(seeds, trackAttributes, &spotify.Options{
        Limit: &limit,
    })
    if err != nil {
        log.Printf("Error fetching recommendations: %v", err)
        return
    }

    fmt.Println("Recommended Tracks:")
    for _, track := range recommendations.Tracks {
        fmt.Println(track.Name, track.URI)
    }
}
tranquil charm
#

with syntax highlighting:

package utils

import (
    "fmt"
    "log"

    "github.com/zmb3/spotify"
)

type Seeds struct {
    Artists []string
    Tracks  []string
    Genres  []string
}

func Recommendation() {
    client := Token()
    seedArtists := []spotify.ID{"4NHQUGzhtTLFvgF5SZesLK"}
    seedTracks := []spotify.ID{"3n3Ppam7vgaVa1iaRUc9Lp"}
    seedGenres := []string{"pop"}

    limit := 20

    trackAttributes := spotify.NewTrackAttributes().
        MaxAcousticness(0.15).
        TargetDanceability(0.8).
        MinEnergy(0.5).
        TargetTempo(120)

    seeds := spotify.Seeds{
        Artists: seedArtists,
        Tracks:  seedTracks,
        Genres:  seedGenres,
    }

    recommendations, err := client.GetRecommendations(seeds, trackAttributes, &spotify.Options{
        Limit: &limit,
    })
    if err != nil {
        log.Printf("Error fetching recommendations: %v", err)
        return
    }

    fmt.Println("Recommended Tracks:")
    for _, track := range recommendations.Tracks {
        fmt.Println(track.Name, track.URI)
    }
}
quiet plume
#

i don't see any major reason to use the sdk, why not just use http.get directly on their api endpoints

#

my point is sdk go unmaintained and break often

prime hinge
#
  1. Seed Validation
  2. Token and Authorization Issues
  3. Empty Recommendations from Spotify
  4. Rate Limiting
    ...
    please check and test to fix by considering these.
static yarrow
#

seed is correct and token is working fine responce body is empty

#

maybe there is some issue with server side what you think