O'Reilly logo

Web Development with Django Cookbook - Second Edition by Aidas Bendoraitis

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Importing data from an external JSON file

The Last.fm music website has an API under the http://ws.audioscrobbler.com/ domain that you can use to read the albums, artists, tracks, events, and more. The API allows you to either use the JSON or XML format. In this recipe, we will import the top tracks tagged disco using the JSON format.

Getting ready

Follow these steps in order to import data in the JSON format from Last.fm:

  1. To use Last.fm, you need to register and get an API key. The API key can be created at http://www.last.fm/api/account/create.
  2. The API key has to be set in the settings as LAST_FM_API_KEY.
  3. Also, install the requests library in your virtual environment using the following command:
    (myproject_env)$ pip install requests
    
  4. Let's check

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required