title: Spotify javascript API - getting the genre of a song in a playlist
body: <p>I'm currently using the very cool app Exportify (<a href="https://github.com/watsonbox/exportify" rel="nofollow noreferrer">https://github.com/watsonbox/exportify</a>) to export Spotify playlists to CSV.</p>
  
  <p>My javascript knowledge is terrible but I'm currently trying to include the genre of each track, and I'm having trouble retrieving it.</p>
  
  <p>I'm assuming that:</p>
  
  <ul>
  <li>I have to get the genre through the artist.</li>
  <li>The playlist API returns a simple artist object that can only get me the ID, not the genre (<a href="https://developer.spotify.com/web-api/get-playlists-tracks/" rel="nofollow noreferrer">https://developer.spotify.com/web-api/get-playlists-tracks/</a>)</li>
  <li>That to get the genre I'd have to do a further lookup of the artist using the artist ID (<a href="https://developer.spotify.com/web-api/object-model/#artist-object-full" rel="nofollow noreferrer">https://developer.spotify.com/web-api/object-model/#artist-object-full</a>)</li>
  </ul>
  
  <p>I can get the artist ID by adding </p>
  
  <pre><code>item.track.artists.map(function (artist) {
    return artist.id
  }).join(', '),
  </code></pre>
  
  <p>to the code below in the <code>exportify.js</code> file. </p>
  
  <pre><code>var tracks = responses.map(function (response) {
    return response.items.map(function (item) {
      return [
        item.track.uri,
        item.track.id,
        item.track.name,
        item.track.artists.map(function (artist) {
          return artist.name
        }).join(', '),
        item.track.artists.map(function (artist) {
          return artist.id
        }).join(', '),
        item.track.album.name,
        item.track.disc_number,
        item.track.track_number,
        item.track.duration_ms,
        item.added_by == null ? '' : item.added_by.uri,
        item.added_at
      ].map(function (track) {
        return '"' + track + '"';
      })
    });
  });
  </code></pre>
  
  <p>Can anyone tell me how I can then get the artist genre based on the artist ID and add it as another column?</p>
  
  <p>Thanks</p>
  
  <p>Chris</p>