diff --git a/.DS_Store b/.DS_Store
new file mode 100644
index 0000000..424c482
Binary files /dev/null and b/.DS_Store differ
diff --git a/notebooks/spotify_rest_api_challenge.ipynb b/notebooks/spotify_rest_api_challenge.ipynb
deleted file mode 100644
index 5e4f8f7..0000000
--- a/notebooks/spotify_rest_api_challenge.ipynb
+++ /dev/null
@@ -1,243 +0,0 @@
-{
- "cells": [
- {
- "cell_type": "markdown",
- "id": "ef05c1d6",
- "metadata": {},
- "source": [
- "\n",
- "\n",
- "# Spotify REST API Challenge\n",
- "\n",
- "__What to listen?__\n",
- "\n",
- "Create your own playlist based on the related artists and their most popular tracks using the [Spotify REST API](https://developer.spotify.com/)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "17a49776",
- "metadata": {},
- "outputs": [],
- "source": [
- "# Imports\n",
- "\n",
- "\n"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "4e97884c",
- "metadata": {},
- "source": [
- "### Get access!!!\n",
- "\n",
- "Get your `client_id` and `client_secret` to generate your __token__ access"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "7b5d2e52",
- "metadata": {},
- "outputs": [],
- "source": [
- "# Generate token with a POST request\n",
- "\n",
- "client_id = # CLIENT ID\n",
- "client_secret = # CLIENT SECRET\n",
- "auth_url = 'https://accounts.spotify.com/api/token'"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "c7901d1e",
- "metadata": {},
- "outputs": [],
- "source": [
- "auth_response = requests.post(auth_url, {'grant_type': 'client_credentials',\n",
- " 'client_id': client_id,\n",
- " 'client_secret': client_secret}).json()"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "262e7e18",
- "metadata": {},
- "outputs": [],
- "source": [
- "access_token = auth_response['access_token']\n",
- "auth_response"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "e617caff",
- "metadata": {},
- "source": [
- "### Set your main variables!!!\n",
- "\n",
- "Set the `base_uri` (i.e.: end-point), parameters and `headers` for your __GET__ operations"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "62e6d4fb",
- "metadata": {},
- "outputs": [],
- "source": [
- "# Base end-point construction\n",
- "\n",
- "base_url = 'https://api.spotify.com/v1/'\n",
- "resource = 'artists/'\n",
- "\n",
- "header_info = {'Authorization': 'Bearer {token}'.format(token=access_token)}"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "16660a9b",
- "metadata": {},
- "source": [
- "### Create your new playlist!!!\n",
- "\n",
- "Use [`/related-artists`](https://developer.spotify.com/documentation/web-api/reference/#/operations/get-an-artists-related-artists) and [`/top-tracks`](https://developer.spotify.com/documentation/web-api/reference/#/operations/get-an-artists-top-tracks) in order to get the data that you need.\n",
- "\n",
- "__Here you have the different artists to start with:__\n",
- "\n",
- "- __Option 1:__ 0L8ExT028jH3ddEcZwqJJ5\n",
- "\n",
- "- __Option 2:__ 4Y7tXHSEejGu1vQ9bwDdXW\n",
- "\n",
- "- __Option 3:__ 6FBDaR13swtiWwGhX1WQsP\n",
- "\n",
- "- __Option 4:__ 0kyQwKHCZnKE7kTXkxXjrB\n",
- "\n",
- "- __Option 5:__ 2d0hyoQ5ynDBnkvAbJKORj\n",
- "\n",
- "- __Option 6:__ 3bgsNtcf5d5h9jbQbohfBK\n",
- "\n",
- "- __Option 7:__ 7mWCSSOYqm4E9mB7V4ot6S\n",
- "\n",
- "- __Option 8:__ 64KEffDW9EtZ1y2vBYgq8T\n",
- "\n",
- "- __Option 9:__ 4k1ELeJKT1ISyDv8JivPpB\n",
- "\n",
- "- __Option 10:__ 4Z8W4fKeB5YxbusRsdQVPb\n",
- "\n",
- "- __Option 11:__ 26dSoYclwsYLMAKD3tpOr4\n",
- "\n",
- "- __Option 12:__ 7y97mc3bZRFXzT2szRM4L4\n",
- "\n",
- "- __Option 13:__ 1w5Kfo2jwwIPruYS2UWh56\n",
- "\n",
- "\n",
- "> Remember to check the [Requests](https://requests.readthedocs.io/en/latest/) library docs!!!\n",
- "\n",
- "---"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "04f85940",
- "metadata": {},
- "outputs": [],
- "source": [
- "# Here you can complete your endpoint URI\n",
- "\n",
- "full_endpoint = \n",
- "full_endpoint"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "50ec3959",
- "metadata": {},
- "outputs": [],
- "source": [
- "# Start building your playlist!!!\n",
- "\n",
- "\n"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "98827be6",
- "metadata": {},
- "source": [
- "---\n",
- "\n",
- "### Bonus track!!!\n",
- "\n",
- "You can publish your own Playlist with [`/playlists`](https://developer.spotify.com/documentation/web-api/reference/#/operations/create-playlist) and [`/tracks`](https://developer.spotify.com/documentation/web-api/reference/#/operations/add-tracks-to-playlist).\n",
- "\n",
- ""
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "2e5f0905",
- "metadata": {},
- "outputs": [],
- "source": [
- "# Bonus\n",
- "\n",
- "\n"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "9436b623",
- "metadata": {},
- "source": [
- "---"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "a9487ef7",
- "metadata": {},
- "source": [
- "You can always try with the [wrapper](https://github.com/plamere/spotipy)!!!\n",
- "\n",
- ""
- ]
- },
- {
- "cell_type": "markdown",
- "id": "0a399ce8",
- "metadata": {},
- "source": [
- "---"
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python [conda env:.conda-ironhack]",
- "language": "python",
- "name": "conda-env-.conda-ironhack-py"
- },
- "language_info": {
- "codemirror_mode": {
- "name": "ipython",
- "version": 3
- },
- "file_extension": ".py",
- "mimetype": "text/x-python",
- "name": "python",
- "nbconvert_exporter": "python",
- "pygments_lexer": "ipython3",
- "version": "3.7.11"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 5
-}
diff --git a/notebooks/spotify_rest_api_challenge_SOLUCIONES_con_BONUS.ipynb b/notebooks/spotify_rest_api_challenge_SOLUCIONES_con_BONUS.ipynb
new file mode 100644
index 0000000..f1b10ff
--- /dev/null
+++ b/notebooks/spotify_rest_api_challenge_SOLUCIONES_con_BONUS.ipynb
@@ -0,0 +1,1879 @@
+{
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "id": "37219dd7",
+ "metadata": {},
+ "source": [
+ "## Acceso"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 1,
+ "id": "d9ba4ce5",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "import requests\n",
+ "import pandas as pd\n",
+ "import json\n",
+ "import string\n",
+ "import random\n",
+ "from flask import Flask, request, redirect #No sé muy bien qué hace esto\n",
+ "import base64"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 2,
+ "id": "1a6a0d91",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "from dotenv import dotenv_values"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 3,
+ "id": "322e807a",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "OrderedDict([('client_id', 'f3c31c7678ae4a9887fc4c626a1e9bc1'), ('client_secret', 'a7ec3c800df3483cbc128524bec99fd3')])\n"
+ ]
+ }
+ ],
+ "source": [
+ "config = dotenv_values(\".env\")\n",
+ "print(config)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 4,
+ "id": "3ac2cac6",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "client_id = config[\"client_id\"]\n",
+ "client_secret = config[\"client_secret\"]"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 5,
+ "id": "f86d27d9",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "auth_url = 'https://accounts.spotify.com/api/token'"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 6,
+ "id": "3d4d0c29",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "auth_response = requests.post(auth_url, {'grant_type': 'client_credentials',\n",
+ " 'client_id': client_id,\n",
+ " 'client_secret': client_secret}).json()"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 7,
+ "id": "80f9f763",
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "'BQD29JwI_VgodIy35tqumuLJ2OrfWOps2Dx_mB_IhieCva38QQ9CPD8MfQx8PMpftFezL4x8yRpF6ajh6KE0p2vARKR41lUpQnjFK5bxvFXfFPnI7Z4'"
+ ]
+ },
+ "execution_count": 7,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "access_token = auth_response[\"access_token\"]\n",
+ "access_token"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 8,
+ "id": "4f609df6",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "base_url = 'https://api.spotify.com/v1/'\n",
+ "resource = 'artists/'\n",
+ "\n",
+ "header_info = {'Authorization': 'Bearer {token}'.format(token=access_token)}"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 9,
+ "id": "34a960cd",
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "{'Authorization': 'Bearer BQD29JwI_VgodIy35tqumuLJ2OrfWOps2Dx_mB_IhieCva38QQ9CPD8MfQx8PMpftFezL4x8yRpF6ajh6KE0p2vARKR41lUpQnjFK5bxvFXfFPnI7Z4'}"
+ ]
+ },
+ "execution_count": 9,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "header_info"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "0e81f95b",
+ "metadata": {},
+ "source": [
+ "## Creación de una playlist de artista + relacionados"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 10,
+ "id": "a938a7e2",
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "'3ZXXJ9nO1Dn9B0AJ25eAQY'"
+ ]
+ },
+ "execution_count": 10,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "#En este caso, yo voy a coger a Hamilton Leithauser\n",
+ "artist_id = \"3ZXXJ9nO1Dn9B0AJ25eAQY\"\n",
+ "artist_id"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 11,
+ "id": "8b90892c",
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "'https://api.spotify.com/v1/artists/3ZXXJ9nO1Dn9B0AJ25eAQY/related-artists'"
+ ]
+ },
+ "execution_count": 11,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "artist_id = \"3ZXXJ9nO1Dn9B0AJ25eAQY\"\n",
+ "method = \"/related-artists\"\n",
+ "argument = \"market = ES\"\n",
+ "full_endpoint = base_url + resource + artist_id + method \n",
+ "full_endpoint"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 12,
+ "id": "498c223f",
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "200"
+ ]
+ },
+ "execution_count": 12,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "related_artists_response = requests.get(full_endpoint, headers = header_info)\n",
+ "related_artists_response.status_code"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 13,
+ "id": "434bd193",
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "{'artists': [{'external_urls': {'spotify': 'https://open.spotify.com/artist/3h0w83PsjASrm5999trG4n'},\n",
+ " 'followers': {'href': None, 'total': 51178},\n",
+ " 'genres': ['ambient folk'],\n",
+ " 'href': 'https://api.spotify.com/v1/artists/3h0w83PsjASrm5999trG4n',\n",
+ " 'id': '3h0w83PsjASrm5999trG4n',\n",
+ " 'images': [{'height': 640,\n",
+ " 'url': 'https://i.scdn.co/image/ab6761610000e5ebf97b946adea21df03434101a',\n",
+ " 'width': 640},\n",
+ " {'height': 320,\n",
+ " 'url': 'https://i.scdn.co/image/ab67616100005174f97b946adea21df03434101a',\n",
+ " 'width': 320},\n",
+ " {'height': 160,\n",
+ " 'url': 'https://i.scdn.co/image/ab6761610000f178f97b946adea21df03434101a',\n",
+ " 'width': 160}],\n",
+ " 'name': 'Hamilton Leithauser + Rostam',\n",
+ " 'popularity': 7,\n",
+ " 'type': 'artist',\n",
+ " 'uri': 'spotify:artist:3h0w83PsjASrm5999trG4n'},\n",
+ " {'external_urls': {'spotify': 'https://open.spotify.com/artist/6kFay2DQ5aZfeu5OsrF3Pw'},\n",
+ " 'followers': {'href': None, 'total': 193249},\n",
+ " 'genres': ['chamber pop', 'indie rock', 'noise pop'],\n",
+ " 'href': 'https://api.spotify.com/v1/artists/6kFay2DQ5aZfeu5OsrF3Pw',\n",
+ " 'id': '6kFay2DQ5aZfeu5OsrF3Pw',\n",
+ " 'images': [{'height': 640,\n",
+ " 'url': 'https://i.scdn.co/image/ab6761610000e5ebaefcc48f32686224654746ca',\n",
+ " 'width': 640},\n",
+ " {'height': 320,\n",
+ " 'url': 'https://i.scdn.co/image/ab67616100005174aefcc48f32686224654746ca',\n",
+ " 'width': 320},\n",
+ " {'height': 160,\n",
+ " 'url': 'https://i.scdn.co/image/ab6761610000f178aefcc48f32686224654746ca',\n",
+ " 'width': 160}],\n",
+ " 'name': 'The Walkmen',\n",
+ " 'popularity': 44,\n",
+ " 'type': 'artist',\n",
+ " 'uri': 'spotify:artist:6kFay2DQ5aZfeu5OsrF3Pw'},\n",
+ " {'external_urls': {'spotify': 'https://open.spotify.com/artist/04XggbrM51GcFPTxBYtRXT'},\n",
+ " 'followers': {'href': None, 'total': 78947},\n",
+ " 'genres': ['art pop'],\n",
+ " 'href': 'https://api.spotify.com/v1/artists/04XggbrM51GcFPTxBYtRXT',\n",
+ " 'id': '04XggbrM51GcFPTxBYtRXT',\n",
+ " 'images': [{'height': 640,\n",
+ " 'url': 'https://i.scdn.co/image/ab6761610000e5eb927fc6434315284d758fa2cd',\n",
+ " 'width': 640},\n",
+ " {'height': 320,\n",
+ " 'url': 'https://i.scdn.co/image/ab67616100005174927fc6434315284d758fa2cd',\n",
+ " 'width': 320},\n",
+ " {'height': 160,\n",
+ " 'url': 'https://i.scdn.co/image/ab6761610000f178927fc6434315284d758fa2cd',\n",
+ " 'width': 160}],\n",
+ " 'name': 'Rostam',\n",
+ " 'popularity': 44,\n",
+ " 'type': 'artist',\n",
+ " 'uri': 'spotify:artist:04XggbrM51GcFPTxBYtRXT'},\n",
+ " {'external_urls': {'spotify': 'https://open.spotify.com/artist/0TDphr7Qpz3y4s2yhTBVNr'},\n",
+ " 'followers': {'href': None, 'total': 454},\n",
+ " 'genres': [],\n",
+ " 'href': 'https://api.spotify.com/v1/artists/0TDphr7Qpz3y4s2yhTBVNr',\n",
+ " 'id': '0TDphr7Qpz3y4s2yhTBVNr',\n",
+ " 'images': [{'height': 640,\n",
+ " 'url': 'https://i.scdn.co/image/ab6761610000e5eb8ef4fa63c15a643c5c287762',\n",
+ " 'width': 640},\n",
+ " {'height': 320,\n",
+ " 'url': 'https://i.scdn.co/image/ab676161000051748ef4fa63c15a643c5c287762',\n",
+ " 'width': 320},\n",
+ " {'height': 160,\n",
+ " 'url': 'https://i.scdn.co/image/ab6761610000f1788ef4fa63c15a643c5c287762',\n",
+ " 'width': 160}],\n",
+ " 'name': 'Paul Maroon',\n",
+ " 'popularity': 12,\n",
+ " 'type': 'artist',\n",
+ " 'uri': 'spotify:artist:0TDphr7Qpz3y4s2yhTBVNr'},\n",
+ " {'external_urls': {'spotify': 'https://open.spotify.com/artist/4ZMQlzOFrvOftjt1rjl8YR'},\n",
+ " 'followers': {'href': None, 'total': 4061},\n",
+ " 'genres': ['garage psych'],\n",
+ " 'href': 'https://api.spotify.com/v1/artists/4ZMQlzOFrvOftjt1rjl8YR',\n",
+ " 'id': '4ZMQlzOFrvOftjt1rjl8YR',\n",
+ " 'images': [{'height': 640,\n",
+ " 'url': 'https://i.scdn.co/image/ab6761610000e5eb7c7dac3f52ef8ff0aabfdac6',\n",
+ " 'width': 640},\n",
+ " {'height': 320,\n",
+ " 'url': 'https://i.scdn.co/image/ab676161000051747c7dac3f52ef8ff0aabfdac6',\n",
+ " 'width': 320},\n",
+ " {'height': 160,\n",
+ " 'url': 'https://i.scdn.co/image/ab6761610000f1787c7dac3f52ef8ff0aabfdac6',\n",
+ " 'width': 160}],\n",
+ " 'name': 'Peter Matthew Bauer',\n",
+ " 'popularity': 14,\n",
+ " 'type': 'artist',\n",
+ " 'uri': 'spotify:artist:4ZMQlzOFrvOftjt1rjl8YR'},\n",
+ " {'external_urls': {'spotify': 'https://open.spotify.com/artist/6fxk3UXHTFYET8qCT9WlBF'},\n",
+ " 'followers': {'href': None, 'total': 282212},\n",
+ " 'genres': ['chamber pop', 'indie rock', 'kc indie', 'modern folk rock'],\n",
+ " 'href': 'https://api.spotify.com/v1/artists/6fxk3UXHTFYET8qCT9WlBF',\n",
+ " 'id': '6fxk3UXHTFYET8qCT9WlBF',\n",
+ " 'images': [{'height': 640,\n",
+ " 'url': 'https://i.scdn.co/image/ab6761610000e5eb292b964365b5de1a53216852',\n",
+ " 'width': 640},\n",
+ " {'height': 320,\n",
+ " 'url': 'https://i.scdn.co/image/ab67616100005174292b964365b5de1a53216852',\n",
+ " 'width': 320},\n",
+ " {'height': 160,\n",
+ " 'url': 'https://i.scdn.co/image/ab6761610000f178292b964365b5de1a53216852',\n",
+ " 'width': 160}],\n",
+ " 'name': 'Kevin Morby',\n",
+ " 'popularity': 48,\n",
+ " 'type': 'artist',\n",
+ " 'uri': 'spotify:artist:6fxk3UXHTFYET8qCT9WlBF'},\n",
+ " {'external_urls': {'spotify': 'https://open.spotify.com/artist/1HvCWUrKX1xKeT3yQXjPeI'},\n",
+ " 'followers': {'href': None, 'total': 9011},\n",
+ " 'genres': [],\n",
+ " 'href': 'https://api.spotify.com/v1/artists/1HvCWUrKX1xKeT3yQXjPeI',\n",
+ " 'id': '1HvCWUrKX1xKeT3yQXjPeI',\n",
+ " 'images': [{'height': 640,\n",
+ " 'url': 'https://i.scdn.co/image/ab6761610000e5ebe11b3639c8159dbaea0c1243',\n",
+ " 'width': 640},\n",
+ " {'height': 320,\n",
+ " 'url': 'https://i.scdn.co/image/ab67616100005174e11b3639c8159dbaea0c1243',\n",
+ " 'width': 320},\n",
+ " {'height': 160,\n",
+ " 'url': 'https://i.scdn.co/image/ab6761610000f178e11b3639c8159dbaea0c1243',\n",
+ " 'width': 160}],\n",
+ " 'name': 'Walter Martin',\n",
+ " 'popularity': 23,\n",
+ " 'type': 'artist',\n",
+ " 'uri': 'spotify:artist:1HvCWUrKX1xKeT3yQXjPeI'},\n",
+ " {'external_urls': {'spotify': 'https://open.spotify.com/artist/22ojy4H4ZVpowC4lRRC8In'},\n",
+ " 'followers': {'href': None, 'total': 170636},\n",
+ " 'genres': ['art pop',\n",
+ " 'chamber pop',\n",
+ " 'indie rock',\n",
+ " 'indietronica',\n",
+ " 'noise pop',\n",
+ " 'vancouver indie'],\n",
+ " 'href': 'https://api.spotify.com/v1/artists/22ojy4H4ZVpowC4lRRC8In',\n",
+ " 'id': '22ojy4H4ZVpowC4lRRC8In',\n",
+ " 'images': [{'height': 640,\n",
+ " 'url': 'https://i.scdn.co/image/ab6761610000e5eb5a06b396f61778ebc0747b55',\n",
+ " 'width': 640},\n",
+ " {'height': 320,\n",
+ " 'url': 'https://i.scdn.co/image/ab676161000051745a06b396f61778ebc0747b55',\n",
+ " 'width': 320},\n",
+ " {'height': 160,\n",
+ " 'url': 'https://i.scdn.co/image/ab6761610000f1785a06b396f61778ebc0747b55',\n",
+ " 'width': 160}],\n",
+ " 'name': 'Destroyer',\n",
+ " 'popularity': 37,\n",
+ " 'type': 'artist',\n",
+ " 'uri': 'spotify:artist:22ojy4H4ZVpowC4lRRC8In'},\n",
+ " {'external_urls': {'spotify': 'https://open.spotify.com/artist/0XSqX2PB3C5dTMv7SZaxSm'},\n",
+ " 'followers': {'href': None, 'total': 158411},\n",
+ " 'genres': ['canadian indie',\n",
+ " 'indie rock',\n",
+ " 'indietronica',\n",
+ " 'noise pop',\n",
+ " 'quebec indie'],\n",
+ " 'href': 'https://api.spotify.com/v1/artists/0XSqX2PB3C5dTMv7SZaxSm',\n",
+ " 'id': '0XSqX2PB3C5dTMv7SZaxSm',\n",
+ " 'images': [{'height': 640,\n",
+ " 'url': 'https://i.scdn.co/image/ab6761610000e5ebe0ee9d6c0075af4fabb763bb',\n",
+ " 'width': 640},\n",
+ " {'height': 320,\n",
+ " 'url': 'https://i.scdn.co/image/ab67616100005174e0ee9d6c0075af4fabb763bb',\n",
+ " 'width': 320},\n",
+ " {'height': 160,\n",
+ " 'url': 'https://i.scdn.co/image/ab6761610000f178e0ee9d6c0075af4fabb763bb',\n",
+ " 'width': 160}],\n",
+ " 'name': 'Wolf Parade',\n",
+ " 'popularity': 36,\n",
+ " 'type': 'artist',\n",
+ " 'uri': 'spotify:artist:0XSqX2PB3C5dTMv7SZaxSm'},\n",
+ " {'external_urls': {'spotify': 'https://open.spotify.com/artist/5IWCU0V9evBlW4gIeGY4zF'},\n",
+ " 'followers': {'href': None, 'total': 174464},\n",
+ " 'genres': ['alabama indie',\n",
+ " 'art pop',\n",
+ " 'bubblegrunge',\n",
+ " 'chamber pop',\n",
+ " 'countrygaze',\n",
+ " 'indie pop',\n",
+ " 'indie rock'],\n",
+ " 'href': 'https://api.spotify.com/v1/artists/5IWCU0V9evBlW4gIeGY4zF',\n",
+ " 'id': '5IWCU0V9evBlW4gIeGY4zF',\n",
+ " 'images': [{'height': 640,\n",
+ " 'url': 'https://i.scdn.co/image/ab6761610000e5eb7c9318ae648ff7f53c14fdaf',\n",
+ " 'width': 640},\n",
+ " {'height': 320,\n",
+ " 'url': 'https://i.scdn.co/image/ab676161000051747c9318ae648ff7f53c14fdaf',\n",
+ " 'width': 320},\n",
+ " {'height': 160,\n",
+ " 'url': 'https://i.scdn.co/image/ab6761610000f1787c9318ae648ff7f53c14fdaf',\n",
+ " 'width': 160}],\n",
+ " 'name': 'Waxahatchee',\n",
+ " 'popularity': 45,\n",
+ " 'type': 'artist',\n",
+ " 'uri': 'spotify:artist:5IWCU0V9evBlW4gIeGY4zF'},\n",
+ " {'external_urls': {'spotify': 'https://open.spotify.com/artist/7fSjnDr8tBO37Xbb2UXuYr'},\n",
+ " 'followers': {'href': None, 'total': 45012},\n",
+ " 'genres': [],\n",
+ " 'href': 'https://api.spotify.com/v1/artists/7fSjnDr8tBO37Xbb2UXuYr',\n",
+ " 'id': '7fSjnDr8tBO37Xbb2UXuYr',\n",
+ " 'images': [{'height': 640,\n",
+ " 'url': 'https://i.scdn.co/image/ab6761610000e5ebf269afd754a34817acd0b343',\n",
+ " 'width': 640},\n",
+ " {'height': 320,\n",
+ " 'url': 'https://i.scdn.co/image/ab67616100005174f269afd754a34817acd0b343',\n",
+ " 'width': 320},\n",
+ " {'height': 160,\n",
+ " 'url': 'https://i.scdn.co/image/ab6761610000f178f269afd754a34817acd0b343',\n",
+ " 'width': 160}],\n",
+ " 'name': 'Richard Swift',\n",
+ " 'popularity': 35,\n",
+ " 'type': 'artist',\n",
+ " 'uri': 'spotify:artist:7fSjnDr8tBO37Xbb2UXuYr'},\n",
+ " {'external_urls': {'spotify': 'https://open.spotify.com/artist/3zsR0Nsw8G2KuzKSdmosPI'},\n",
+ " 'followers': {'href': None, 'total': 73448},\n",
+ " 'genres': ['indie rock'],\n",
+ " 'href': 'https://api.spotify.com/v1/artists/3zsR0Nsw8G2KuzKSdmosPI',\n",
+ " 'id': '3zsR0Nsw8G2KuzKSdmosPI',\n",
+ " 'images': [{'height': 665,\n",
+ " 'url': 'https://i.scdn.co/image/daf8fa1f9159d424dcaad7e7c1719e82e27d0e21',\n",
+ " 'width': 1000},\n",
+ " {'height': 425,\n",
+ " 'url': 'https://i.scdn.co/image/9509cf0caa26482bb4e89ec24723707520d75f27',\n",
+ " 'width': 640},\n",
+ " {'height': 133,\n",
+ " 'url': 'https://i.scdn.co/image/2f3cddd01c0ffa89bd01908d44d64e2a270703b5',\n",
+ " 'width': 200},\n",
+ " {'height': 43,\n",
+ " 'url': 'https://i.scdn.co/image/9960df72cc54ba146882b172d400d9c2ff5a4116',\n",
+ " 'width': 64}],\n",
+ " 'name': 'EL VY',\n",
+ " 'popularity': 30,\n",
+ " 'type': 'artist',\n",
+ " 'uri': 'spotify:artist:3zsR0Nsw8G2KuzKSdmosPI'},\n",
+ " {'external_urls': {'spotify': 'https://open.spotify.com/artist/4nZTcwItN2j9H21sJBZ2Nq'},\n",
+ " 'followers': {'href': None, 'total': 30686},\n",
+ " 'genres': [],\n",
+ " 'href': 'https://api.spotify.com/v1/artists/4nZTcwItN2j9H21sJBZ2Nq',\n",
+ " 'id': '4nZTcwItN2j9H21sJBZ2Nq',\n",
+ " 'images': [{'height': 1000,\n",
+ " 'url': 'https://i.scdn.co/image/ab6772690000c46cd34be1e044e87be8781dccc8',\n",
+ " 'width': 1000},\n",
+ " {'height': 640,\n",
+ " 'url': 'https://i.scdn.co/image/ab6772690000dd22d34be1e044e87be8781dccc8',\n",
+ " 'width': 640},\n",
+ " {'height': 200,\n",
+ " 'url': 'https://i.scdn.co/image/ab6772690000bac3d34be1e044e87be8781dccc8',\n",
+ " 'width': 200},\n",
+ " {'height': 64,\n",
+ " 'url': 'https://i.scdn.co/image/ab67726900008f74d34be1e044e87be8781dccc8',\n",
+ " 'width': 64}],\n",
+ " 'name': 'Muzz',\n",
+ " 'popularity': 25,\n",
+ " 'type': 'artist',\n",
+ " 'uri': 'spotify:artist:4nZTcwItN2j9H21sJBZ2Nq'},\n",
+ " {'external_urls': {'spotify': 'https://open.spotify.com/artist/2sBPVEeMBXKNsZtYaJixnJ'},\n",
+ " 'followers': {'href': None, 'total': 100019},\n",
+ " 'genres': ['brooklyn indie',\n",
+ " 'chamber pop',\n",
+ " 'freak folk',\n",
+ " 'indie rock',\n",
+ " 'modern folk rock',\n",
+ " 'neo-psychedelic',\n",
+ " 'noise pop'],\n",
+ " 'href': 'https://api.spotify.com/v1/artists/2sBPVEeMBXKNsZtYaJixnJ',\n",
+ " 'id': '2sBPVEeMBXKNsZtYaJixnJ',\n",
+ " 'images': [{'height': 640,\n",
+ " 'url': 'https://i.scdn.co/image/ab6761610000e5eb457ad88617a18d83d7f3bbd3',\n",
+ " 'width': 640},\n",
+ " {'height': 320,\n",
+ " 'url': 'https://i.scdn.co/image/ab67616100005174457ad88617a18d83d7f3bbd3',\n",
+ " 'width': 320},\n",
+ " {'height': 160,\n",
+ " 'url': 'https://i.scdn.co/image/ab6761610000f178457ad88617a18d83d7f3bbd3',\n",
+ " 'width': 160}],\n",
+ " 'name': 'Woods',\n",
+ " 'popularity': 37,\n",
+ " 'type': 'artist',\n",
+ " 'uri': 'spotify:artist:2sBPVEeMBXKNsZtYaJixnJ'},\n",
+ " {'external_urls': {'spotify': 'https://open.spotify.com/artist/27jRNjIvlUcGN7FBRDnqhp'},\n",
+ " 'followers': {'href': None, 'total': 82499},\n",
+ " 'genres': [],\n",
+ " 'href': 'https://api.spotify.com/v1/artists/27jRNjIvlUcGN7FBRDnqhp',\n",
+ " 'id': '27jRNjIvlUcGN7FBRDnqhp',\n",
+ " 'images': [{'height': 640,\n",
+ " 'url': 'https://i.scdn.co/image/ab6761610000e5ebdf796c4a5ad87ff40b45cf8a',\n",
+ " 'width': 640},\n",
+ " {'height': 320,\n",
+ " 'url': 'https://i.scdn.co/image/ab67616100005174df796c4a5ad87ff40b45cf8a',\n",
+ " 'width': 320},\n",
+ " {'height': 160,\n",
+ " 'url': 'https://i.scdn.co/image/ab6761610000f178df796c4a5ad87ff40b45cf8a',\n",
+ " 'width': 160}],\n",
+ " 'name': 'Matt Berninger',\n",
+ " 'popularity': 41,\n",
+ " 'type': 'artist',\n",
+ " 'uri': 'spotify:artist:27jRNjIvlUcGN7FBRDnqhp'},\n",
+ " {'external_urls': {'spotify': 'https://open.spotify.com/artist/1jwOuEBcOKq0BeudSarbEM'},\n",
+ " 'followers': {'href': None, 'total': 68488},\n",
+ " 'genres': ['art pop', 'chamber pop', 'modern psychedelic folk', 'popgaze'],\n",
+ " 'href': 'https://api.spotify.com/v1/artists/1jwOuEBcOKq0BeudSarbEM',\n",
+ " 'id': '1jwOuEBcOKq0BeudSarbEM',\n",
+ " 'images': [{'height': 640,\n",
+ " 'url': 'https://i.scdn.co/image/ab6761610000e5eb875f84589a2d188940634732',\n",
+ " 'width': 640},\n",
+ " {'height': 320,\n",
+ " 'url': 'https://i.scdn.co/image/ab67616100005174875f84589a2d188940634732',\n",
+ " 'width': 320},\n",
+ " {'height': 160,\n",
+ " 'url': 'https://i.scdn.co/image/ab6761610000f178875f84589a2d188940634732',\n",
+ " 'width': 160}],\n",
+ " 'name': 'Amen Dunes',\n",
+ " 'popularity': 33,\n",
+ " 'type': 'artist',\n",
+ " 'uri': 'spotify:artist:1jwOuEBcOKq0BeudSarbEM'},\n",
+ " {'external_urls': {'spotify': 'https://open.spotify.com/artist/2iUVQjheBnvOt8vaBrxXJz'},\n",
+ " 'followers': {'href': None, 'total': 160452},\n",
+ " 'genres': ['baroque pop',\n",
+ " 'chamber pop',\n",
+ " 'indie rock',\n",
+ " 'neo-psychedelic',\n",
+ " 'singer-songwriter'],\n",
+ " 'href': 'https://api.spotify.com/v1/artists/2iUVQjheBnvOt8vaBrxXJz',\n",
+ " 'id': '2iUVQjheBnvOt8vaBrxXJz',\n",
+ " 'images': [{'height': 640,\n",
+ " 'url': 'https://i.scdn.co/image/ab6761610000e5ebe234c3d8b4211a0698827bd3',\n",
+ " 'width': 640},\n",
+ " {'height': 320,\n",
+ " 'url': 'https://i.scdn.co/image/ab67616100005174e234c3d8b4211a0698827bd3',\n",
+ " 'width': 320},\n",
+ " {'height': 160,\n",
+ " 'url': 'https://i.scdn.co/image/ab6761610000f178e234c3d8b4211a0698827bd3',\n",
+ " 'width': 160}],\n",
+ " 'name': 'Cass McCombs',\n",
+ " 'popularity': 49,\n",
+ " 'type': 'artist',\n",
+ " 'uri': 'spotify:artist:2iUVQjheBnvOt8vaBrxXJz'},\n",
+ " {'external_urls': {'spotify': 'https://open.spotify.com/artist/57kIMCLPgkzQlXjblX7XXP'},\n",
+ " 'followers': {'href': None, 'total': 225645},\n",
+ " 'genres': ['alternative americana',\n",
+ " 'chamber pop',\n",
+ " 'countrygaze',\n",
+ " 'indie folk',\n",
+ " 'indie rock',\n",
+ " 'stomp and holler',\n",
+ " 'swedish americana'],\n",
+ " 'href': 'https://api.spotify.com/v1/artists/57kIMCLPgkzQlXjblX7XXP',\n",
+ " 'id': '57kIMCLPgkzQlXjblX7XXP',\n",
+ " 'images': [{'height': 640,\n",
+ " 'url': 'https://i.scdn.co/image/ab6761610000e5eb0695eb77e4b7e89669d83723',\n",
+ " 'width': 640},\n",
+ " {'height': 320,\n",
+ " 'url': 'https://i.scdn.co/image/ab676161000051740695eb77e4b7e89669d83723',\n",
+ " 'width': 320},\n",
+ " {'height': 160,\n",
+ " 'url': 'https://i.scdn.co/image/ab6761610000f1780695eb77e4b7e89669d83723',\n",
+ " 'width': 160}],\n",
+ " 'name': 'Phosphorescent',\n",
+ " 'popularity': 46,\n",
+ " 'type': 'artist',\n",
+ " 'uri': 'spotify:artist:57kIMCLPgkzQlXjblX7XXP'},\n",
+ " {'external_urls': {'spotify': 'https://open.spotify.com/artist/6Qm9stX6XO1a4c7BXQDDgc'},\n",
+ " 'followers': {'href': None, 'total': 168825},\n",
+ " 'genres': ['chamber pop',\n",
+ " 'indie folk',\n",
+ " 'indie rock',\n",
+ " 'new americana',\n",
+ " 'stomp and holler'],\n",
+ " 'href': 'https://api.spotify.com/v1/artists/6Qm9stX6XO1a4c7BXQDDgc',\n",
+ " 'id': '6Qm9stX6XO1a4c7BXQDDgc',\n",
+ " 'images': [{'height': 640,\n",
+ " 'url': 'https://i.scdn.co/image/ab6761610000e5ebfc63c3630989a598f892b93b',\n",
+ " 'width': 640},\n",
+ " {'height': 320,\n",
+ " 'url': 'https://i.scdn.co/image/ab67616100005174fc63c3630989a598f892b93b',\n",
+ " 'width': 320},\n",
+ " {'height': 160,\n",
+ " 'url': 'https://i.scdn.co/image/ab6761610000f178fc63c3630989a598f892b93b',\n",
+ " 'width': 160}],\n",
+ " 'name': 'Fruit Bats',\n",
+ " 'popularity': 52,\n",
+ " 'type': 'artist',\n",
+ " 'uri': 'spotify:artist:6Qm9stX6XO1a4c7BXQDDgc'},\n",
+ " {'external_urls': {'spotify': 'https://open.spotify.com/artist/2rDxtYUzTAYJJE3Bl3Z5IN'},\n",
+ " 'followers': {'href': None, 'total': 88918},\n",
+ " 'genres': ['alternative country',\n",
+ " 'chamber pop',\n",
+ " 'folk',\n",
+ " 'roots rock',\n",
+ " 'singer-songwriter'],\n",
+ " 'href': 'https://api.spotify.com/v1/artists/2rDxtYUzTAYJJE3Bl3Z5IN',\n",
+ " 'id': '2rDxtYUzTAYJJE3Bl3Z5IN',\n",
+ " 'images': [{'height': 640,\n",
+ " 'url': 'https://i.scdn.co/image/ab6761610000e5ebfbddc561042109b5528d43d8',\n",
+ " 'width': 640},\n",
+ " {'height': 320,\n",
+ " 'url': 'https://i.scdn.co/image/ab67616100005174fbddc561042109b5528d43d8',\n",
+ " 'width': 320},\n",
+ " {'height': 160,\n",
+ " 'url': 'https://i.scdn.co/image/ab6761610000f178fbddc561042109b5528d43d8',\n",
+ " 'width': 160}],\n",
+ " 'name': 'Jeff Tweedy',\n",
+ " 'popularity': 40,\n",
+ " 'type': 'artist',\n",
+ " 'uri': 'spotify:artist:2rDxtYUzTAYJJE3Bl3Z5IN'}]}"
+ ]
+ },
+ "execution_count": 13,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "related_artists_json = related_artists_response.json()\n",
+ "related_artists_json"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 14,
+ "id": "6338e607",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "# Voy a coger los top_tracks de mi artista seleccionado:\n",
+ "\n",
+ "def get_top_tracks(artist_id):\n",
+ " resource = \"artists\"\n",
+ " parameters = f\"/{artist_id}/top-tracks?market=ES\"\n",
+ " url = base_url + resource + parameters\n",
+ " response = requests.get(url, headers=header_info).json()\n",
+ " df_tracks = pd.DataFrame(response[\"tracks\"])[[\"id\", \"href\", \"name\", \"uri\"]]\n",
+ " return df_tracks"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 15,
+ "id": "010335e3",
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "pandas.core.frame.DataFrame"
+ ]
+ },
+ "execution_count": 15,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "top_tracks_artist = get_top_tracks(\"3ZXXJ9nO1Dn9B0AJ25eAQY\")\n",
+ "type(top_tracks_artist)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 16,
+ "id": "a2896c59",
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "'\\ntop_tracks_artist = top_tracks_artist.rename(columns = {\"id\": \"original_artist_id\",\\n \"name\":\"original_artist_name\",\\n \"genres\":\"original_artist_genres\",\\n \"popularity\": \"original_artist_popularity\",\\n \"followers\": \"original_artist_followers\"\\n })\\n \\n'"
+ ]
+ },
+ "execution_count": 16,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "\"\"\"\n",
+ "top_tracks_artist = top_tracks_artist.rename(columns = {\"id\": \"original_artist_id\",\n",
+ " \"name\":\"original_artist_name\",\n",
+ " \"genres\":\"original_artist_genres\",\n",
+ " \"popularity\": \"original_artist_popularity\",\n",
+ " \"followers\": \"original_artist_followers\"\n",
+ " })\n",
+ " \n",
+ "\"\"\""
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 17,
+ "id": "0383ed82",
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "
\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " id | \n",
+ " href | \n",
+ " name | \n",
+ " uri | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | 0 | \n",
+ " 7dfQNWgVxikbrdvEmsfPMA | \n",
+ " https://api.spotify.com/v1/tracks/7dfQNWgVxikb... | \n",
+ " A 1000 Times | \n",
+ " spotify:track:7dfQNWgVxikbrdvEmsfPMA | \n",
+ "
\n",
+ " \n",
+ " | 1 | \n",
+ " 2ZBzOL0HTCQCw7W3luTZtB | \n",
+ " https://api.spotify.com/v1/tracks/2ZBzOL0HTCQC... | \n",
+ " In a Black Out | \n",
+ " spotify:track:2ZBzOL0HTCQCw7W3luTZtB | \n",
+ "
\n",
+ " \n",
+ " | 2 | \n",
+ " 6UuOsC3oeu6SgC6mono7XS | \n",
+ " https://api.spotify.com/v1/tracks/6UuOsC3oeu6S... | \n",
+ " When the Truth Is... | \n",
+ " spotify:track:6UuOsC3oeu6SgC6mono7XS | \n",
+ "
\n",
+ " \n",
+ " | 3 | \n",
+ " 60y3z4xCQhmhQ7cwqHGKzo | \n",
+ " https://api.spotify.com/v1/tracks/60y3z4xCQhmh... | \n",
+ " Here They Come | \n",
+ " spotify:track:60y3z4xCQhmhQ7cwqHGKzo | \n",
+ "
\n",
+ " \n",
+ " | 4 | \n",
+ " 27NWwTGqZSd0WsNi4NxJaA | \n",
+ " https://api.spotify.com/v1/tracks/27NWwTGqZSd0... | \n",
+ " Sick as a Dog | \n",
+ " spotify:track:27NWwTGqZSd0WsNi4NxJaA | \n",
+ "
\n",
+ " \n",
+ " | 5 | \n",
+ " 4O8uW41RxfVF6AJRehcG9W | \n",
+ " https://api.spotify.com/v1/tracks/4O8uW41RxfVF... | \n",
+ " Virginia Beach | \n",
+ " spotify:track:4O8uW41RxfVF6AJRehcG9W | \n",
+ "
\n",
+ " \n",
+ " | 6 | \n",
+ " 0GMe0UKs0YDq5OHGnrEu22 | \n",
+ " https://api.spotify.com/v1/tracks/0GMe0UKs0YDq... | \n",
+ " The Silent Orchestra | \n",
+ " spotify:track:0GMe0UKs0YDq5OHGnrEu22 | \n",
+ "
\n",
+ " \n",
+ " | 7 | \n",
+ " 2aoPczdg7KqPieRRCBePkq | \n",
+ " https://api.spotify.com/v1/tracks/2aoPczdg7KqP... | \n",
+ " Heartstruck (Wild Hunger) | \n",
+ " spotify:track:2aoPczdg7KqPieRRCBePkq | \n",
+ "
\n",
+ " \n",
+ " | 8 | \n",
+ " 3s9bSPogDpCCNhbAcmKHor | \n",
+ " https://api.spotify.com/v1/tracks/3s9bSPogDpCC... | \n",
+ " 1959 | \n",
+ " spotify:track:3s9bSPogDpCCNhbAcmKHor | \n",
+ "
\n",
+ " \n",
+ " | 9 | \n",
+ " 5cqrgqsNudu6qV2vjJyUML | \n",
+ " https://api.spotify.com/v1/tracks/5cqrgqsNudu6... | \n",
+ " The Bride's Dad | \n",
+ " spotify:track:5cqrgqsNudu6qV2vjJyUML | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " id href \\\n",
+ "0 7dfQNWgVxikbrdvEmsfPMA https://api.spotify.com/v1/tracks/7dfQNWgVxikb... \n",
+ "1 2ZBzOL0HTCQCw7W3luTZtB https://api.spotify.com/v1/tracks/2ZBzOL0HTCQC... \n",
+ "2 6UuOsC3oeu6SgC6mono7XS https://api.spotify.com/v1/tracks/6UuOsC3oeu6S... \n",
+ "3 60y3z4xCQhmhQ7cwqHGKzo https://api.spotify.com/v1/tracks/60y3z4xCQhmh... \n",
+ "4 27NWwTGqZSd0WsNi4NxJaA https://api.spotify.com/v1/tracks/27NWwTGqZSd0... \n",
+ "5 4O8uW41RxfVF6AJRehcG9W https://api.spotify.com/v1/tracks/4O8uW41RxfVF... \n",
+ "6 0GMe0UKs0YDq5OHGnrEu22 https://api.spotify.com/v1/tracks/0GMe0UKs0YDq... \n",
+ "7 2aoPczdg7KqPieRRCBePkq https://api.spotify.com/v1/tracks/2aoPczdg7KqP... \n",
+ "8 3s9bSPogDpCCNhbAcmKHor https://api.spotify.com/v1/tracks/3s9bSPogDpCC... \n",
+ "9 5cqrgqsNudu6qV2vjJyUML https://api.spotify.com/v1/tracks/5cqrgqsNudu6... \n",
+ "\n",
+ " name uri \n",
+ "0 A 1000 Times spotify:track:7dfQNWgVxikbrdvEmsfPMA \n",
+ "1 In a Black Out spotify:track:2ZBzOL0HTCQCw7W3luTZtB \n",
+ "2 When the Truth Is... spotify:track:6UuOsC3oeu6SgC6mono7XS \n",
+ "3 Here They Come spotify:track:60y3z4xCQhmhQ7cwqHGKzo \n",
+ "4 Sick as a Dog spotify:track:27NWwTGqZSd0WsNi4NxJaA \n",
+ "5 Virginia Beach spotify:track:4O8uW41RxfVF6AJRehcG9W \n",
+ "6 The Silent Orchestra spotify:track:0GMe0UKs0YDq5OHGnrEu22 \n",
+ "7 Heartstruck (Wild Hunger) spotify:track:2aoPczdg7KqPieRRCBePkq \n",
+ "8 1959 spotify:track:3s9bSPogDpCCNhbAcmKHor \n",
+ "9 The Bride's Dad spotify:track:5cqrgqsNudu6qV2vjJyUML "
+ ]
+ },
+ "execution_count": 17,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "top_tracks_artist"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 18,
+ "id": "75d9720a",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "#Ahora voy a sacar los artistas relacionados con sus id.\n",
+ "def get_related_artists(artist_id):\n",
+ " parameters = f\"/{artist_id}/related-artists\"\n",
+ " url = base_url + resource + parameters\n",
+ " response = related_artists_json\n",
+ " df_related_artists= pd.DataFrame(response[\"artists\"])[[\"id\", \"name\"]]\n",
+ " df_related_artists\n",
+ " return df_related_artists"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 19,
+ "id": "9e5d3b93",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "df_related_artists = get_related_artists(\"3ZXXJ9nO1Dn9B0AJ25eAQY\")"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 20,
+ "id": "464f237b",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "df_related_artists = df_related_artists.drop(0)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 21,
+ "id": "36cd6bc7",
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " id | \n",
+ " name | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | 1 | \n",
+ " 6kFay2DQ5aZfeu5OsrF3Pw | \n",
+ " The Walkmen | \n",
+ "
\n",
+ " \n",
+ " | 2 | \n",
+ " 04XggbrM51GcFPTxBYtRXT | \n",
+ " Rostam | \n",
+ "
\n",
+ " \n",
+ " | 3 | \n",
+ " 0TDphr7Qpz3y4s2yhTBVNr | \n",
+ " Paul Maroon | \n",
+ "
\n",
+ " \n",
+ " | 4 | \n",
+ " 4ZMQlzOFrvOftjt1rjl8YR | \n",
+ " Peter Matthew Bauer | \n",
+ "
\n",
+ " \n",
+ " | 5 | \n",
+ " 6fxk3UXHTFYET8qCT9WlBF | \n",
+ " Kevin Morby | \n",
+ "
\n",
+ " \n",
+ " | 6 | \n",
+ " 1HvCWUrKX1xKeT3yQXjPeI | \n",
+ " Walter Martin | \n",
+ "
\n",
+ " \n",
+ " | 7 | \n",
+ " 22ojy4H4ZVpowC4lRRC8In | \n",
+ " Destroyer | \n",
+ "
\n",
+ " \n",
+ " | 8 | \n",
+ " 0XSqX2PB3C5dTMv7SZaxSm | \n",
+ " Wolf Parade | \n",
+ "
\n",
+ " \n",
+ " | 9 | \n",
+ " 5IWCU0V9evBlW4gIeGY4zF | \n",
+ " Waxahatchee | \n",
+ "
\n",
+ " \n",
+ " | 10 | \n",
+ " 7fSjnDr8tBO37Xbb2UXuYr | \n",
+ " Richard Swift | \n",
+ "
\n",
+ " \n",
+ " | 11 | \n",
+ " 3zsR0Nsw8G2KuzKSdmosPI | \n",
+ " EL VY | \n",
+ "
\n",
+ " \n",
+ " | 12 | \n",
+ " 4nZTcwItN2j9H21sJBZ2Nq | \n",
+ " Muzz | \n",
+ "
\n",
+ " \n",
+ " | 13 | \n",
+ " 2sBPVEeMBXKNsZtYaJixnJ | \n",
+ " Woods | \n",
+ "
\n",
+ " \n",
+ " | 14 | \n",
+ " 27jRNjIvlUcGN7FBRDnqhp | \n",
+ " Matt Berninger | \n",
+ "
\n",
+ " \n",
+ " | 15 | \n",
+ " 1jwOuEBcOKq0BeudSarbEM | \n",
+ " Amen Dunes | \n",
+ "
\n",
+ " \n",
+ " | 16 | \n",
+ " 2iUVQjheBnvOt8vaBrxXJz | \n",
+ " Cass McCombs | \n",
+ "
\n",
+ " \n",
+ " | 17 | \n",
+ " 57kIMCLPgkzQlXjblX7XXP | \n",
+ " Phosphorescent | \n",
+ "
\n",
+ " \n",
+ " | 18 | \n",
+ " 6Qm9stX6XO1a4c7BXQDDgc | \n",
+ " Fruit Bats | \n",
+ "
\n",
+ " \n",
+ " | 19 | \n",
+ " 2rDxtYUzTAYJJE3Bl3Z5IN | \n",
+ " Jeff Tweedy | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " id name\n",
+ "1 6kFay2DQ5aZfeu5OsrF3Pw The Walkmen\n",
+ "2 04XggbrM51GcFPTxBYtRXT Rostam\n",
+ "3 0TDphr7Qpz3y4s2yhTBVNr Paul Maroon\n",
+ "4 4ZMQlzOFrvOftjt1rjl8YR Peter Matthew Bauer\n",
+ "5 6fxk3UXHTFYET8qCT9WlBF Kevin Morby\n",
+ "6 1HvCWUrKX1xKeT3yQXjPeI Walter Martin\n",
+ "7 22ojy4H4ZVpowC4lRRC8In Destroyer\n",
+ "8 0XSqX2PB3C5dTMv7SZaxSm Wolf Parade\n",
+ "9 5IWCU0V9evBlW4gIeGY4zF Waxahatchee\n",
+ "10 7fSjnDr8tBO37Xbb2UXuYr Richard Swift\n",
+ "11 3zsR0Nsw8G2KuzKSdmosPI EL VY\n",
+ "12 4nZTcwItN2j9H21sJBZ2Nq Muzz\n",
+ "13 2sBPVEeMBXKNsZtYaJixnJ Woods\n",
+ "14 27jRNjIvlUcGN7FBRDnqhp Matt Berninger\n",
+ "15 1jwOuEBcOKq0BeudSarbEM Amen Dunes\n",
+ "16 2iUVQjheBnvOt8vaBrxXJz Cass McCombs\n",
+ "17 57kIMCLPgkzQlXjblX7XXP Phosphorescent\n",
+ "18 6Qm9stX6XO1a4c7BXQDDgc Fruit Bats\n",
+ "19 2rDxtYUzTAYJJE3Bl3Z5IN Jeff Tweedy"
+ ]
+ },
+ "execution_count": 21,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "df_related_artists"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 22,
+ "id": "f72b0593",
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "1 6kFay2DQ5aZfeu5OsrF3Pw\n",
+ "2 04XggbrM51GcFPTxBYtRXT\n",
+ "3 0TDphr7Qpz3y4s2yhTBVNr\n",
+ "4 4ZMQlzOFrvOftjt1rjl8YR\n",
+ "5 6fxk3UXHTFYET8qCT9WlBF\n",
+ "6 1HvCWUrKX1xKeT3yQXjPeI\n",
+ "7 22ojy4H4ZVpowC4lRRC8In\n",
+ "8 0XSqX2PB3C5dTMv7SZaxSm\n",
+ "9 5IWCU0V9evBlW4gIeGY4zF\n",
+ "10 7fSjnDr8tBO37Xbb2UXuYr\n",
+ "11 3zsR0Nsw8G2KuzKSdmosPI\n",
+ "12 4nZTcwItN2j9H21sJBZ2Nq\n",
+ "13 2sBPVEeMBXKNsZtYaJixnJ\n",
+ "14 27jRNjIvlUcGN7FBRDnqhp\n",
+ "15 1jwOuEBcOKq0BeudSarbEM\n",
+ "16 2iUVQjheBnvOt8vaBrxXJz\n",
+ "17 57kIMCLPgkzQlXjblX7XXP\n",
+ "18 6Qm9stX6XO1a4c7BXQDDgc\n",
+ "19 2rDxtYUzTAYJJE3Bl3Z5IN\n",
+ "Name: id, dtype: object"
+ ]
+ },
+ "execution_count": 22,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "df_related_artists[\"id\"]"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 23,
+ "id": "3b3e282c",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "#Voy a sacar un df con las top-tracks de cada uno de ellos."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 24,
+ "id": "ffe9fb2c",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "def make_playlist(dataframe):\n",
+ " playlist = pd.DataFrame() \n",
+ " for artist_id in dataframe:\n",
+ " artist_name = df_related_artists[df_related_artists[\"id\"] == artist_id][\"name\"].values[0]\n",
+ " top_tracks = get_top_tracks(artist_id)\n",
+ " top_tracks[\"artist_name\"] = artist_name\n",
+ " playlist = pd.concat([playlist, top_tracks])\n",
+ " playlist = playlist.reset_index(drop=True)\n",
+ " return playlist"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 25,
+ "id": "39be86d6",
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " id | \n",
+ " href | \n",
+ " name | \n",
+ " uri | \n",
+ " artist_name | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | 0 | \n",
+ " 2YIOkqKgg3jZEFoL5qcEPT | \n",
+ " https://api.spotify.com/v1/tracks/2YIOkqKgg3jZ... | \n",
+ " The Rat | \n",
+ " spotify:track:2YIOkqKgg3jZEFoL5qcEPT | \n",
+ " The Walkmen | \n",
+ "
\n",
+ " \n",
+ " | 1 | \n",
+ " 3ji1o94rKqulYA4I2eDKat | \n",
+ " https://api.spotify.com/v1/tracks/3ji1o94rKqul... | \n",
+ " Heaven | \n",
+ " spotify:track:3ji1o94rKqulYA4I2eDKat | \n",
+ " The Walkmen | \n",
+ "
\n",
+ " \n",
+ " | 2 | \n",
+ " 1BoH28Sopj6wkd1Fbb5B0K | \n",
+ " https://api.spotify.com/v1/tracks/1BoH28Sopj6w... | \n",
+ " We've Been Had | \n",
+ " spotify:track:1BoH28Sopj6wkd1Fbb5B0K | \n",
+ " The Walkmen | \n",
+ "
\n",
+ " \n",
+ " | 3 | \n",
+ " 1cLq7fqXkTWenCCUdogdbD | \n",
+ " https://api.spotify.com/v1/tracks/1cLq7fqXkTWe... | \n",
+ " On The Water | \n",
+ " spotify:track:1cLq7fqXkTWenCCUdogdbD | \n",
+ " The Walkmen | \n",
+ "
\n",
+ " \n",
+ " | 4 | \n",
+ " 2CDdxtnp24GCx6uqxkjbco | \n",
+ " https://api.spotify.com/v1/tracks/2CDdxtnp24GC... | \n",
+ " Red Moon | \n",
+ " spotify:track:2CDdxtnp24GCx6uqxkjbco | \n",
+ " The Walkmen | \n",
+ "
\n",
+ " \n",
+ " | 5 | \n",
+ " 4KlEGra3FXtqfaGfx4k9He | \n",
+ " https://api.spotify.com/v1/tracks/4KlEGra3FXtq... | \n",
+ " They're Winning | \n",
+ " spotify:track:4KlEGra3FXtqfaGfx4k9He | \n",
+ " The Walkmen | \n",
+ "
\n",
+ " \n",
+ " | 6 | \n",
+ " 2iSMH5kI4Ge0PPuS8xlmWb | \n",
+ " https://api.spotify.com/v1/tracks/2iSMH5kI4Ge0... | \n",
+ " In The New Year | \n",
+ " spotify:track:2iSMH5kI4Ge0PPuS8xlmWb | \n",
+ " The Walkmen | \n",
+ "
\n",
+ " \n",
+ " | 7 | \n",
+ " 2DhBFr722vzR5VF4V2AalW | \n",
+ " https://api.spotify.com/v1/tracks/2DhBFr722vzR... | \n",
+ " The Witch | \n",
+ " spotify:track:2DhBFr722vzR5VF4V2AalW | \n",
+ " The Walkmen | \n",
+ "
\n",
+ " \n",
+ " | 8 | \n",
+ " 3308hstupmMUcRwbam0EPs | \n",
+ " https://api.spotify.com/v1/tracks/3308hstupmMU... | \n",
+ " Another One Goes By | \n",
+ " spotify:track:3308hstupmMUcRwbam0EPs | \n",
+ " The Walkmen | \n",
+ "
\n",
+ " \n",
+ " | 9 | \n",
+ " 5SVbK6xHvb8Lru8YfBeEFI | \n",
+ " https://api.spotify.com/v1/tracks/5SVbK6xHvb8L... | \n",
+ " Angela Surf City | \n",
+ " spotify:track:5SVbK6xHvb8Lru8YfBeEFI | \n",
+ " The Walkmen | \n",
+ "
\n",
+ " \n",
+ " | 10 | \n",
+ " 7dfQNWgVxikbrdvEmsfPMA | \n",
+ " https://api.spotify.com/v1/tracks/7dfQNWgVxikb... | \n",
+ " A 1000 Times | \n",
+ " spotify:track:7dfQNWgVxikbrdvEmsfPMA | \n",
+ " Rostam | \n",
+ "
\n",
+ " \n",
+ " | 11 | \n",
+ " 2ZBzOL0HTCQCw7W3luTZtB | \n",
+ " https://api.spotify.com/v1/tracks/2ZBzOL0HTCQC... | \n",
+ " In a Black Out | \n",
+ " spotify:track:2ZBzOL0HTCQCw7W3luTZtB | \n",
+ " Rostam | \n",
+ "
\n",
+ " \n",
+ " | 12 | \n",
+ " 7gmusWQX2xxYxda2ba10N5 | \n",
+ " https://api.spotify.com/v1/tracks/7gmusWQX2xxY... | \n",
+ " Water | \n",
+ " spotify:track:7gmusWQX2xxYxda2ba10N5 | \n",
+ " Rostam | \n",
+ "
\n",
+ " \n",
+ " | 13 | \n",
+ " 3mPEQcWspL9kFSUQ35bks5 | \n",
+ " https://api.spotify.com/v1/tracks/3mPEQcWspL9k... | \n",
+ " In a River (Acoustic) | \n",
+ " spotify:track:3mPEQcWspL9kFSUQ35bks5 | \n",
+ " Rostam | \n",
+ "
\n",
+ " \n",
+ " | 14 | \n",
+ " 5eum0L07wuKd7Agse5Lgy1 | \n",
+ " https://api.spotify.com/v1/tracks/5eum0L07wuKd... | \n",
+ " In a River | \n",
+ " spotify:track:5eum0L07wuKd7Agse5Lgy1 | \n",
+ " Rostam | \n",
+ "
\n",
+ " \n",
+ " | 15 | \n",
+ " 1acb8u70kClk6NjITaZyuG | \n",
+ " https://api.spotify.com/v1/tracks/1acb8u70kClk... | \n",
+ " Bike Dream | \n",
+ " spotify:track:1acb8u70kClk6NjITaZyuG | \n",
+ " Rostam | \n",
+ "
\n",
+ " \n",
+ " | 16 | \n",
+ " 6OrLovzoCKCwsiGYydDpKt | \n",
+ " https://api.spotify.com/v1/tracks/6OrLovzoCKCw... | \n",
+ " From the Back of a Cab - Ben Böhmer Remix | \n",
+ " spotify:track:6OrLovzoCKCwsiGYydDpKt | \n",
+ " Rostam | \n",
+ "
\n",
+ " \n",
+ " | 17 | \n",
+ " 3kduxaRADVX6gVfZ6IeqcB | \n",
+ " https://api.spotify.com/v1/tracks/3kduxaRADVX6... | \n",
+ " 4Runner | \n",
+ " spotify:track:3kduxaRADVX6gVfZ6IeqcB | \n",
+ " Rostam | \n",
+ "
\n",
+ " \n",
+ " | 18 | \n",
+ " 6UuOsC3oeu6SgC6mono7XS | \n",
+ " https://api.spotify.com/v1/tracks/6UuOsC3oeu6S... | \n",
+ " When the Truth Is... | \n",
+ " spotify:track:6UuOsC3oeu6SgC6mono7XS | \n",
+ " Rostam | \n",
+ "
\n",
+ " \n",
+ " | 19 | \n",
+ " 0DgWa8oXi3wn3Q67MaHRdw | \n",
+ " https://api.spotify.com/v1/tracks/0DgWa8oXi3wn... | \n",
+ " Half-Light (feat. Kelly Zutrau) | \n",
+ " spotify:track:0DgWa8oXi3wn3Q67MaHRdw | \n",
+ " Rostam | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " id href \\\n",
+ "0 2YIOkqKgg3jZEFoL5qcEPT https://api.spotify.com/v1/tracks/2YIOkqKgg3jZ... \n",
+ "1 3ji1o94rKqulYA4I2eDKat https://api.spotify.com/v1/tracks/3ji1o94rKqul... \n",
+ "2 1BoH28Sopj6wkd1Fbb5B0K https://api.spotify.com/v1/tracks/1BoH28Sopj6w... \n",
+ "3 1cLq7fqXkTWenCCUdogdbD https://api.spotify.com/v1/tracks/1cLq7fqXkTWe... \n",
+ "4 2CDdxtnp24GCx6uqxkjbco https://api.spotify.com/v1/tracks/2CDdxtnp24GC... \n",
+ "5 4KlEGra3FXtqfaGfx4k9He https://api.spotify.com/v1/tracks/4KlEGra3FXtq... \n",
+ "6 2iSMH5kI4Ge0PPuS8xlmWb https://api.spotify.com/v1/tracks/2iSMH5kI4Ge0... \n",
+ "7 2DhBFr722vzR5VF4V2AalW https://api.spotify.com/v1/tracks/2DhBFr722vzR... \n",
+ "8 3308hstupmMUcRwbam0EPs https://api.spotify.com/v1/tracks/3308hstupmMU... \n",
+ "9 5SVbK6xHvb8Lru8YfBeEFI https://api.spotify.com/v1/tracks/5SVbK6xHvb8L... \n",
+ "10 7dfQNWgVxikbrdvEmsfPMA https://api.spotify.com/v1/tracks/7dfQNWgVxikb... \n",
+ "11 2ZBzOL0HTCQCw7W3luTZtB https://api.spotify.com/v1/tracks/2ZBzOL0HTCQC... \n",
+ "12 7gmusWQX2xxYxda2ba10N5 https://api.spotify.com/v1/tracks/7gmusWQX2xxY... \n",
+ "13 3mPEQcWspL9kFSUQ35bks5 https://api.spotify.com/v1/tracks/3mPEQcWspL9k... \n",
+ "14 5eum0L07wuKd7Agse5Lgy1 https://api.spotify.com/v1/tracks/5eum0L07wuKd... \n",
+ "15 1acb8u70kClk6NjITaZyuG https://api.spotify.com/v1/tracks/1acb8u70kClk... \n",
+ "16 6OrLovzoCKCwsiGYydDpKt https://api.spotify.com/v1/tracks/6OrLovzoCKCw... \n",
+ "17 3kduxaRADVX6gVfZ6IeqcB https://api.spotify.com/v1/tracks/3kduxaRADVX6... \n",
+ "18 6UuOsC3oeu6SgC6mono7XS https://api.spotify.com/v1/tracks/6UuOsC3oeu6S... \n",
+ "19 0DgWa8oXi3wn3Q67MaHRdw https://api.spotify.com/v1/tracks/0DgWa8oXi3wn... \n",
+ "\n",
+ " name \\\n",
+ "0 The Rat \n",
+ "1 Heaven \n",
+ "2 We've Been Had \n",
+ "3 On The Water \n",
+ "4 Red Moon \n",
+ "5 They're Winning \n",
+ "6 In The New Year \n",
+ "7 The Witch \n",
+ "8 Another One Goes By \n",
+ "9 Angela Surf City \n",
+ "10 A 1000 Times \n",
+ "11 In a Black Out \n",
+ "12 Water \n",
+ "13 In a River (Acoustic) \n",
+ "14 In a River \n",
+ "15 Bike Dream \n",
+ "16 From the Back of a Cab - Ben Böhmer Remix \n",
+ "17 4Runner \n",
+ "18 When the Truth Is... \n",
+ "19 Half-Light (feat. Kelly Zutrau) \n",
+ "\n",
+ " uri artist_name \n",
+ "0 spotify:track:2YIOkqKgg3jZEFoL5qcEPT The Walkmen \n",
+ "1 spotify:track:3ji1o94rKqulYA4I2eDKat The Walkmen \n",
+ "2 spotify:track:1BoH28Sopj6wkd1Fbb5B0K The Walkmen \n",
+ "3 spotify:track:1cLq7fqXkTWenCCUdogdbD The Walkmen \n",
+ "4 spotify:track:2CDdxtnp24GCx6uqxkjbco The Walkmen \n",
+ "5 spotify:track:4KlEGra3FXtqfaGfx4k9He The Walkmen \n",
+ "6 spotify:track:2iSMH5kI4Ge0PPuS8xlmWb The Walkmen \n",
+ "7 spotify:track:2DhBFr722vzR5VF4V2AalW The Walkmen \n",
+ "8 spotify:track:3308hstupmMUcRwbam0EPs The Walkmen \n",
+ "9 spotify:track:5SVbK6xHvb8Lru8YfBeEFI The Walkmen \n",
+ "10 spotify:track:7dfQNWgVxikbrdvEmsfPMA Rostam \n",
+ "11 spotify:track:2ZBzOL0HTCQCw7W3luTZtB Rostam \n",
+ "12 spotify:track:7gmusWQX2xxYxda2ba10N5 Rostam \n",
+ "13 spotify:track:3mPEQcWspL9kFSUQ35bks5 Rostam \n",
+ "14 spotify:track:5eum0L07wuKd7Agse5Lgy1 Rostam \n",
+ "15 spotify:track:1acb8u70kClk6NjITaZyuG Rostam \n",
+ "16 spotify:track:6OrLovzoCKCwsiGYydDpKt Rostam \n",
+ "17 spotify:track:3kduxaRADVX6gVfZ6IeqcB Rostam \n",
+ "18 spotify:track:6UuOsC3oeu6SgC6mono7XS Rostam \n",
+ "19 spotify:track:0DgWa8oXi3wn3Q67MaHRdw Rostam "
+ ]
+ },
+ "execution_count": 25,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "playlist = make_playlist(df_related_artists[\"id\"])\n",
+ "playlist.head(20)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 26,
+ "id": "56c53536",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "#Ahora me voy a quedar sólo con las columnas que quiero\n",
+ "\n",
+ "playlist = playlist.drop(\"href\", axis = 1)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 27,
+ "id": "94a5519e",
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " id | \n",
+ " name | \n",
+ " uri | \n",
+ " artist_name | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | 0 | \n",
+ " 2YIOkqKgg3jZEFoL5qcEPT | \n",
+ " The Rat | \n",
+ " spotify:track:2YIOkqKgg3jZEFoL5qcEPT | \n",
+ " The Walkmen | \n",
+ "
\n",
+ " \n",
+ " | 1 | \n",
+ " 3ji1o94rKqulYA4I2eDKat | \n",
+ " Heaven | \n",
+ " spotify:track:3ji1o94rKqulYA4I2eDKat | \n",
+ " The Walkmen | \n",
+ "
\n",
+ " \n",
+ " | 2 | \n",
+ " 1BoH28Sopj6wkd1Fbb5B0K | \n",
+ " We've Been Had | \n",
+ " spotify:track:1BoH28Sopj6wkd1Fbb5B0K | \n",
+ " The Walkmen | \n",
+ "
\n",
+ " \n",
+ " | 3 | \n",
+ " 1cLq7fqXkTWenCCUdogdbD | \n",
+ " On The Water | \n",
+ " spotify:track:1cLq7fqXkTWenCCUdogdbD | \n",
+ " The Walkmen | \n",
+ "
\n",
+ " \n",
+ " | 4 | \n",
+ " 2CDdxtnp24GCx6uqxkjbco | \n",
+ " Red Moon | \n",
+ " spotify:track:2CDdxtnp24GCx6uqxkjbco | \n",
+ " The Walkmen | \n",
+ "
\n",
+ " \n",
+ " | ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ "
\n",
+ " \n",
+ " | 185 | \n",
+ " 64Eddq5GDqysRp5LV6p1gE | \n",
+ " Long Black Veil | \n",
+ " spotify:track:64Eddq5GDqysRp5LV6p1gE | \n",
+ " Jeff Tweedy | \n",
+ "
\n",
+ " \n",
+ " | 186 | \n",
+ " 6VxW98Zfexy6LKeCxlVz8g | \n",
+ " Low Key | \n",
+ " spotify:track:6VxW98Zfexy6LKeCxlVz8g | \n",
+ " Jeff Tweedy | \n",
+ "
\n",
+ " \n",
+ " | 187 | \n",
+ " 1x3uCuAcNVZvSwd4WFDzRR | \n",
+ " Warm (When The Sun Has Died) | \n",
+ " spotify:track:1x3uCuAcNVZvSwd4WFDzRR | \n",
+ " Jeff Tweedy | \n",
+ "
\n",
+ " \n",
+ " | 188 | \n",
+ " 2LjpcdgyjRIIoGUDwDk2kL | \n",
+ " I Am Trying to Break Your Heart | \n",
+ " spotify:track:2LjpcdgyjRIIoGUDwDk2kL | \n",
+ " Jeff Tweedy | \n",
+ "
\n",
+ " \n",
+ " | 189 | \n",
+ " 0zRooGATNcoPQpSsT6Egsc | \n",
+ " The Ballad of the Opening Band | \n",
+ " spotify:track:0zRooGATNcoPQpSsT6Egsc | \n",
+ " Jeff Tweedy | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
190 rows × 4 columns
\n",
+ "
"
+ ],
+ "text/plain": [
+ " id name \\\n",
+ "0 2YIOkqKgg3jZEFoL5qcEPT The Rat \n",
+ "1 3ji1o94rKqulYA4I2eDKat Heaven \n",
+ "2 1BoH28Sopj6wkd1Fbb5B0K We've Been Had \n",
+ "3 1cLq7fqXkTWenCCUdogdbD On The Water \n",
+ "4 2CDdxtnp24GCx6uqxkjbco Red Moon \n",
+ ".. ... ... \n",
+ "185 64Eddq5GDqysRp5LV6p1gE Long Black Veil \n",
+ "186 6VxW98Zfexy6LKeCxlVz8g Low Key \n",
+ "187 1x3uCuAcNVZvSwd4WFDzRR Warm (When The Sun Has Died) \n",
+ "188 2LjpcdgyjRIIoGUDwDk2kL I Am Trying to Break Your Heart \n",
+ "189 0zRooGATNcoPQpSsT6Egsc The Ballad of the Opening Band \n",
+ "\n",
+ " uri artist_name \n",
+ "0 spotify:track:2YIOkqKgg3jZEFoL5qcEPT The Walkmen \n",
+ "1 spotify:track:3ji1o94rKqulYA4I2eDKat The Walkmen \n",
+ "2 spotify:track:1BoH28Sopj6wkd1Fbb5B0K The Walkmen \n",
+ "3 spotify:track:1cLq7fqXkTWenCCUdogdbD The Walkmen \n",
+ "4 spotify:track:2CDdxtnp24GCx6uqxkjbco The Walkmen \n",
+ ".. ... ... \n",
+ "185 spotify:track:64Eddq5GDqysRp5LV6p1gE Jeff Tweedy \n",
+ "186 spotify:track:6VxW98Zfexy6LKeCxlVz8g Jeff Tweedy \n",
+ "187 spotify:track:1x3uCuAcNVZvSwd4WFDzRR Jeff Tweedy \n",
+ "188 spotify:track:2LjpcdgyjRIIoGUDwDk2kL Jeff Tweedy \n",
+ "189 spotify:track:0zRooGATNcoPQpSsT6Egsc Jeff Tweedy \n",
+ "\n",
+ "[190 rows x 4 columns]"
+ ]
+ },
+ "execution_count": 27,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "playlist"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 47,
+ "id": "5c5c7ec8",
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "0 spotify:track:2YIOkqKgg3jZEFoL5qcEPT\n",
+ "1 spotify:track:3ji1o94rKqulYA4I2eDKat\n",
+ "2 spotify:track:1BoH28Sopj6wkd1Fbb5B0K\n",
+ "3 spotify:track:1cLq7fqXkTWenCCUdogdbD\n",
+ "4 spotify:track:2CDdxtnp24GCx6uqxkjbco\n",
+ " ... \n",
+ "185 spotify:track:64Eddq5GDqysRp5LV6p1gE\n",
+ "186 spotify:track:6VxW98Zfexy6LKeCxlVz8g\n",
+ "187 spotify:track:1x3uCuAcNVZvSwd4WFDzRR\n",
+ "188 spotify:track:2LjpcdgyjRIIoGUDwDk2kL\n",
+ "189 spotify:track:0zRooGATNcoPQpSsT6Egsc\n",
+ "Name: uri, Length: 190, dtype: object"
+ ]
+ },
+ "execution_count": 47,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "playlist[\"uri\"]"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "811e1ee5",
+ "metadata": {},
+ "source": [
+ "## Voy a intentar publicar la playlist"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 28,
+ "id": "63312430",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "import webbrowser\n",
+ "from urllib.parse import urlparse, parse_qs"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "f1b15684",
+ "metadata": {},
+ "outputs": [],
+ "source": []
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 29,
+ "id": "b2c841ff",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Open the following URL in your web browser to authorize:\n"
+ ]
+ },
+ {
+ "data": {
+ "text/plain": [
+ "True"
+ ]
+ },
+ "execution_count": 29,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "#Aquí uso la función que utilicé para mi último lab. \n",
+ "\n",
+ "def randomstring(length=16, num_strings=1):\n",
+ " strings = []\n",
+ " letters = string.ascii_lowercase\n",
+ " numbers = \"\".join([str(x) for x in range(1, length)])\n",
+ " numbers_letters = letters + numbers\n",
+ " \n",
+ " for i in range(num_strings):\n",
+ " string_length = length\n",
+ " random_string = \"\".join(random.choice(numbers_letters) for i in range(length))\n",
+ " strings.append(random_string)\n",
+ " return strings\n",
+ "\n",
+ "def login():\n",
+ " client_id = \"f3c31c7678ae4a9887fc4c626a1e9bc1\"\n",
+ " redirect_uri = 'https://example.com/callback'\n",
+ " state = randomstring(16)\n",
+ " scope = 'playlist-read-private playlist-read-collaborative playlist-modify-private playlist-modify-public'\n",
+ " auth_url = 'https://accounts.spotify.com/authorize'\n",
+ " params = {\n",
+ " 'response_type': 'code',\n",
+ " 'client_id': client_id,\n",
+ " 'scope': scope,\n",
+ " 'redirect_uri': redirect_uri,\n",
+ " 'state': state\n",
+ " }\n",
+ " \n",
+ " authorization_url = f\"{auth_url}?{'&'.join([f'{key}={value}' for key, value in params.items()])}\"\n",
+ " print(\"Open the following URL in your web browser to authorize:\")\n",
+ " return requests.get(authorization_url)\n",
+ "\n",
+ "login = login()\n",
+ "webbrowser.open(login.url)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "28c1d242",
+ "metadata": {},
+ "source": [
+ "## Para parsear el token"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 36,
+ "id": "07657ff2",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "url = \"https://example.com/callback?code=AQA02URJhL5Em1aAgOaMrl5CQOkG7LU3aJllqDiTXFb6p53jbesY-lcmBUDa3Eiv45QZAm1ns42Kiadbb2MRrL5QEst4_mJnOhzwLa7a-ND9oolOVxU6C2NA10WRU9jyg59o0kgKs10oqajVWIDsvZiQSgjtTl43KERtmM8SlXtCPSGMoL504GGM5jFBndfAIEKlqWdSGijeGqB9fsA_81OclEdlYXwXxZtjPlbOwzt8opudiBSW4MSbPzPtk-8K30XwIsm4YiIWfza7KHru9012jq2GGaprj_AEoZ-Q9dyvWi_oKg&state=%5B%27o59111716dylrug1%27%5D\"\n",
+ "code = url.replace('https://example.com/callback?code=','').split('&state')[0]"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 38,
+ "id": "0c6dfd09",
+ "metadata": {
+ "scrolled": true
+ },
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "'AQA02URJhL5Em1aAgOaMrl5CQOkG7LU3aJllqDiTXFb6p53jbesY-lcmBUDa3Eiv45QZAm1ns42Kiadbb2MRrL5QEst4_mJnOhzwLa7a-ND9oolOVxU6C2NA10WRU9jyg59o0kgKs10oqajVWIDsvZiQSgjtTl43KERtmM8SlXtCPSGMoL504GGM5jFBndfAIEKlqWdSGijeGqB9fsA_81OclEdlYXwXxZtjPlbOwzt8opudiBSW4MSbPzPtk-8K30XwIsm4YiIWfza7KHru9012jq2GGaprj_AEoZ-Q9dyvWi_oKg'"
+ ]
+ },
+ "execution_count": 38,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "code"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 39,
+ "id": "6cb056b5",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "def callback():\n",
+ " redirect_uri='https://example.com/callback'\n",
+ " auth_options = {\n",
+ " 'url': 'https://accounts.spotify.com/api/token',\n",
+ " 'data': {\n",
+ " 'code': code,\n",
+ " 'redirect_uri': redirect_uri,\n",
+ " 'grant_type': 'authorization_code'\n",
+ " },\n",
+ " 'headers': {\n",
+ " 'Content-Type': 'application/x-www-form-urlencoded',\n",
+ " 'Authorization': 'Basic ' + base64.b64encode(f'{client_id}:{client_secret}'.encode()).decode()\n",
+ " }\n",
+ " }\n",
+ "\n",
+ " response = requests.post(auth_options['url'], data=auth_options['data'], headers=auth_options['headers'])\n",
+ " return response.json()\n",
+ "\n",
+ "access_token = callback()"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 42,
+ "id": "4dee276d",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "access_token = access_token[\"access_token\"]"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 43,
+ "id": "8b7e9e60",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Enter a playlist name:playlist silvia\n",
+ "Playlist created successfully:\n",
+ "{'collaborative': False, 'description': 'Description of your playlist playlist silvia', 'external_urls': {'spotify': 'https://open.spotify.com/playlist/362OCdVbQ4xgIGEcCJojmX'}, 'followers': {'href': None, 'total': 0}, 'href': 'https://api.spotify.com/v1/playlists/362OCdVbQ4xgIGEcCJojmX', 'id': '362OCdVbQ4xgIGEcCJojmX', 'images': [], 'name': 'playlist silvia', 'owner': {'display_name': 'Silvia Martínez Valero', 'external_urls': {'spotify': 'https://open.spotify.com/user/1150209529'}, 'href': 'https://api.spotify.com/v1/users/1150209529', 'id': '1150209529', 'type': 'user', 'uri': 'spotify:user:1150209529'}, 'primary_color': None, 'public': True, 'snapshot_id': 'MSxkOTE2MTQ0M2Q0NTMxMjY1OGQ3MDQ4NDYyYjQ0YTdiN2E5MThjMzI4', 'tracks': {'href': 'https://api.spotify.com/v1/playlists/362OCdVbQ4xgIGEcCJojmX/tracks', 'items': [], 'limit': 100, 'next': None, 'offset': 0, 'previous': None, 'total': 0}, 'type': 'playlist', 'uri': 'spotify:playlist:362OCdVbQ4xgIGEcCJojmX'}\n"
+ ]
+ }
+ ],
+ "source": [
+ "# Replace these variables with your own values\n",
+ "#access_token = “your_access_token_here”\n",
+ "user_id = \"1150209529\" # “your_user_id_here”\n",
+ "playlist_name = input(\"Enter a playlist name:\")\n",
+ "playlist_description = f\"Description of your playlist {playlist_name}\"\n",
+ "# Define the API endpoint and headers\n",
+ "api_endpoint = f\"https://api.spotify.com/v1/users/{user_id}/playlists\"\n",
+ "headers = {\n",
+ " \"Authorization\": f\"Bearer {access_token}\",\n",
+ " \"Content-Type\": \"application/json\"\n",
+ "}\n",
+ "# Create the playlist\n",
+ "playlist_data = {\n",
+ " \"name\": playlist_name,\n",
+ " \"description\": playlist_description,\n",
+ " \"public\": True # You can change the visibility as needed\n",
+ "}\n",
+ "response = requests.post(api_endpoint, headers=headers, json=playlist_data)\n",
+ "if response.status_code == 201:\n",
+ " playlist_info = response.json()\n",
+ " print(\"Playlist created successfully:\")\n",
+ " print(playlist_info)\n",
+ "else:\n",
+ " print(\"Failed to create the playlist.\")"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 56,
+ "id": "c8a69765",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "def add_tracks_to_playlist(access_token, playlist_id):\n",
+ " api_endpoint = f\"https://api.spotify.com/v1/playlists/{playlist_id}/tracks\"\n",
+ " headers = {\n",
+ " \"Authorization\": f\"Bearer {access_token}\",\n",
+ " \"Content-Type\": \"application/json\"\n",
+ " }\n",
+ " data = {\n",
+ " \"uris\": list(playlist[\"uri\"])[:99]\n",
+ " }\n",
+ " response = requests.post(api_endpoint, headers=headers, json=data)\n",
+ " if response.status_code == 201:\n",
+ " print(\"Tracks added to the playlist successfully.\")\n",
+ " else:\n",
+ " print(\"Failed to add tracks to the playlist\")"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 57,
+ "id": "6aa11625",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Tracks added to the playlist successfully.\n"
+ ]
+ }
+ ],
+ "source": [
+ "add_tracks_to_playlist(access_token,\"362OCdVbQ4xgIGEcCJojmX\")"
+ ]
+ }
+ ],
+ "metadata": {
+ "kernelspec": {
+ "display_name": "Python (m1_env)",
+ "language": "python",
+ "name": "m1_env"
+ },
+ "language_info": {
+ "codemirror_mode": {
+ "name": "ipython",
+ "version": 3
+ },
+ "file_extension": ".py",
+ "mimetype": "text/x-python",
+ "name": "python",
+ "nbconvert_exporter": "python",
+ "pygments_lexer": "ipython3",
+ "version": "3.10.13"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 5
+}
diff --git a/notebooks/spotify_rest_api_challenge_pruebas.ipynb b/notebooks/spotify_rest_api_challenge_pruebas.ipynb
new file mode 100644
index 0000000..bcb0fcb
--- /dev/null
+++ b/notebooks/spotify_rest_api_challenge_pruebas.ipynb
@@ -0,0 +1,2033 @@
+{
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "id": "ef05c1d6",
+ "metadata": {},
+ "source": [
+ "\n",
+ "\n",
+ "# Spotify REST API Challenge\n",
+ "\n",
+ "__What to listen?__\n",
+ "\n",
+ "Create your own playlist based on the related artists and their most popular tracks using the [Spotify REST API](https://developer.spotify.com/)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 1,
+ "id": "17a49776",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "# Imports\n",
+ "import requests\n",
+ "import pandas as pd"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "4e97884c",
+ "metadata": {},
+ "source": [
+ "### Get access!!!\n",
+ "\n",
+ "Get your `client_id` and `client_secret` to generate your __token__ access"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 2,
+ "id": "7b5d2e52",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "# Generate token with a POST request\n",
+ "\n",
+ "client_id = \"f3c31c7678ae4a9887fc4c626a1e9bc1\" #Client ID\n",
+ "client_secret = \"a7ec3c800df3483cbc128524bec99fd3\" #Cliente Secret\n",
+ "auth_url = 'https://accounts.spotify.com/api/token'"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 3,
+ "id": "c7901d1e",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "auth_response = requests.post(auth_url, {'grant_type': 'client_credentials',\n",
+ " 'client_id': client_id,\n",
+ " 'client_secret': client_secret}).json()"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 4,
+ "id": "262e7e18",
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "{'access_token': 'BQDdllnwwsH7IiRVIMdZYgUZZsQalRB91aDK93J-Ee58NAo-2lnRzI_UWDZ__m70s2WrmndDKfz_et7KYicN4bf88AA4TK3PDJqPu19niYbtZVtUCOc',\n",
+ " 'token_type': 'Bearer',\n",
+ " 'expires_in': 3600}"
+ ]
+ },
+ "execution_count": 4,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "access_token = auth_response['access_token']\n",
+ "auth_response"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 5,
+ "id": "791c8a7b",
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "'BQDdllnwwsH7IiRVIMdZYgUZZsQalRB91aDK93J-Ee58NAo-2lnRzI_UWDZ__m70s2WrmndDKfz_et7KYicN4bf88AA4TK3PDJqPu19niYbtZVtUCOc'"
+ ]
+ },
+ "execution_count": 5,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "access_token"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "e617caff",
+ "metadata": {},
+ "source": [
+ "### Set your main variables!!!\n",
+ "\n",
+ "Set the `base_uri` (i.e.: end-point), parameters and `headers` for your __GET__ operations"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 6,
+ "id": "62e6d4fb",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "# Base end-point construction\n",
+ "\n",
+ "base_url = 'https://api.spotify.com/v1/'\n",
+ "resource = 'artists/'\n",
+ "\n",
+ "header_info = {'Authorization': 'Bearer {token}'.format(token=access_token)}"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 7,
+ "id": "7f1195e2",
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "{'Authorization': 'Bearer BQDdllnwwsH7IiRVIMdZYgUZZsQalRB91aDK93J-Ee58NAo-2lnRzI_UWDZ__m70s2WrmndDKfz_et7KYicN4bf88AA4TK3PDJqPu19niYbtZVtUCOc'}"
+ ]
+ },
+ "execution_count": 7,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "header_info"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "16660a9b",
+ "metadata": {},
+ "source": [
+ "### Create your new playlist!!!\n",
+ "\n",
+ "Use [`/related-artists`](https://developer.spotify.com/documentation/web-api/reference/#/operations/get-an-artists-related-artists) and [`/top-tracks`](https://developer.spotify.com/documentation/web-api/reference/#/operations/get-an-artists-top-tracks) in order to get the data that you need.\n",
+ "\n",
+ "__Here you have the different artists to start with:__\n",
+ "\n",
+ "- __Option 1:__ 0L8ExT028jH3ddEcZwqJJ5\n",
+ "\n",
+ "- __Option 2:__ 4Y7tXHSEejGu1vQ9bwDdXW\n",
+ "\n",
+ "- __Option 3:__ 6FBDaR13swtiWwGhX1WQsP\n",
+ "\n",
+ "- __Option 4:__ 0kyQwKHCZnKE7kTXkxXjrB\n",
+ "\n",
+ "- __Option 5:__ 2d0hyoQ5ynDBnkvAbJKORj\n",
+ "\n",
+ "- __Option 6:__ 3bgsNtcf5d5h9jbQbohfBK\n",
+ "\n",
+ "- __Option 7:__ 7mWCSSOYqm4E9mB7V4ot6S\n",
+ "\n",
+ "- __Option 8:__ 64KEffDW9EtZ1y2vBYgq8T\n",
+ "\n",
+ "- __Option 9:__ 4k1ELeJKT1ISyDv8JivPpB\n",
+ "\n",
+ "- __Option 10:__ 4Z8W4fKeB5YxbusRsdQVPb\n",
+ "\n",
+ "- __Option 11:__ 26dSoYclwsYLMAKD3tpOr4\n",
+ "\n",
+ "- __Option 12:__ 7y97mc3bZRFXzT2szRM4L4\n",
+ "\n",
+ "- __Option 13:__ 1w5Kfo2jwwIPruYS2UWh56\n",
+ "\n",
+ "\n",
+ "> Remember to check the [Requests](https://requests.readthedocs.io/en/latest/) library docs!!!\n",
+ "\n",
+ "---"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 8,
+ "id": "04f85940",
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "'https://api.spotify.com/v1/artists/0kyQwKHCZnKE7kTXkxXjrB/related-artists'"
+ ]
+ },
+ "execution_count": 8,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "# Here you can complete your endpoint URI\n",
+ "\n",
+ "artist_id = \"0kyQwKHCZnKE7kTXkxXjrB\"\n",
+ "method = \"/related-artists\"\n",
+ "argument = \"market = ES\"\n",
+ "full_endpoint = base_url + resource + artist_id + method \n",
+ "full_endpoint"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 9,
+ "id": "50ec3959",
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "200"
+ ]
+ },
+ "execution_count": 9,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "# Start building your playlist!!!\n",
+ "related_artists_response = requests.get(full_endpoint, headers = header_info)\n",
+ "related_artists_response.status_code"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 10,
+ "id": "f0900f61",
+ "metadata": {
+ "scrolled": false
+ },
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "{'artists': [{'external_urls': {'spotify': 'https://open.spotify.com/artist/38Wv3iDJm7vyk4OvaHWZxx'},\n",
+ " 'followers': {'href': None, 'total': 69575},\n",
+ " 'genres': ['venezuelan rock'],\n",
+ " 'href': 'https://api.spotify.com/v1/artists/38Wv3iDJm7vyk4OvaHWZxx',\n",
+ " 'id': '38Wv3iDJm7vyk4OvaHWZxx',\n",
+ " 'images': [{'height': 640,\n",
+ " 'url': 'https://i.scdn.co/image/ab6761610000e5eb272c47d395c7b3ecb1bf9e55',\n",
+ " 'width': 640},\n",
+ " {'height': 320,\n",
+ " 'url': 'https://i.scdn.co/image/ab67616100005174272c47d395c7b3ecb1bf9e55',\n",
+ " 'width': 320},\n",
+ " {'height': 160,\n",
+ " 'url': 'https://i.scdn.co/image/ab6761610000f178272c47d395c7b3ecb1bf9e55',\n",
+ " 'width': 160}],\n",
+ " 'name': 'Zapato3',\n",
+ " 'popularity': 29,\n",
+ " 'type': 'artist',\n",
+ " 'uri': 'spotify:artist:38Wv3iDJm7vyk4OvaHWZxx'},\n",
+ " {'external_urls': {'spotify': 'https://open.spotify.com/artist/6xPMZgR2peupwU41WF9qi7'},\n",
+ " 'followers': {'href': None, 'total': 42221},\n",
+ " 'genres': ['venezuelan rock'],\n",
+ " 'href': 'https://api.spotify.com/v1/artists/6xPMZgR2peupwU41WF9qi7',\n",
+ " 'id': '6xPMZgR2peupwU41WF9qi7',\n",
+ " 'images': [{'height': 640,\n",
+ " 'url': 'https://i.scdn.co/image/ab6761610000e5ebbe265e982c8a304bca29e626',\n",
+ " 'width': 640},\n",
+ " {'height': 320,\n",
+ " 'url': 'https://i.scdn.co/image/ab67616100005174be265e982c8a304bca29e626',\n",
+ " 'width': 320},\n",
+ " {'height': 160,\n",
+ " 'url': 'https://i.scdn.co/image/ab6761610000f178be265e982c8a304bca29e626',\n",
+ " 'width': 160}],\n",
+ " 'name': 'Malanga',\n",
+ " 'popularity': 30,\n",
+ " 'type': 'artist',\n",
+ " 'uri': 'spotify:artist:6xPMZgR2peupwU41WF9qi7'},\n",
+ " {'external_urls': {'spotify': 'https://open.spotify.com/artist/7nx8DlJ8j0sUGBvFtpoEwz'},\n",
+ " 'followers': {'href': None, 'total': 42712},\n",
+ " 'genres': ['latin rock', 'rock gotico', 'venezuelan rock'],\n",
+ " 'href': 'https://api.spotify.com/v1/artists/7nx8DlJ8j0sUGBvFtpoEwz',\n",
+ " 'id': '7nx8DlJ8j0sUGBvFtpoEwz',\n",
+ " 'images': [{'height': 640,\n",
+ " 'url': 'https://i.scdn.co/image/ab6761610000e5eb0eabcda0a565599e11ad1160',\n",
+ " 'width': 640},\n",
+ " {'height': 320,\n",
+ " 'url': 'https://i.scdn.co/image/ab676161000051740eabcda0a565599e11ad1160',\n",
+ " 'width': 320},\n",
+ " {'height': 160,\n",
+ " 'url': 'https://i.scdn.co/image/ab6761610000f1780eabcda0a565599e11ad1160',\n",
+ " 'width': 160}],\n",
+ " 'name': 'Sentimiento Muerto',\n",
+ " 'popularity': 23,\n",
+ " 'type': 'artist',\n",
+ " 'uri': 'spotify:artist:7nx8DlJ8j0sUGBvFtpoEwz'},\n",
+ " {'external_urls': {'spotify': 'https://open.spotify.com/artist/7jLOrU2XbkSEDJL26be4Mr'},\n",
+ " 'followers': {'href': None, 'total': 35053},\n",
+ " 'genres': [],\n",
+ " 'href': 'https://api.spotify.com/v1/artists/7jLOrU2XbkSEDJL26be4Mr',\n",
+ " 'id': '7jLOrU2XbkSEDJL26be4Mr',\n",
+ " 'images': [{'height': 640,\n",
+ " 'url': 'https://i.scdn.co/image/ab6761610000e5eb8cbc036931e48ab7b603f0bd',\n",
+ " 'width': 640},\n",
+ " {'height': 320,\n",
+ " 'url': 'https://i.scdn.co/image/ab676161000051748cbc036931e48ab7b603f0bd',\n",
+ " 'width': 320},\n",
+ " {'height': 160,\n",
+ " 'url': 'https://i.scdn.co/image/ab6761610000f1788cbc036931e48ab7b603f0bd',\n",
+ " 'width': 160}],\n",
+ " 'name': 'Mulato',\n",
+ " 'popularity': 5,\n",
+ " 'type': 'artist',\n",
+ " 'uri': 'spotify:artist:7jLOrU2XbkSEDJL26be4Mr'},\n",
+ " {'external_urls': {'spotify': 'https://open.spotify.com/artist/5nZlhgO7iNedGlO0gKu9us'},\n",
+ " 'followers': {'href': None, 'total': 98037},\n",
+ " 'genres': ['venezuelan rock'],\n",
+ " 'href': 'https://api.spotify.com/v1/artists/5nZlhgO7iNedGlO0gKu9us',\n",
+ " 'id': '5nZlhgO7iNedGlO0gKu9us',\n",
+ " 'images': [{'height': 640,\n",
+ " 'url': 'https://i.scdn.co/image/ab6761610000e5ebd915aa801b9c654b6b1ffd44',\n",
+ " 'width': 640},\n",
+ " {'height': 320,\n",
+ " 'url': 'https://i.scdn.co/image/ab67616100005174d915aa801b9c654b6b1ffd44',\n",
+ " 'width': 320},\n",
+ " {'height': 160,\n",
+ " 'url': 'https://i.scdn.co/image/ab6761610000f178d915aa801b9c654b6b1ffd44',\n",
+ " 'width': 160}],\n",
+ " 'name': 'King Chango',\n",
+ " 'popularity': 40,\n",
+ " 'type': 'artist',\n",
+ " 'uri': 'spotify:artist:5nZlhgO7iNedGlO0gKu9us'},\n",
+ " {'external_urls': {'spotify': 'https://open.spotify.com/artist/1b2FooqkEdKdykGcdEof02'},\n",
+ " 'followers': {'href': None, 'total': 54368},\n",
+ " 'genres': ['venezuelan rock'],\n",
+ " 'href': 'https://api.spotify.com/v1/artists/1b2FooqkEdKdykGcdEof02',\n",
+ " 'id': '1b2FooqkEdKdykGcdEof02',\n",
+ " 'images': [{'height': 640,\n",
+ " 'url': 'https://i.scdn.co/image/ab6761610000e5eba67da944d309915e1407975d',\n",
+ " 'width': 640},\n",
+ " {'height': 320,\n",
+ " 'url': 'https://i.scdn.co/image/ab67616100005174a67da944d309915e1407975d',\n",
+ " 'width': 320},\n",
+ " {'height': 160,\n",
+ " 'url': 'https://i.scdn.co/image/ab6761610000f178a67da944d309915e1407975d',\n",
+ " 'width': 160}],\n",
+ " 'name': 'Mermelada Bunch',\n",
+ " 'popularity': 24,\n",
+ " 'type': 'artist',\n",
+ " 'uri': 'spotify:artist:1b2FooqkEdKdykGcdEof02'},\n",
+ " {'external_urls': {'spotify': 'https://open.spotify.com/artist/0WmmhplJiEohqKsYoRLsbq'},\n",
+ " 'followers': {'href': None, 'total': 30652},\n",
+ " 'genres': ['venezuelan hip hop', 'venezuelan rock'],\n",
+ " 'href': 'https://api.spotify.com/v1/artists/0WmmhplJiEohqKsYoRLsbq',\n",
+ " 'id': '0WmmhplJiEohqKsYoRLsbq',\n",
+ " 'images': [{'height': 640,\n",
+ " 'url': 'https://i.scdn.co/image/ab6761610000e5eb9877593d432b8443b98ac093',\n",
+ " 'width': 640},\n",
+ " {'height': 320,\n",
+ " 'url': 'https://i.scdn.co/image/ab676161000051749877593d432b8443b98ac093',\n",
+ " 'width': 320},\n",
+ " {'height': 160,\n",
+ " 'url': 'https://i.scdn.co/image/ab6761610000f1789877593d432b8443b98ac093',\n",
+ " 'width': 160}],\n",
+ " 'name': 'PapaShanty SaundSystem',\n",
+ " 'popularity': 22,\n",
+ " 'type': 'artist',\n",
+ " 'uri': 'spotify:artist:0WmmhplJiEohqKsYoRLsbq'},\n",
+ " {'external_urls': {'spotify': 'https://open.spotify.com/artist/48NeXVOrqMUIRc4M8g0lnZ'},\n",
+ " 'followers': {'href': None, 'total': 37419},\n",
+ " 'genres': ['classic venezuelan pop', 'venezuelan rock'],\n",
+ " 'href': 'https://api.spotify.com/v1/artists/48NeXVOrqMUIRc4M8g0lnZ',\n",
+ " 'id': '48NeXVOrqMUIRc4M8g0lnZ',\n",
+ " 'images': [{'height': 640,\n",
+ " 'url': 'https://i.scdn.co/image/ab67616d0000b273ece78d66f04c9d05a7901371',\n",
+ " 'width': 640},\n",
+ " {'height': 300,\n",
+ " 'url': 'https://i.scdn.co/image/ab67616d00001e02ece78d66f04c9d05a7901371',\n",
+ " 'width': 300},\n",
+ " {'height': 64,\n",
+ " 'url': 'https://i.scdn.co/image/ab67616d00004851ece78d66f04c9d05a7901371',\n",
+ " 'width': 64}],\n",
+ " 'name': 'Aditus',\n",
+ " 'popularity': 25,\n",
+ " 'type': 'artist',\n",
+ " 'uri': 'spotify:artist:48NeXVOrqMUIRc4M8g0lnZ'},\n",
+ " {'external_urls': {'spotify': 'https://open.spotify.com/artist/2jZIvxOfIP6hhzthCqRmqI'},\n",
+ " 'followers': {'href': None, 'total': 27537},\n",
+ " 'genres': ['venezuelan hip hop', 'venezuelan rock'],\n",
+ " 'href': 'https://api.spotify.com/v1/artists/2jZIvxOfIP6hhzthCqRmqI',\n",
+ " 'id': '2jZIvxOfIP6hhzthCqRmqI',\n",
+ " 'images': [{'height': 640,\n",
+ " 'url': 'https://i.scdn.co/image/ab67616d0000b2734b3f3163fc13dc1a8757d396',\n",
+ " 'width': 640},\n",
+ " {'height': 300,\n",
+ " 'url': 'https://i.scdn.co/image/ab67616d00001e024b3f3163fc13dc1a8757d396',\n",
+ " 'width': 300},\n",
+ " {'height': 64,\n",
+ " 'url': 'https://i.scdn.co/image/ab67616d000048514b3f3163fc13dc1a8757d396',\n",
+ " 'width': 64}],\n",
+ " 'name': 'Cuarto Poder',\n",
+ " 'popularity': 21,\n",
+ " 'type': 'artist',\n",
+ " 'uri': 'spotify:artist:2jZIvxOfIP6hhzthCqRmqI'},\n",
+ " {'external_urls': {'spotify': 'https://open.spotify.com/artist/0gt2Xy6uSRTFTWYrHOHx82'},\n",
+ " 'followers': {'href': None, 'total': 24642},\n",
+ " 'genres': ['venezuelan rock'],\n",
+ " 'href': 'https://api.spotify.com/v1/artists/0gt2Xy6uSRTFTWYrHOHx82',\n",
+ " 'id': '0gt2Xy6uSRTFTWYrHOHx82',\n",
+ " 'images': [{'height': 640,\n",
+ " 'url': 'https://i.scdn.co/image/ab6761610000e5ebcc1ba8f81e2482e1fedc9a24',\n",
+ " 'width': 640},\n",
+ " {'height': 320,\n",
+ " 'url': 'https://i.scdn.co/image/ab67616100005174cc1ba8f81e2482e1fedc9a24',\n",
+ " 'width': 320},\n",
+ " {'height': 160,\n",
+ " 'url': 'https://i.scdn.co/image/ab6761610000f178cc1ba8f81e2482e1fedc9a24',\n",
+ " 'width': 160}],\n",
+ " 'name': 'Los Mentas',\n",
+ " 'popularity': 17,\n",
+ " 'type': 'artist',\n",
+ " 'uri': 'spotify:artist:0gt2Xy6uSRTFTWYrHOHx82'},\n",
+ " {'external_urls': {'spotify': 'https://open.spotify.com/artist/2i99x70sDfixFZ95bIYayb'},\n",
+ " 'followers': {'href': None, 'total': 30453},\n",
+ " 'genres': ['venezuelan rock'],\n",
+ " 'href': 'https://api.spotify.com/v1/artists/2i99x70sDfixFZ95bIYayb',\n",
+ " 'id': '2i99x70sDfixFZ95bIYayb',\n",
+ " 'images': [{'height': 640,\n",
+ " 'url': 'https://i.scdn.co/image/ab6761610000e5eb5aadf695d08d1eda5af7bf1e',\n",
+ " 'width': 640},\n",
+ " {'height': 320,\n",
+ " 'url': 'https://i.scdn.co/image/ab676161000051745aadf695d08d1eda5af7bf1e',\n",
+ " 'width': 320},\n",
+ " {'height': 160,\n",
+ " 'url': 'https://i.scdn.co/image/ab6761610000f1785aadf695d08d1eda5af7bf1e',\n",
+ " 'width': 160}],\n",
+ " 'name': 'Tomates Fritos',\n",
+ " 'popularity': 24,\n",
+ " 'type': 'artist',\n",
+ " 'uri': 'spotify:artist:2i99x70sDfixFZ95bIYayb'},\n",
+ " {'external_urls': {'spotify': 'https://open.spotify.com/artist/5rTdxb1YVVZMXscz4wexGu'},\n",
+ " 'followers': {'href': None, 'total': 62438},\n",
+ " 'genres': ['venezuelan hip hop', 'venezuelan rock'],\n",
+ " 'href': 'https://api.spotify.com/v1/artists/5rTdxb1YVVZMXscz4wexGu',\n",
+ " 'id': '5rTdxb1YVVZMXscz4wexGu',\n",
+ " 'images': [{'height': 640,\n",
+ " 'url': 'https://i.scdn.co/image/ab6761610000e5ebd7aa84d02112f3b4f4903ebf',\n",
+ " 'width': 640},\n",
+ " {'height': 320,\n",
+ " 'url': 'https://i.scdn.co/image/ab67616100005174d7aa84d02112f3b4f4903ebf',\n",
+ " 'width': 320},\n",
+ " {'height': 160,\n",
+ " 'url': 'https://i.scdn.co/image/ab6761610000f178d7aa84d02112f3b4f4903ebf',\n",
+ " 'width': 160}],\n",
+ " 'name': '3 Dueños',\n",
+ " 'popularity': 33,\n",
+ " 'type': 'artist',\n",
+ " 'uri': 'spotify:artist:5rTdxb1YVVZMXscz4wexGu'},\n",
+ " {'external_urls': {'spotify': 'https://open.spotify.com/artist/2TPLqqQ9arRHA6Xt7gvZTZ'},\n",
+ " 'followers': {'href': None, 'total': 25341},\n",
+ " 'genres': ['caracas indie', 'venezuelan rock'],\n",
+ " 'href': 'https://api.spotify.com/v1/artists/2TPLqqQ9arRHA6Xt7gvZTZ',\n",
+ " 'id': '2TPLqqQ9arRHA6Xt7gvZTZ',\n",
+ " 'images': [{'height': 640,\n",
+ " 'url': 'https://i.scdn.co/image/ab6761610000e5eb72bd2f8d2a6142eda84bec24',\n",
+ " 'width': 640},\n",
+ " {'height': 320,\n",
+ " 'url': 'https://i.scdn.co/image/ab6761610000517472bd2f8d2a6142eda84bec24',\n",
+ " 'width': 320},\n",
+ " {'height': 160,\n",
+ " 'url': 'https://i.scdn.co/image/ab6761610000f17872bd2f8d2a6142eda84bec24',\n",
+ " 'width': 160}],\n",
+ " 'name': 'Candy66',\n",
+ " 'popularity': 22,\n",
+ " 'type': 'artist',\n",
+ " 'uri': 'spotify:artist:2TPLqqQ9arRHA6Xt7gvZTZ'},\n",
+ " {'external_urls': {'spotify': 'https://open.spotify.com/artist/3ZReJfzCEVpHWUSWd5emic'},\n",
+ " 'followers': {'href': None, 'total': 49390},\n",
+ " 'genres': ['classic venezuelan pop', 'venezuelan rock'],\n",
+ " 'href': 'https://api.spotify.com/v1/artists/3ZReJfzCEVpHWUSWd5emic',\n",
+ " 'id': '3ZReJfzCEVpHWUSWd5emic',\n",
+ " 'images': [{'height': 640,\n",
+ " 'url': 'https://i.scdn.co/image/ab6761610000e5ebb075a2351facacd595bd4aa5',\n",
+ " 'width': 640},\n",
+ " {'height': 320,\n",
+ " 'url': 'https://i.scdn.co/image/ab67616100005174b075a2351facacd595bd4aa5',\n",
+ " 'width': 320},\n",
+ " {'height': 160,\n",
+ " 'url': 'https://i.scdn.co/image/ab6761610000f178b075a2351facacd595bd4aa5',\n",
+ " 'width': 160}],\n",
+ " 'name': 'Frank Quintero',\n",
+ " 'popularity': 28,\n",
+ " 'type': 'artist',\n",
+ " 'uri': 'spotify:artist:3ZReJfzCEVpHWUSWd5emic'},\n",
+ " {'external_urls': {'spotify': 'https://open.spotify.com/artist/0D8yIOlFPxp7OL6n6UzJ38'},\n",
+ " 'followers': {'href': None, 'total': 88901},\n",
+ " 'genres': ['classic venezuelan pop', 'gaita zuliana'],\n",
+ " 'href': 'https://api.spotify.com/v1/artists/0D8yIOlFPxp7OL6n6UzJ38',\n",
+ " 'id': '0D8yIOlFPxp7OL6n6UzJ38',\n",
+ " 'images': [{'height': 1000,\n",
+ " 'url': 'https://i.scdn.co/image/33917a8ffe165003b49e95a03077c234e0979756',\n",
+ " 'width': 1000},\n",
+ " {'height': 640,\n",
+ " 'url': 'https://i.scdn.co/image/cd8a6e7d007c430ddeba76503a212450d3c7b1bf',\n",
+ " 'width': 640},\n",
+ " {'height': 200,\n",
+ " 'url': 'https://i.scdn.co/image/0d559560a7f1e714302eb02048a244deab679519',\n",
+ " 'width': 200},\n",
+ " {'height': 64,\n",
+ " 'url': 'https://i.scdn.co/image/85e27c08f38b9869d757e4ac8a78e3fd4062db6e',\n",
+ " 'width': 64}],\n",
+ " 'name': 'Gran Coquivacoa',\n",
+ " 'popularity': 41,\n",
+ " 'type': 'artist',\n",
+ " 'uri': 'spotify:artist:0D8yIOlFPxp7OL6n6UzJ38'},\n",
+ " {'external_urls': {'spotify': 'https://open.spotify.com/artist/4SBlgsYD1T6dUV17RDrEBN'},\n",
+ " 'followers': {'href': None, 'total': 20543},\n",
+ " 'genres': ['venezuelan hip hop', 'venezuelan rock'],\n",
+ " 'href': 'https://api.spotify.com/v1/artists/4SBlgsYD1T6dUV17RDrEBN',\n",
+ " 'id': '4SBlgsYD1T6dUV17RDrEBN',\n",
+ " 'images': [{'height': 640,\n",
+ " 'url': 'https://i.scdn.co/image/ab6761610000e5eba4eeae888ec5fadac554a03a',\n",
+ " 'width': 640},\n",
+ " {'height': 320,\n",
+ " 'url': 'https://i.scdn.co/image/ab67616100005174a4eeae888ec5fadac554a03a',\n",
+ " 'width': 320},\n",
+ " {'height': 160,\n",
+ " 'url': 'https://i.scdn.co/image/ab6761610000f178a4eeae888ec5fadac554a03a',\n",
+ " 'width': 160}],\n",
+ " 'name': 'La Corte',\n",
+ " 'popularity': 19,\n",
+ " 'type': 'artist',\n",
+ " 'uri': 'spotify:artist:4SBlgsYD1T6dUV17RDrEBN'},\n",
+ " {'external_urls': {'spotify': 'https://open.spotify.com/artist/2zwh4WnVBGZcfnllC7DUxt'},\n",
+ " 'followers': {'href': None, 'total': 70202},\n",
+ " 'genres': ['caracas indie', 'rock en espanol', 'venezuelan rock'],\n",
+ " 'href': 'https://api.spotify.com/v1/artists/2zwh4WnVBGZcfnllC7DUxt',\n",
+ " 'id': '2zwh4WnVBGZcfnllC7DUxt',\n",
+ " 'images': [{'height': 640,\n",
+ " 'url': 'https://i.scdn.co/image/ab6761610000e5eb17b22b5d7cc2b0043ea039b3',\n",
+ " 'width': 640},\n",
+ " {'height': 320,\n",
+ " 'url': 'https://i.scdn.co/image/ab6761610000517417b22b5d7cc2b0043ea039b3',\n",
+ " 'width': 320},\n",
+ " {'height': 160,\n",
+ " 'url': 'https://i.scdn.co/image/ab6761610000f17817b22b5d7cc2b0043ea039b3',\n",
+ " 'width': 160}],\n",
+ " 'name': 'Viniloversus',\n",
+ " 'popularity': 36,\n",
+ " 'type': 'artist',\n",
+ " 'uri': 'spotify:artist:2zwh4WnVBGZcfnllC7DUxt'},\n",
+ " {'external_urls': {'spotify': 'https://open.spotify.com/artist/6dTMVeRubUzINO6gmQhWat'},\n",
+ " 'followers': {'href': None, 'total': 43757},\n",
+ " 'genres': ['classic venezuelan pop',\n",
+ " 'folklore venezolano',\n",
+ " 'musica llanera',\n",
+ " 'venezuelan rock'],\n",
+ " 'href': 'https://api.spotify.com/v1/artists/6dTMVeRubUzINO6gmQhWat',\n",
+ " 'id': '6dTMVeRubUzINO6gmQhWat',\n",
+ " 'images': [{'height': 640,\n",
+ " 'url': 'https://i.scdn.co/image/ab67616d0000b273f3ab1260f5e5858750e11b47',\n",
+ " 'width': 640},\n",
+ " {'height': 300,\n",
+ " 'url': 'https://i.scdn.co/image/ab67616d00001e02f3ab1260f5e5858750e11b47',\n",
+ " 'width': 300},\n",
+ " {'height': 64,\n",
+ " 'url': 'https://i.scdn.co/image/ab67616d00004851f3ab1260f5e5858750e11b47',\n",
+ " 'width': 64}],\n",
+ " 'name': 'Un Solo Pueblo',\n",
+ " 'popularity': 27,\n",
+ " 'type': 'artist',\n",
+ " 'uri': 'spotify:artist:6dTMVeRubUzINO6gmQhWat'},\n",
+ " {'external_urls': {'spotify': 'https://open.spotify.com/artist/4FNbNj9mlDLitaic9vXlwZ'},\n",
+ " 'followers': {'href': None, 'total': 102961},\n",
+ " 'genres': ['pop reggaeton', 'venezuelan rock'],\n",
+ " 'href': 'https://api.spotify.com/v1/artists/4FNbNj9mlDLitaic9vXlwZ',\n",
+ " 'id': '4FNbNj9mlDLitaic9vXlwZ',\n",
+ " 'images': [{'height': 640,\n",
+ " 'url': 'https://i.scdn.co/image/ab6761610000e5eb1a56b039362f96ac5cdd952d',\n",
+ " 'width': 640},\n",
+ " {'height': 320,\n",
+ " 'url': 'https://i.scdn.co/image/ab676161000051741a56b039362f96ac5cdd952d',\n",
+ " 'width': 320},\n",
+ " {'height': 160,\n",
+ " 'url': 'https://i.scdn.co/image/ab6761610000f1781a56b039362f96ac5cdd952d',\n",
+ " 'width': 160}],\n",
+ " 'name': 'Tecupae',\n",
+ " 'popularity': 34,\n",
+ " 'type': 'artist',\n",
+ " 'uri': 'spotify:artist:4FNbNj9mlDLitaic9vXlwZ'},\n",
+ " {'external_urls': {'spotify': 'https://open.spotify.com/artist/1V6FooKFiokndcPHKJ4Tmz'},\n",
+ " 'followers': {'href': None, 'total': 96047},\n",
+ " 'genres': ['classic venezuelan pop', 'gaita zuliana'],\n",
+ " 'href': 'https://api.spotify.com/v1/artists/1V6FooKFiokndcPHKJ4Tmz',\n",
+ " 'id': '1V6FooKFiokndcPHKJ4Tmz',\n",
+ " 'images': [{'height': 640,\n",
+ " 'url': 'https://i.scdn.co/image/ab6761610000e5eb4daf2241bb915e6358e06f3e',\n",
+ " 'width': 640},\n",
+ " {'height': 320,\n",
+ " 'url': 'https://i.scdn.co/image/ab676161000051744daf2241bb915e6358e06f3e',\n",
+ " 'width': 320},\n",
+ " {'height': 160,\n",
+ " 'url': 'https://i.scdn.co/image/ab6761610000f1784daf2241bb915e6358e06f3e',\n",
+ " 'width': 160}],\n",
+ " 'name': 'Maracaibo 15',\n",
+ " 'popularity': 42,\n",
+ " 'type': 'artist',\n",
+ " 'uri': 'spotify:artist:1V6FooKFiokndcPHKJ4Tmz'}]}"
+ ]
+ },
+ "execution_count": 10,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "related_artists_json = related_artists_response.json()\n",
+ "related_artists_json"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 11,
+ "id": "80148a1e",
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "['Zapato3',\n",
+ " 'Malanga',\n",
+ " 'Sentimiento Muerto',\n",
+ " 'Mulato',\n",
+ " 'King Chango',\n",
+ " 'Mermelada Bunch',\n",
+ " 'PapaShanty SaundSystem',\n",
+ " 'Aditus',\n",
+ " 'Cuarto Poder',\n",
+ " 'Los Mentas',\n",
+ " 'Tomates Fritos',\n",
+ " '3 Dueños',\n",
+ " 'Candy66',\n",
+ " 'Frank Quintero',\n",
+ " 'Gran Coquivacoa',\n",
+ " 'La Corte',\n",
+ " 'Viniloversus',\n",
+ " 'Un Solo Pueblo',\n",
+ " 'Tecupae',\n",
+ " 'Maracaibo 15']"
+ ]
+ },
+ "execution_count": 11,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "[related_artists_json[\"artists\"][i][\"name\"] for i in range(len(related_artists_json[\"artists\"]))]"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 12,
+ "id": "7ced2ebf",
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "'https://api.spotify.com/v1/artists/0kyQwKHCZnKE7kTXkxXjrB/top-tracks?market=ES'"
+ ]
+ },
+ "execution_count": 12,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "artist_id = \"0kyQwKHCZnKE7kTXkxXjrB\"\n",
+ "method = \"/top-tracks\"\n",
+ "argument = \"?market=ES\"\n",
+ "full_endpoint = base_url + resource + artist_id + method + argument\n",
+ "full_endpoint"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 13,
+ "id": "b4985554",
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "200"
+ ]
+ },
+ "execution_count": 13,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "top_tracks_response = requests.get(full_endpoint, headers = header_info)\n",
+ "top_tracks_response.status_code"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 14,
+ "id": "228bbcc9",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "top_tracks_json = top_tracks_response.json()"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 15,
+ "id": "2a614fac",
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "['Allá Cayó',\n",
+ " 'Los Que Se Quedan, los Que Se Van',\n",
+ " 'Tiembla - En Vivo',\n",
+ " 'La Danza de los Esqueletos',\n",
+ " 'La Cumbia - Desorden Público rinde Homenaje al Indio Pastor López',\n",
+ " 'Tiemble',\n",
+ " 'Combate',\n",
+ " 'Música de Fiesta',\n",
+ " 'Traicionera / El Reo Ausente - Desorden Público rinde Homenaje al Indio Pastor López',\n",
+ " 'Latex - En Vivo']"
+ ]
+ },
+ "execution_count": 15,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "[top_tracks_json[\"tracks\"][i][\"name\"] for i in range(len(top_tracks_json[\"tracks\"]))]"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 16,
+ "id": "daf0fdea",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "https://api.spotify.com/v1/artists/0kyQwKHCZnKE7kTXkxXjrB\n"
+ ]
+ },
+ {
+ "data": {
+ "text/plain": [
+ "{'external_urls': {'spotify': 'https://open.spotify.com/artist/0kyQwKHCZnKE7kTXkxXjrB'},\n",
+ " 'followers': {'href': None, 'total': 136338},\n",
+ " 'genres': ['caracas indie',\n",
+ " 'latin alternative',\n",
+ " 'latin ska',\n",
+ " 'venezuelan rock'],\n",
+ " 'href': 'https://api.spotify.com/v1/artists/0kyQwKHCZnKE7kTXkxXjrB',\n",
+ " 'id': '0kyQwKHCZnKE7kTXkxXjrB',\n",
+ " 'images': [{'height': 640,\n",
+ " 'url': 'https://i.scdn.co/image/ab6761610000e5eb856a4c8434bc80e2518a1091',\n",
+ " 'width': 640},\n",
+ " {'height': 320,\n",
+ " 'url': 'https://i.scdn.co/image/ab67616100005174856a4c8434bc80e2518a1091',\n",
+ " 'width': 320},\n",
+ " {'height': 160,\n",
+ " 'url': 'https://i.scdn.co/image/ab6761610000f178856a4c8434bc80e2518a1091',\n",
+ " 'width': 160}],\n",
+ " 'name': 'Desorden Público',\n",
+ " 'popularity': 37,\n",
+ " 'type': 'artist',\n",
+ " 'uri': 'spotify:artist:0kyQwKHCZnKE7kTXkxXjrB'}"
+ ]
+ },
+ "execution_count": 16,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "id_selected = \"0kyQwKHCZnKE7kTXkxXjrB\"\n",
+ "resource = \"artists\"\n",
+ "parameters = f\"/{id_selected}\"\n",
+ "url = base_url + resource + parameters\n",
+ "print(url)\n",
+ "response = requests.get(url, headers=header_info).json()\n",
+ "response"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 17,
+ "id": "cad5dc33",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "dict_artist = dict((key, [response[key]]) for key in [\"id\", \"name\", \"genres\", \"popularity\", \"followers\"] if key in response.keys())"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 18,
+ "id": "c4a185b8",
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "{'id': ['0kyQwKHCZnKE7kTXkxXjrB'],\n",
+ " 'name': ['Desorden Público'],\n",
+ " 'genres': [['caracas indie',\n",
+ " 'latin alternative',\n",
+ " 'latin ska',\n",
+ " 'venezuelan rock']],\n",
+ " 'popularity': [37],\n",
+ " 'followers': [{'href': None, 'total': 136338}]}"
+ ]
+ },
+ "execution_count": 18,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "dict_artist"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 19,
+ "id": "00868c77",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "def get_top_tracks(artist_id):\n",
+ " resource = \"artists\"\n",
+ " parameters = f\"/{artist_id}/top-tracks?market=ES\"\n",
+ " url = base_url + resource + parameters\n",
+ " response = requests.get(url, headers=header_info).json()\n",
+ " df_tracks = pd.DataFrame(response[\"tracks\"])[[\"id\", \"href\", \"name\", \"uri\"]]\n",
+ " df_tracks[\"related_id\"] = artist_id\n",
+ " return df_tracks"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 20,
+ "id": "97ac3902",
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " id | \n",
+ " href | \n",
+ " name | \n",
+ " uri | \n",
+ " related_id | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | 0 | \n",
+ " 6F7uqfzvcdl5Y42mJBVc9V | \n",
+ " https://api.spotify.com/v1/tracks/6F7uqfzvcdl5... | \n",
+ " Allá Cayó | \n",
+ " spotify:track:6F7uqfzvcdl5Y42mJBVc9V | \n",
+ " 0kyQwKHCZnKE7kTXkxXjrB | \n",
+ "
\n",
+ " \n",
+ " | 1 | \n",
+ " 2ntUj3hnSU7GQTKA9oZWW1 | \n",
+ " https://api.spotify.com/v1/tracks/2ntUj3hnSU7G... | \n",
+ " Los Que Se Quedan, los Que Se Van | \n",
+ " spotify:track:2ntUj3hnSU7GQTKA9oZWW1 | \n",
+ " 0kyQwKHCZnKE7kTXkxXjrB | \n",
+ "
\n",
+ " \n",
+ " | 2 | \n",
+ " 6tJn0JYD6QKE6eXbh4829b | \n",
+ " https://api.spotify.com/v1/tracks/6tJn0JYD6QKE... | \n",
+ " Tiembla - En Vivo | \n",
+ " spotify:track:6tJn0JYD6QKE6eXbh4829b | \n",
+ " 0kyQwKHCZnKE7kTXkxXjrB | \n",
+ "
\n",
+ " \n",
+ " | 3 | \n",
+ " 1f9X3c8Bzn79zkCwnZ2vay | \n",
+ " https://api.spotify.com/v1/tracks/1f9X3c8Bzn79... | \n",
+ " La Danza de los Esqueletos | \n",
+ " spotify:track:1f9X3c8Bzn79zkCwnZ2vay | \n",
+ " 0kyQwKHCZnKE7kTXkxXjrB | \n",
+ "
\n",
+ " \n",
+ " | 4 | \n",
+ " 1TQLNy86xeKIBnB4O2LOWr | \n",
+ " https://api.spotify.com/v1/tracks/1TQLNy86xeKI... | \n",
+ " La Cumbia - Desorden Público rinde Homenaje al... | \n",
+ " spotify:track:1TQLNy86xeKIBnB4O2LOWr | \n",
+ " 0kyQwKHCZnKE7kTXkxXjrB | \n",
+ "
\n",
+ " \n",
+ " | 5 | \n",
+ " 1eEFMib4nzsUaeWYN0n5Ot | \n",
+ " https://api.spotify.com/v1/tracks/1eEFMib4nzsU... | \n",
+ " Tiemble | \n",
+ " spotify:track:1eEFMib4nzsUaeWYN0n5Ot | \n",
+ " 0kyQwKHCZnKE7kTXkxXjrB | \n",
+ "
\n",
+ " \n",
+ " | 6 | \n",
+ " 6B9NhbeAAvCX0oqQLL4inQ | \n",
+ " https://api.spotify.com/v1/tracks/6B9NhbeAAvCX... | \n",
+ " Combate | \n",
+ " spotify:track:6B9NhbeAAvCX0oqQLL4inQ | \n",
+ " 0kyQwKHCZnKE7kTXkxXjrB | \n",
+ "
\n",
+ " \n",
+ " | 7 | \n",
+ " 5iuzPrZExQitcYGBShOSvW | \n",
+ " https://api.spotify.com/v1/tracks/5iuzPrZExQit... | \n",
+ " Música de Fiesta | \n",
+ " spotify:track:5iuzPrZExQitcYGBShOSvW | \n",
+ " 0kyQwKHCZnKE7kTXkxXjrB | \n",
+ "
\n",
+ " \n",
+ " | 8 | \n",
+ " 4DPRgzo3TmEOM6DZM11cZU | \n",
+ " https://api.spotify.com/v1/tracks/4DPRgzo3TmEO... | \n",
+ " Traicionera / El Reo Ausente - Desorden Públic... | \n",
+ " spotify:track:4DPRgzo3TmEOM6DZM11cZU | \n",
+ " 0kyQwKHCZnKE7kTXkxXjrB | \n",
+ "
\n",
+ " \n",
+ " | 9 | \n",
+ " 4KrHDgpSoSFj6zDj3Jzbz3 | \n",
+ " https://api.spotify.com/v1/tracks/4KrHDgpSoSFj... | \n",
+ " Latex - En Vivo | \n",
+ " spotify:track:4KrHDgpSoSFj6zDj3Jzbz3 | \n",
+ " 0kyQwKHCZnKE7kTXkxXjrB | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " id href \\\n",
+ "0 6F7uqfzvcdl5Y42mJBVc9V https://api.spotify.com/v1/tracks/6F7uqfzvcdl5... \n",
+ "1 2ntUj3hnSU7GQTKA9oZWW1 https://api.spotify.com/v1/tracks/2ntUj3hnSU7G... \n",
+ "2 6tJn0JYD6QKE6eXbh4829b https://api.spotify.com/v1/tracks/6tJn0JYD6QKE... \n",
+ "3 1f9X3c8Bzn79zkCwnZ2vay https://api.spotify.com/v1/tracks/1f9X3c8Bzn79... \n",
+ "4 1TQLNy86xeKIBnB4O2LOWr https://api.spotify.com/v1/tracks/1TQLNy86xeKI... \n",
+ "5 1eEFMib4nzsUaeWYN0n5Ot https://api.spotify.com/v1/tracks/1eEFMib4nzsU... \n",
+ "6 6B9NhbeAAvCX0oqQLL4inQ https://api.spotify.com/v1/tracks/6B9NhbeAAvCX... \n",
+ "7 5iuzPrZExQitcYGBShOSvW https://api.spotify.com/v1/tracks/5iuzPrZExQit... \n",
+ "8 4DPRgzo3TmEOM6DZM11cZU https://api.spotify.com/v1/tracks/4DPRgzo3TmEO... \n",
+ "9 4KrHDgpSoSFj6zDj3Jzbz3 https://api.spotify.com/v1/tracks/4KrHDgpSoSFj... \n",
+ "\n",
+ " name \\\n",
+ "0 Allá Cayó \n",
+ "1 Los Que Se Quedan, los Que Se Van \n",
+ "2 Tiembla - En Vivo \n",
+ "3 La Danza de los Esqueletos \n",
+ "4 La Cumbia - Desorden Público rinde Homenaje al... \n",
+ "5 Tiemble \n",
+ "6 Combate \n",
+ "7 Música de Fiesta \n",
+ "8 Traicionera / El Reo Ausente - Desorden Públic... \n",
+ "9 Latex - En Vivo \n",
+ "\n",
+ " uri related_id \n",
+ "0 spotify:track:6F7uqfzvcdl5Y42mJBVc9V 0kyQwKHCZnKE7kTXkxXjrB \n",
+ "1 spotify:track:2ntUj3hnSU7GQTKA9oZWW1 0kyQwKHCZnKE7kTXkxXjrB \n",
+ "2 spotify:track:6tJn0JYD6QKE6eXbh4829b 0kyQwKHCZnKE7kTXkxXjrB \n",
+ "3 spotify:track:1f9X3c8Bzn79zkCwnZ2vay 0kyQwKHCZnKE7kTXkxXjrB \n",
+ "4 spotify:track:1TQLNy86xeKIBnB4O2LOWr 0kyQwKHCZnKE7kTXkxXjrB \n",
+ "5 spotify:track:1eEFMib4nzsUaeWYN0n5Ot 0kyQwKHCZnKE7kTXkxXjrB \n",
+ "6 spotify:track:6B9NhbeAAvCX0oqQLL4inQ 0kyQwKHCZnKE7kTXkxXjrB \n",
+ "7 spotify:track:5iuzPrZExQitcYGBShOSvW 0kyQwKHCZnKE7kTXkxXjrB \n",
+ "8 spotify:track:4DPRgzo3TmEOM6DZM11cZU 0kyQwKHCZnKE7kTXkxXjrB \n",
+ "9 spotify:track:4KrHDgpSoSFj6zDj3Jzbz3 0kyQwKHCZnKE7kTXkxXjrB "
+ ]
+ },
+ "execution_count": 20,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "get_top_tracks(artist_id = \"0kyQwKHCZnKE7kTXkxXjrB\")"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 21,
+ "id": "20c8dd11",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "df_artist = pd.DataFrame(dict_artist)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 22,
+ "id": "d4b5e79f",
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " id | \n",
+ " name | \n",
+ " genres | \n",
+ " popularity | \n",
+ " followers | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | 0 | \n",
+ " 0kyQwKHCZnKE7kTXkxXjrB | \n",
+ " Desorden Público | \n",
+ " [caracas indie, latin alternative, latin ska, ... | \n",
+ " 37 | \n",
+ " {'href': None, 'total': 136338} | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " id name \\\n",
+ "0 0kyQwKHCZnKE7kTXkxXjrB Desorden Público \n",
+ "\n",
+ " genres popularity \\\n",
+ "0 [caracas indie, latin alternative, latin ska, ... 37 \n",
+ "\n",
+ " followers \n",
+ "0 {'href': None, 'total': 136338} "
+ ]
+ },
+ "execution_count": 22,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "df_artist"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 23,
+ "id": "79d82dad",
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " artist_id | \n",
+ " artist_name | \n",
+ " artist_genres | \n",
+ " artist_popularity | \n",
+ " artist_followers | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | 0 | \n",
+ " 0kyQwKHCZnKE7kTXkxXjrB | \n",
+ " Desorden Público | \n",
+ " [caracas indie, latin alternative, latin ska, ... | \n",
+ " 37 | \n",
+ " {'href': None, 'total': 136338} | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " artist_id artist_name \\\n",
+ "0 0kyQwKHCZnKE7kTXkxXjrB Desorden Público \n",
+ "\n",
+ " artist_genres artist_popularity \\\n",
+ "0 [caracas indie, latin alternative, latin ska, ... 37 \n",
+ "\n",
+ " artist_followers \n",
+ "0 {'href': None, 'total': 136338} "
+ ]
+ },
+ "execution_count": 23,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "df_artist = df_artist.rename(columns = {\"id\": \"artist_id\",\n",
+ " \"name\":\"artist_name\",\n",
+ " \"genres\":\"artist_genres\",\n",
+ " \"popularity\": \"artist_popularity\",\n",
+ " \"followers\": \"artist_followers\"\n",
+ " })\n",
+ "df_artist"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 24,
+ "id": "dd3b4c65",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "df_artist.drop(\"artist_followers\", axis = 1, inplace = True)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 25,
+ "id": "9629ab32",
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " artist_id | \n",
+ " artist_name | \n",
+ " artist_genres | \n",
+ " artist_popularity | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | 0 | \n",
+ " 0kyQwKHCZnKE7kTXkxXjrB | \n",
+ " Desorden Público | \n",
+ " [caracas indie, latin alternative, latin ska, ... | \n",
+ " 37 | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " artist_id artist_name \\\n",
+ "0 0kyQwKHCZnKE7kTXkxXjrB Desorden Público \n",
+ "\n",
+ " artist_genres artist_popularity \n",
+ "0 [caracas indie, latin alternative, latin ska, ... 37 "
+ ]
+ },
+ "execution_count": 25,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "df_artist"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 26,
+ "id": "a204db5a",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "https://api.spotify.com/v1/artists/0kyQwKHCZnKE7kTXkxXjrB/related-artists\n"
+ ]
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " id | \n",
+ " name | \n",
+ " genres | \n",
+ " popularity | \n",
+ " followers | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | 0 | \n",
+ " 38Wv3iDJm7vyk4OvaHWZxx | \n",
+ " Zapato3 | \n",
+ " [venezuelan rock] | \n",
+ " 29 | \n",
+ " {'href': None, 'total': 69575} | \n",
+ "
\n",
+ " \n",
+ " | 1 | \n",
+ " 6xPMZgR2peupwU41WF9qi7 | \n",
+ " Malanga | \n",
+ " [venezuelan rock] | \n",
+ " 30 | \n",
+ " {'href': None, 'total': 42221} | \n",
+ "
\n",
+ " \n",
+ " | 2 | \n",
+ " 7nx8DlJ8j0sUGBvFtpoEwz | \n",
+ " Sentimiento Muerto | \n",
+ " [latin rock, rock gotico, venezuelan rock] | \n",
+ " 23 | \n",
+ " {'href': None, 'total': 42712} | \n",
+ "
\n",
+ " \n",
+ " | 3 | \n",
+ " 7jLOrU2XbkSEDJL26be4Mr | \n",
+ " Mulato | \n",
+ " [] | \n",
+ " 5 | \n",
+ " {'href': None, 'total': 35053} | \n",
+ "
\n",
+ " \n",
+ " | 4 | \n",
+ " 5nZlhgO7iNedGlO0gKu9us | \n",
+ " King Chango | \n",
+ " [venezuelan rock] | \n",
+ " 40 | \n",
+ " {'href': None, 'total': 98037} | \n",
+ "
\n",
+ " \n",
+ " | 5 | \n",
+ " 1b2FooqkEdKdykGcdEof02 | \n",
+ " Mermelada Bunch | \n",
+ " [venezuelan rock] | \n",
+ " 24 | \n",
+ " {'href': None, 'total': 54368} | \n",
+ "
\n",
+ " \n",
+ " | 6 | \n",
+ " 0WmmhplJiEohqKsYoRLsbq | \n",
+ " PapaShanty SaundSystem | \n",
+ " [venezuelan hip hop, venezuelan rock] | \n",
+ " 22 | \n",
+ " {'href': None, 'total': 30652} | \n",
+ "
\n",
+ " \n",
+ " | 7 | \n",
+ " 48NeXVOrqMUIRc4M8g0lnZ | \n",
+ " Aditus | \n",
+ " [classic venezuelan pop, venezuelan rock] | \n",
+ " 25 | \n",
+ " {'href': None, 'total': 37419} | \n",
+ "
\n",
+ " \n",
+ " | 8 | \n",
+ " 2jZIvxOfIP6hhzthCqRmqI | \n",
+ " Cuarto Poder | \n",
+ " [venezuelan hip hop, venezuelan rock] | \n",
+ " 21 | \n",
+ " {'href': None, 'total': 27537} | \n",
+ "
\n",
+ " \n",
+ " | 9 | \n",
+ " 0gt2Xy6uSRTFTWYrHOHx82 | \n",
+ " Los Mentas | \n",
+ " [venezuelan rock] | \n",
+ " 17 | \n",
+ " {'href': None, 'total': 24642} | \n",
+ "
\n",
+ " \n",
+ " | 10 | \n",
+ " 2i99x70sDfixFZ95bIYayb | \n",
+ " Tomates Fritos | \n",
+ " [venezuelan rock] | \n",
+ " 24 | \n",
+ " {'href': None, 'total': 30453} | \n",
+ "
\n",
+ " \n",
+ " | 11 | \n",
+ " 5rTdxb1YVVZMXscz4wexGu | \n",
+ " 3 Dueños | \n",
+ " [venezuelan hip hop, venezuelan rock] | \n",
+ " 33 | \n",
+ " {'href': None, 'total': 62438} | \n",
+ "
\n",
+ " \n",
+ " | 12 | \n",
+ " 2TPLqqQ9arRHA6Xt7gvZTZ | \n",
+ " Candy66 | \n",
+ " [caracas indie, venezuelan rock] | \n",
+ " 22 | \n",
+ " {'href': None, 'total': 25341} | \n",
+ "
\n",
+ " \n",
+ " | 13 | \n",
+ " 3ZReJfzCEVpHWUSWd5emic | \n",
+ " Frank Quintero | \n",
+ " [classic venezuelan pop, venezuelan rock] | \n",
+ " 28 | \n",
+ " {'href': None, 'total': 49390} | \n",
+ "
\n",
+ " \n",
+ " | 14 | \n",
+ " 0D8yIOlFPxp7OL6n6UzJ38 | \n",
+ " Gran Coquivacoa | \n",
+ " [classic venezuelan pop, gaita zuliana] | \n",
+ " 41 | \n",
+ " {'href': None, 'total': 88901} | \n",
+ "
\n",
+ " \n",
+ " | 15 | \n",
+ " 4SBlgsYD1T6dUV17RDrEBN | \n",
+ " La Corte | \n",
+ " [venezuelan hip hop, venezuelan rock] | \n",
+ " 19 | \n",
+ " {'href': None, 'total': 20543} | \n",
+ "
\n",
+ " \n",
+ " | 16 | \n",
+ " 2zwh4WnVBGZcfnllC7DUxt | \n",
+ " Viniloversus | \n",
+ " [caracas indie, rock en espanol, venezuelan rock] | \n",
+ " 36 | \n",
+ " {'href': None, 'total': 70202} | \n",
+ "
\n",
+ " \n",
+ " | 17 | \n",
+ " 6dTMVeRubUzINO6gmQhWat | \n",
+ " Un Solo Pueblo | \n",
+ " [classic venezuelan pop, folklore venezolano, ... | \n",
+ " 27 | \n",
+ " {'href': None, 'total': 43757} | \n",
+ "
\n",
+ " \n",
+ " | 18 | \n",
+ " 4FNbNj9mlDLitaic9vXlwZ | \n",
+ " Tecupae | \n",
+ " [pop reggaeton, venezuelan rock] | \n",
+ " 34 | \n",
+ " {'href': None, 'total': 102961} | \n",
+ "
\n",
+ " \n",
+ " | 19 | \n",
+ " 1V6FooKFiokndcPHKJ4Tmz | \n",
+ " Maracaibo 15 | \n",
+ " [classic venezuelan pop, gaita zuliana] | \n",
+ " 42 | \n",
+ " {'href': None, 'total': 96047} | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " id name \\\n",
+ "0 38Wv3iDJm7vyk4OvaHWZxx Zapato3 \n",
+ "1 6xPMZgR2peupwU41WF9qi7 Malanga \n",
+ "2 7nx8DlJ8j0sUGBvFtpoEwz Sentimiento Muerto \n",
+ "3 7jLOrU2XbkSEDJL26be4Mr Mulato \n",
+ "4 5nZlhgO7iNedGlO0gKu9us King Chango \n",
+ "5 1b2FooqkEdKdykGcdEof02 Mermelada Bunch \n",
+ "6 0WmmhplJiEohqKsYoRLsbq PapaShanty SaundSystem \n",
+ "7 48NeXVOrqMUIRc4M8g0lnZ Aditus \n",
+ "8 2jZIvxOfIP6hhzthCqRmqI Cuarto Poder \n",
+ "9 0gt2Xy6uSRTFTWYrHOHx82 Los Mentas \n",
+ "10 2i99x70sDfixFZ95bIYayb Tomates Fritos \n",
+ "11 5rTdxb1YVVZMXscz4wexGu 3 Dueños \n",
+ "12 2TPLqqQ9arRHA6Xt7gvZTZ Candy66 \n",
+ "13 3ZReJfzCEVpHWUSWd5emic Frank Quintero \n",
+ "14 0D8yIOlFPxp7OL6n6UzJ38 Gran Coquivacoa \n",
+ "15 4SBlgsYD1T6dUV17RDrEBN La Corte \n",
+ "16 2zwh4WnVBGZcfnllC7DUxt Viniloversus \n",
+ "17 6dTMVeRubUzINO6gmQhWat Un Solo Pueblo \n",
+ "18 4FNbNj9mlDLitaic9vXlwZ Tecupae \n",
+ "19 1V6FooKFiokndcPHKJ4Tmz Maracaibo 15 \n",
+ "\n",
+ " genres popularity \\\n",
+ "0 [venezuelan rock] 29 \n",
+ "1 [venezuelan rock] 30 \n",
+ "2 [latin rock, rock gotico, venezuelan rock] 23 \n",
+ "3 [] 5 \n",
+ "4 [venezuelan rock] 40 \n",
+ "5 [venezuelan rock] 24 \n",
+ "6 [venezuelan hip hop, venezuelan rock] 22 \n",
+ "7 [classic venezuelan pop, venezuelan rock] 25 \n",
+ "8 [venezuelan hip hop, venezuelan rock] 21 \n",
+ "9 [venezuelan rock] 17 \n",
+ "10 [venezuelan rock] 24 \n",
+ "11 [venezuelan hip hop, venezuelan rock] 33 \n",
+ "12 [caracas indie, venezuelan rock] 22 \n",
+ "13 [classic venezuelan pop, venezuelan rock] 28 \n",
+ "14 [classic venezuelan pop, gaita zuliana] 41 \n",
+ "15 [venezuelan hip hop, venezuelan rock] 19 \n",
+ "16 [caracas indie, rock en espanol, venezuelan rock] 36 \n",
+ "17 [classic venezuelan pop, folklore venezolano, ... 27 \n",
+ "18 [pop reggaeton, venezuelan rock] 34 \n",
+ "19 [classic venezuelan pop, gaita zuliana] 42 \n",
+ "\n",
+ " followers \n",
+ "0 {'href': None, 'total': 69575} \n",
+ "1 {'href': None, 'total': 42221} \n",
+ "2 {'href': None, 'total': 42712} \n",
+ "3 {'href': None, 'total': 35053} \n",
+ "4 {'href': None, 'total': 98037} \n",
+ "5 {'href': None, 'total': 54368} \n",
+ "6 {'href': None, 'total': 30652} \n",
+ "7 {'href': None, 'total': 37419} \n",
+ "8 {'href': None, 'total': 27537} \n",
+ "9 {'href': None, 'total': 24642} \n",
+ "10 {'href': None, 'total': 30453} \n",
+ "11 {'href': None, 'total': 62438} \n",
+ "12 {'href': None, 'total': 25341} \n",
+ "13 {'href': None, 'total': 49390} \n",
+ "14 {'href': None, 'total': 88901} \n",
+ "15 {'href': None, 'total': 20543} \n",
+ "16 {'href': None, 'total': 70202} \n",
+ "17 {'href': None, 'total': 43757} \n",
+ "18 {'href': None, 'total': 102961} \n",
+ "19 {'href': None, 'total': 96047} "
+ ]
+ },
+ "execution_count": 26,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "parameters = f\"/{id_selected}/related-artists\"\n",
+ "url = base_url + resource + parameters\n",
+ "print(url)\n",
+ "response = requests.get(url, headers=header_info).json()\n",
+ "response\n",
+ "df_related_artists= pd.DataFrame(response[\"artists\"])[[\"id\", \"name\", \"genres\", \"popularity\", \"followers\"]]\n",
+ "df_related_artists"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 27,
+ "id": "17fa1fd9",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "df_related_artists = df_related_artists.rename(columns={\"id\": \"related_id\",\n",
+ " \"name\":\"related_name\",\n",
+ " \"genres\":\"related_genres\",\n",
+ " \"popularity\": \"related_popularity\",\n",
+ " \"followers\": \"related_followers\"\n",
+ " })"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 28,
+ "id": "f83905c9",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "df_related_artists[\"artist_id\"] = id_selected"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 29,
+ "id": "6a4086c4",
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " related_id | \n",
+ " related_name | \n",
+ " related_genres | \n",
+ " related_popularity | \n",
+ " related_followers | \n",
+ " artist_id | \n",
+ " artist_name | \n",
+ " artist_genres | \n",
+ " artist_popularity | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | 0 | \n",
+ " 38Wv3iDJm7vyk4OvaHWZxx | \n",
+ " Zapato3 | \n",
+ " [venezuelan rock] | \n",
+ " 29 | \n",
+ " {'href': None, 'total': 69575} | \n",
+ " 0kyQwKHCZnKE7kTXkxXjrB | \n",
+ " Desorden Público | \n",
+ " [caracas indie, latin alternative, latin ska, ... | \n",
+ " 37 | \n",
+ "
\n",
+ " \n",
+ " | 1 | \n",
+ " 6xPMZgR2peupwU41WF9qi7 | \n",
+ " Malanga | \n",
+ " [venezuelan rock] | \n",
+ " 30 | \n",
+ " {'href': None, 'total': 42221} | \n",
+ " 0kyQwKHCZnKE7kTXkxXjrB | \n",
+ " Desorden Público | \n",
+ " [caracas indie, latin alternative, latin ska, ... | \n",
+ " 37 | \n",
+ "
\n",
+ " \n",
+ " | 2 | \n",
+ " 7nx8DlJ8j0sUGBvFtpoEwz | \n",
+ " Sentimiento Muerto | \n",
+ " [latin rock, rock gotico, venezuelan rock] | \n",
+ " 23 | \n",
+ " {'href': None, 'total': 42712} | \n",
+ " 0kyQwKHCZnKE7kTXkxXjrB | \n",
+ " Desorden Público | \n",
+ " [caracas indie, latin alternative, latin ska, ... | \n",
+ " 37 | \n",
+ "
\n",
+ " \n",
+ " | 3 | \n",
+ " 7jLOrU2XbkSEDJL26be4Mr | \n",
+ " Mulato | \n",
+ " [] | \n",
+ " 5 | \n",
+ " {'href': None, 'total': 35053} | \n",
+ " 0kyQwKHCZnKE7kTXkxXjrB | \n",
+ " Desorden Público | \n",
+ " [caracas indie, latin alternative, latin ska, ... | \n",
+ " 37 | \n",
+ "
\n",
+ " \n",
+ " | 4 | \n",
+ " 5nZlhgO7iNedGlO0gKu9us | \n",
+ " King Chango | \n",
+ " [venezuelan rock] | \n",
+ " 40 | \n",
+ " {'href': None, 'total': 98037} | \n",
+ " 0kyQwKHCZnKE7kTXkxXjrB | \n",
+ " Desorden Público | \n",
+ " [caracas indie, latin alternative, latin ska, ... | \n",
+ " 37 | \n",
+ "
\n",
+ " \n",
+ " | 5 | \n",
+ " 1b2FooqkEdKdykGcdEof02 | \n",
+ " Mermelada Bunch | \n",
+ " [venezuelan rock] | \n",
+ " 24 | \n",
+ " {'href': None, 'total': 54368} | \n",
+ " 0kyQwKHCZnKE7kTXkxXjrB | \n",
+ " Desorden Público | \n",
+ " [caracas indie, latin alternative, latin ska, ... | \n",
+ " 37 | \n",
+ "
\n",
+ " \n",
+ " | 6 | \n",
+ " 0WmmhplJiEohqKsYoRLsbq | \n",
+ " PapaShanty SaundSystem | \n",
+ " [venezuelan hip hop, venezuelan rock] | \n",
+ " 22 | \n",
+ " {'href': None, 'total': 30652} | \n",
+ " 0kyQwKHCZnKE7kTXkxXjrB | \n",
+ " Desorden Público | \n",
+ " [caracas indie, latin alternative, latin ska, ... | \n",
+ " 37 | \n",
+ "
\n",
+ " \n",
+ " | 7 | \n",
+ " 48NeXVOrqMUIRc4M8g0lnZ | \n",
+ " Aditus | \n",
+ " [classic venezuelan pop, venezuelan rock] | \n",
+ " 25 | \n",
+ " {'href': None, 'total': 37419} | \n",
+ " 0kyQwKHCZnKE7kTXkxXjrB | \n",
+ " Desorden Público | \n",
+ " [caracas indie, latin alternative, latin ska, ... | \n",
+ " 37 | \n",
+ "
\n",
+ " \n",
+ " | 8 | \n",
+ " 2jZIvxOfIP6hhzthCqRmqI | \n",
+ " Cuarto Poder | \n",
+ " [venezuelan hip hop, venezuelan rock] | \n",
+ " 21 | \n",
+ " {'href': None, 'total': 27537} | \n",
+ " 0kyQwKHCZnKE7kTXkxXjrB | \n",
+ " Desorden Público | \n",
+ " [caracas indie, latin alternative, latin ska, ... | \n",
+ " 37 | \n",
+ "
\n",
+ " \n",
+ " | 9 | \n",
+ " 0gt2Xy6uSRTFTWYrHOHx82 | \n",
+ " Los Mentas | \n",
+ " [venezuelan rock] | \n",
+ " 17 | \n",
+ " {'href': None, 'total': 24642} | \n",
+ " 0kyQwKHCZnKE7kTXkxXjrB | \n",
+ " Desorden Público | \n",
+ " [caracas indie, latin alternative, latin ska, ... | \n",
+ " 37 | \n",
+ "
\n",
+ " \n",
+ " | 10 | \n",
+ " 2i99x70sDfixFZ95bIYayb | \n",
+ " Tomates Fritos | \n",
+ " [venezuelan rock] | \n",
+ " 24 | \n",
+ " {'href': None, 'total': 30453} | \n",
+ " 0kyQwKHCZnKE7kTXkxXjrB | \n",
+ " Desorden Público | \n",
+ " [caracas indie, latin alternative, latin ska, ... | \n",
+ " 37 | \n",
+ "
\n",
+ " \n",
+ " | 11 | \n",
+ " 5rTdxb1YVVZMXscz4wexGu | \n",
+ " 3 Dueños | \n",
+ " [venezuelan hip hop, venezuelan rock] | \n",
+ " 33 | \n",
+ " {'href': None, 'total': 62438} | \n",
+ " 0kyQwKHCZnKE7kTXkxXjrB | \n",
+ " Desorden Público | \n",
+ " [caracas indie, latin alternative, latin ska, ... | \n",
+ " 37 | \n",
+ "
\n",
+ " \n",
+ " | 12 | \n",
+ " 2TPLqqQ9arRHA6Xt7gvZTZ | \n",
+ " Candy66 | \n",
+ " [caracas indie, venezuelan rock] | \n",
+ " 22 | \n",
+ " {'href': None, 'total': 25341} | \n",
+ " 0kyQwKHCZnKE7kTXkxXjrB | \n",
+ " Desorden Público | \n",
+ " [caracas indie, latin alternative, latin ska, ... | \n",
+ " 37 | \n",
+ "
\n",
+ " \n",
+ " | 13 | \n",
+ " 3ZReJfzCEVpHWUSWd5emic | \n",
+ " Frank Quintero | \n",
+ " [classic venezuelan pop, venezuelan rock] | \n",
+ " 28 | \n",
+ " {'href': None, 'total': 49390} | \n",
+ " 0kyQwKHCZnKE7kTXkxXjrB | \n",
+ " Desorden Público | \n",
+ " [caracas indie, latin alternative, latin ska, ... | \n",
+ " 37 | \n",
+ "
\n",
+ " \n",
+ " | 14 | \n",
+ " 0D8yIOlFPxp7OL6n6UzJ38 | \n",
+ " Gran Coquivacoa | \n",
+ " [classic venezuelan pop, gaita zuliana] | \n",
+ " 41 | \n",
+ " {'href': None, 'total': 88901} | \n",
+ " 0kyQwKHCZnKE7kTXkxXjrB | \n",
+ " Desorden Público | \n",
+ " [caracas indie, latin alternative, latin ska, ... | \n",
+ " 37 | \n",
+ "
\n",
+ " \n",
+ " | 15 | \n",
+ " 4SBlgsYD1T6dUV17RDrEBN | \n",
+ " La Corte | \n",
+ " [venezuelan hip hop, venezuelan rock] | \n",
+ " 19 | \n",
+ " {'href': None, 'total': 20543} | \n",
+ " 0kyQwKHCZnKE7kTXkxXjrB | \n",
+ " Desorden Público | \n",
+ " [caracas indie, latin alternative, latin ska, ... | \n",
+ " 37 | \n",
+ "
\n",
+ " \n",
+ " | 16 | \n",
+ " 2zwh4WnVBGZcfnllC7DUxt | \n",
+ " Viniloversus | \n",
+ " [caracas indie, rock en espanol, venezuelan rock] | \n",
+ " 36 | \n",
+ " {'href': None, 'total': 70202} | \n",
+ " 0kyQwKHCZnKE7kTXkxXjrB | \n",
+ " Desorden Público | \n",
+ " [caracas indie, latin alternative, latin ska, ... | \n",
+ " 37 | \n",
+ "
\n",
+ " \n",
+ " | 17 | \n",
+ " 6dTMVeRubUzINO6gmQhWat | \n",
+ " Un Solo Pueblo | \n",
+ " [classic venezuelan pop, folklore venezolano, ... | \n",
+ " 27 | \n",
+ " {'href': None, 'total': 43757} | \n",
+ " 0kyQwKHCZnKE7kTXkxXjrB | \n",
+ " Desorden Público | \n",
+ " [caracas indie, latin alternative, latin ska, ... | \n",
+ " 37 | \n",
+ "
\n",
+ " \n",
+ " | 18 | \n",
+ " 4FNbNj9mlDLitaic9vXlwZ | \n",
+ " Tecupae | \n",
+ " [pop reggaeton, venezuelan rock] | \n",
+ " 34 | \n",
+ " {'href': None, 'total': 102961} | \n",
+ " 0kyQwKHCZnKE7kTXkxXjrB | \n",
+ " Desorden Público | \n",
+ " [caracas indie, latin alternative, latin ska, ... | \n",
+ " 37 | \n",
+ "
\n",
+ " \n",
+ " | 19 | \n",
+ " 1V6FooKFiokndcPHKJ4Tmz | \n",
+ " Maracaibo 15 | \n",
+ " [classic venezuelan pop, gaita zuliana] | \n",
+ " 42 | \n",
+ " {'href': None, 'total': 96047} | \n",
+ " 0kyQwKHCZnKE7kTXkxXjrB | \n",
+ " Desorden Público | \n",
+ " [caracas indie, latin alternative, latin ska, ... | \n",
+ " 37 | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " related_id related_name \\\n",
+ "0 38Wv3iDJm7vyk4OvaHWZxx Zapato3 \n",
+ "1 6xPMZgR2peupwU41WF9qi7 Malanga \n",
+ "2 7nx8DlJ8j0sUGBvFtpoEwz Sentimiento Muerto \n",
+ "3 7jLOrU2XbkSEDJL26be4Mr Mulato \n",
+ "4 5nZlhgO7iNedGlO0gKu9us King Chango \n",
+ "5 1b2FooqkEdKdykGcdEof02 Mermelada Bunch \n",
+ "6 0WmmhplJiEohqKsYoRLsbq PapaShanty SaundSystem \n",
+ "7 48NeXVOrqMUIRc4M8g0lnZ Aditus \n",
+ "8 2jZIvxOfIP6hhzthCqRmqI Cuarto Poder \n",
+ "9 0gt2Xy6uSRTFTWYrHOHx82 Los Mentas \n",
+ "10 2i99x70sDfixFZ95bIYayb Tomates Fritos \n",
+ "11 5rTdxb1YVVZMXscz4wexGu 3 Dueños \n",
+ "12 2TPLqqQ9arRHA6Xt7gvZTZ Candy66 \n",
+ "13 3ZReJfzCEVpHWUSWd5emic Frank Quintero \n",
+ "14 0D8yIOlFPxp7OL6n6UzJ38 Gran Coquivacoa \n",
+ "15 4SBlgsYD1T6dUV17RDrEBN La Corte \n",
+ "16 2zwh4WnVBGZcfnllC7DUxt Viniloversus \n",
+ "17 6dTMVeRubUzINO6gmQhWat Un Solo Pueblo \n",
+ "18 4FNbNj9mlDLitaic9vXlwZ Tecupae \n",
+ "19 1V6FooKFiokndcPHKJ4Tmz Maracaibo 15 \n",
+ "\n",
+ " related_genres related_popularity \\\n",
+ "0 [venezuelan rock] 29 \n",
+ "1 [venezuelan rock] 30 \n",
+ "2 [latin rock, rock gotico, venezuelan rock] 23 \n",
+ "3 [] 5 \n",
+ "4 [venezuelan rock] 40 \n",
+ "5 [venezuelan rock] 24 \n",
+ "6 [venezuelan hip hop, venezuelan rock] 22 \n",
+ "7 [classic venezuelan pop, venezuelan rock] 25 \n",
+ "8 [venezuelan hip hop, venezuelan rock] 21 \n",
+ "9 [venezuelan rock] 17 \n",
+ "10 [venezuelan rock] 24 \n",
+ "11 [venezuelan hip hop, venezuelan rock] 33 \n",
+ "12 [caracas indie, venezuelan rock] 22 \n",
+ "13 [classic venezuelan pop, venezuelan rock] 28 \n",
+ "14 [classic venezuelan pop, gaita zuliana] 41 \n",
+ "15 [venezuelan hip hop, venezuelan rock] 19 \n",
+ "16 [caracas indie, rock en espanol, venezuelan rock] 36 \n",
+ "17 [classic venezuelan pop, folklore venezolano, ... 27 \n",
+ "18 [pop reggaeton, venezuelan rock] 34 \n",
+ "19 [classic venezuelan pop, gaita zuliana] 42 \n",
+ "\n",
+ " related_followers artist_id artist_name \\\n",
+ "0 {'href': None, 'total': 69575} 0kyQwKHCZnKE7kTXkxXjrB Desorden Público \n",
+ "1 {'href': None, 'total': 42221} 0kyQwKHCZnKE7kTXkxXjrB Desorden Público \n",
+ "2 {'href': None, 'total': 42712} 0kyQwKHCZnKE7kTXkxXjrB Desorden Público \n",
+ "3 {'href': None, 'total': 35053} 0kyQwKHCZnKE7kTXkxXjrB Desorden Público \n",
+ "4 {'href': None, 'total': 98037} 0kyQwKHCZnKE7kTXkxXjrB Desorden Público \n",
+ "5 {'href': None, 'total': 54368} 0kyQwKHCZnKE7kTXkxXjrB Desorden Público \n",
+ "6 {'href': None, 'total': 30652} 0kyQwKHCZnKE7kTXkxXjrB Desorden Público \n",
+ "7 {'href': None, 'total': 37419} 0kyQwKHCZnKE7kTXkxXjrB Desorden Público \n",
+ "8 {'href': None, 'total': 27537} 0kyQwKHCZnKE7kTXkxXjrB Desorden Público \n",
+ "9 {'href': None, 'total': 24642} 0kyQwKHCZnKE7kTXkxXjrB Desorden Público \n",
+ "10 {'href': None, 'total': 30453} 0kyQwKHCZnKE7kTXkxXjrB Desorden Público \n",
+ "11 {'href': None, 'total': 62438} 0kyQwKHCZnKE7kTXkxXjrB Desorden Público \n",
+ "12 {'href': None, 'total': 25341} 0kyQwKHCZnKE7kTXkxXjrB Desorden Público \n",
+ "13 {'href': None, 'total': 49390} 0kyQwKHCZnKE7kTXkxXjrB Desorden Público \n",
+ "14 {'href': None, 'total': 88901} 0kyQwKHCZnKE7kTXkxXjrB Desorden Público \n",
+ "15 {'href': None, 'total': 20543} 0kyQwKHCZnKE7kTXkxXjrB Desorden Público \n",
+ "16 {'href': None, 'total': 70202} 0kyQwKHCZnKE7kTXkxXjrB Desorden Público \n",
+ "17 {'href': None, 'total': 43757} 0kyQwKHCZnKE7kTXkxXjrB Desorden Público \n",
+ "18 {'href': None, 'total': 102961} 0kyQwKHCZnKE7kTXkxXjrB Desorden Público \n",
+ "19 {'href': None, 'total': 96047} 0kyQwKHCZnKE7kTXkxXjrB Desorden Público \n",
+ "\n",
+ " artist_genres artist_popularity \n",
+ "0 [caracas indie, latin alternative, latin ska, ... 37 \n",
+ "1 [caracas indie, latin alternative, latin ska, ... 37 \n",
+ "2 [caracas indie, latin alternative, latin ska, ... 37 \n",
+ "3 [caracas indie, latin alternative, latin ska, ... 37 \n",
+ "4 [caracas indie, latin alternative, latin ska, ... 37 \n",
+ "5 [caracas indie, latin alternative, latin ska, ... 37 \n",
+ "6 [caracas indie, latin alternative, latin ska, ... 37 \n",
+ "7 [caracas indie, latin alternative, latin ska, ... 37 \n",
+ "8 [caracas indie, latin alternative, latin ska, ... 37 \n",
+ "9 [caracas indie, latin alternative, latin ska, ... 37 \n",
+ "10 [caracas indie, latin alternative, latin ska, ... 37 \n",
+ "11 [caracas indie, latin alternative, latin ska, ... 37 \n",
+ "12 [caracas indie, latin alternative, latin ska, ... 37 \n",
+ "13 [caracas indie, latin alternative, latin ska, ... 37 \n",
+ "14 [caracas indie, latin alternative, latin ska, ... 37 \n",
+ "15 [caracas indie, latin alternative, latin ska, ... 37 \n",
+ "16 [caracas indie, latin alternative, latin ska, ... 37 \n",
+ "17 [caracas indie, latin alternative, latin ska, ... 37 \n",
+ "18 [caracas indie, latin alternative, latin ska, ... 37 \n",
+ "19 [caracas indie, latin alternative, latin ska, ... 37 "
+ ]
+ },
+ "execution_count": 29,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "df_related_artists = pd.merge(df_related_artists, df_artist, on=\"artist_id\")\n",
+ "df_related_artists"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "98827be6",
+ "metadata": {},
+ "source": [
+ "---\n",
+ "\n",
+ "### Bonus track!!!\n",
+ "\n",
+ "You can publish your own Playlist with [`/playlists`](https://developer.spotify.com/documentation/web-api/reference/#/operations/create-playlist) and [`/tracks`](https://developer.spotify.com/documentation/web-api/reference/#/operations/add-tracks-to-playlist).\n",
+ "\n",
+ ""
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 30,
+ "id": "2e5f0905",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "# Bonus\n",
+ "\n",
+ "\n"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "9436b623",
+ "metadata": {},
+ "source": [
+ "---"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "a9487ef7",
+ "metadata": {},
+ "source": [
+ "You can always try with the [wrapper](https://github.com/plamere/spotipy)!!!\n",
+ "\n",
+ ""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "0a399ce8",
+ "metadata": {},
+ "source": [
+ "---"
+ ]
+ }
+ ],
+ "metadata": {
+ "kernelspec": {
+ "display_name": "Python (m1_env)",
+ "language": "python",
+ "name": "m1_env"
+ },
+ "language_info": {
+ "codemirror_mode": {
+ "name": "ipython",
+ "version": 3
+ },
+ "file_extension": ".py",
+ "mimetype": "text/x-python",
+ "name": "python",
+ "nbconvert_exporter": "python",
+ "pygments_lexer": "ipython3",
+ "version": "3.10.13"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 5
+}