Giter Club home page Giter Club logo

spotify-albums-and-tracks's Introduction

Spotify API Assignment

Spotify has a wonderful public API. Let's explore API usage using music because music is awesome. Your task will be to explore some of the endpoints that Spotify offers us. You'll want the documentation:

https://developer.spotify.com/web-api/

Outside of the documentation, which is expansive, Spotify offers an 'api console' which will create requests on your behalf. It's a lot like Postman, check it out:

https://developer.spotify.com/web-api/console/

If you prefer to use Postman, you can! One of these tools will be useful. The nice thing about the Spotify Web Console is that it has a lot of human readable content to point you in the right direction.

Getting the Code to Run

Fork then clone this repository! Then, from the repo directory run:

Using Python

python -m SimpleHTTPServer

Using Javascript

npm install -g http-server
http-server -p 8000

Now navigate chrome to http://localhost:8000

Try a search for your favorite artist!

Whats Going On

As a baseline, we're making a single request to the Spotify API. You can look at the code or the network tab to see the request being made, but the gist is that we request to:

https://api.spotify.com/v1/search?type=artist&q=WHATEVER YOU TYPE

Head over to the API docs for more about the search endpoint! https://developer.spotify.com/web-api/search-item/

We parse the results, and populate them into the results area. Simple as pie.

Your Task

Your task is to complete the function displayAlbumsAndTracks. Right now, when you click one of the results this function is called, but it simply prints to the console. This function should do 3 things:

  1. Query the Spotify API for every album produced by the artist you clicked on.
  2. For each of those albums fetch every track on the album.
  3. Display this information to the user such that:
    • Albums appear with its release date.
    • Each album has its tracks displayed before the next album appears.
    • All of this information should be appended to this div: <div id='albums-and-tracks'>

This may seem simple, but it won't be. You will be using AJAX heavily; you will be parsing through some serious documentation; you will have to handle race conditions.

Bonus

Get the tracks 'popularity' metric and show it side by side with the track name.

Heres a Tip

You'll need to use these two endpoints, but you may also need to use more:

https://developer.spotify.com/web-api/console/get-album/ https://developer.spotify.com/web-api/console/get-artist-albums/

spotify-albums-and-tracks's People

Contributors

tebba-von-mathenstein avatar carlosnsr avatar w3cj avatar joshwyatt avatar zubaird avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.