Follow these steps to import data in the JSON format from Last.fm:
- Let's start with the music app that we created in the Importing data from a local CSV file recipe.
- To use Last.fm, you need to register and get an API key. The API key can be
created at https://www.last.fm/api/account/create.
- The API key has to be set in the settings as LAST_FM_API_KEY. We recommend
providing it from the secrets file or an environment variable and drawing that into your settings, as shown here:
# myproject/settings/_base.pyLAST_FM_API_KEY = get_secret("LAST_FM_API_KEY")
- Also, install the requests library in your virtual environment using the following command:
(env)$ pip install requests==2.22.0
- Let's check the structure of the JSON endpoint ...