diff --git a/notebooks/spotify_rest_api_challenge.ipynb b/notebooks/spotify_rest_api_challenge.ipynb index 5e4f8f7..7438fe6 100644 --- a/notebooks/spotify_rest_api_challenge.ipynb +++ b/notebooks/spotify_rest_api_challenge.ipynb @@ -16,14 +16,15 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 1, "id": "17a49776", "metadata": {}, "outputs": [], "source": [ "# Imports\n", - "\n", - "\n" + "import pandas as pd\n", + "import requests\n", + "import numpy " ] }, { @@ -38,21 +39,21 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 2, "id": "7b5d2e52", "metadata": {}, "outputs": [], "source": [ "# Generate token with a POST request\n", "\n", - "client_id = # CLIENT ID\n", - "client_secret = # CLIENT SECRET\n", + "client_id = '039788c504f24ade81392f9f5113db0f' # CLIENT ID (esto sale en la web de Spotify Develper)\n", + "client_secret = '63e5bcffb8ca4061a62477cd5c4a808c' # CLIENT SECRET\n", "auth_url = 'https://accounts.spotify.com/api/token'" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 3, "id": "c7901d1e", "metadata": {}, "outputs": [], @@ -64,10 +65,46 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 4, + "id": "66dd51b0", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{'access_token': 'BQBzo7c7BMYA3PaaNDIrGv3Ys0mxL_iDgRVav-7lsCnBboz6tjHm-UfxvaYMQD1ID1ymBgkdvZNhielLvYtohzbsufFVZHBiMI9ttYWeClsK56lMZ6Q',\n", + " 'token_type': 'Bearer',\n", + " 'expires_in': 3600}" + ] + }, + "execution_count": 4, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "auth_response" + ] + }, + { + "cell_type": "code", + "execution_count": 5, "id": "262e7e18", "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "{'access_token': 'BQBzo7c7BMYA3PaaNDIrGv3Ys0mxL_iDgRVav-7lsCnBboz6tjHm-UfxvaYMQD1ID1ymBgkdvZNhielLvYtohzbsufFVZHBiMI9ttYWeClsK56lMZ6Q',\n", + " 'token_type': 'Bearer',\n", + " 'expires_in': 3600}" + ] + }, + "execution_count": 5, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "access_token = auth_response['access_token']\n", "auth_response" @@ -85,7 +122,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 6, "id": "62e6d4fb", "metadata": {}, "outputs": [], @@ -98,12 +135,33 @@ "header_info = {'Authorization': 'Bearer {token}'.format(token=access_token)}" ] }, + { + "cell_type": "code", + "execution_count": 301, + "id": "d19ec18f", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{'Authorization': 'Bearer BQAI-cJQo00Fb0Lc7K3WquHSsyeQk1C4w7O_UKm9bimgGHVcW3dTz9o9ymaylqhurhc1Qc2dYzs0xGeVLb8Bx4VYruUfmMeEUftC3nDma95KVmb28YE'}" + ] + }, + "execution_count": 301, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "header_info" + ] + }, { "cell_type": "markdown", "id": "16660a9b", "metadata": {}, "source": [ - "### Create your new playlist!!!\n", + "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", @@ -143,27 +201,1231 @@ }, { "cell_type": "code", - "execution_count": null, - "id": "04f85940", + "execution_count": 7, + "id": "fc8404b2", "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "'https://api.spotify.com/v1/artists/7mWCSSOYqm4E9mB7V4ot6S'" + ] + }, + "execution_count": 7, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "# Here you can complete your endpoint URI\n", + "artist_id = '7mWCSSOYqm4E9mB7V4ot6S'\n", + "related_artists = '/related-artists'\n", + "top_tracks = '/top-tracks'\n", + "country = '?country=us'\n", "\n", - "full_endpoint = \n", + "full_endpoint = base_url + resource + artist_id\n", "full_endpoint" ] }, { "cell_type": "code", - "execution_count": null, - "id": "50ec3959", + "execution_count": 13, + "id": "5cb5334c", "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "{'external_urls': {'spotify': 'https://open.spotify.com/artist/7mWCSSOYqm4E9mB7V4ot6S'},\n", + " 'followers': {'href': None, 'total': 2633775},\n", + " 'genres': ['latin pop', 'mexican pop'],\n", + " 'href': 'https://api.spotify.com/v1/artists/7mWCSSOYqm4E9mB7V4ot6S',\n", + " 'id': '7mWCSSOYqm4E9mB7V4ot6S',\n", + " 'images': [{'height': 640,\n", + " 'url': 'https://i.scdn.co/image/ab6761610000e5eb7d888623c984600e6af1fdc5',\n", + " 'width': 640},\n", + " {'height': 320,\n", + " 'url': 'https://i.scdn.co/image/ab676161000051747d888623c984600e6af1fdc5',\n", + " 'width': 320},\n", + " {'height': 160,\n", + " 'url': 'https://i.scdn.co/image/ab6761610000f1787d888623c984600e6af1fdc5',\n", + " 'width': 160}],\n", + " 'name': 'Miguel Bosé',\n", + " 'popularity': 67,\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:7mWCSSOYqm4E9mB7V4ot6S'}" + ] + }, + "execution_count": 13, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "#start builing your playlist !!!\n", + "response = requests.get(full_endpoint, headers=header_info).json() #aqui estas pasando lo que te identifica\n", + "response #siempre darle un nombre al argumento " + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "id": "38ef72f5", + "metadata": {}, + "outputs": [ + { + "ename": "AttributeError", + "evalue": "'dict' object has no attribute 'json'", + "output_type": "error", + "traceback": [ + "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[1;31mAttributeError\u001b[0m Traceback (most recent call last)", + "Cell \u001b[1;32mIn[12], line 1\u001b[0m\n\u001b[1;32m----> 1\u001b[0m res_dict \u001b[38;5;241m=\u001b[39m \u001b[43mresponse\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mjson\u001b[49m()\n\u001b[0;32m 2\u001b[0m \u001b[38;5;28mlen\u001b[39m(res_dict)\n", + "\u001b[1;31mAttributeError\u001b[0m: 'dict' object has no attribute 'json'" + ] + } + ], + "source": [ + "res_dict = response.json()\n", + "len(res_dict)" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "id": "8c8a849a", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "dict_keys(['external_urls', 'followers', 'genres', 'href', 'id', 'images', 'name', 'popularity', 'type', 'uri'])" + ] + }, + "execution_count": 14, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "key_list = response.keys()\n", + "key_list" + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "id": "04c2826f", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "external_urls ---> {'spotify': 'https://open.spotify.com/artist/7mWCSSOYqm4E9mB7V4ot6S'}\n", + "followers ---> {'href': None, 'total': 2633775}\n", + "genres ---> ['latin pop', 'mexican pop']\n", + "href ---> https://api.spotify.com/v1/artists/7mWCSSOYqm4E9mB7V4ot6S\n", + "id ---> 7mWCSSOYqm4E9mB7V4ot6S\n", + "images ---> [{'height': 640, 'url': 'https://i.scdn.co/image/ab6761610000e5eb7d888623c984600e6af1fdc5', 'width': 640}, {'height': 320, 'url': 'https://i.scdn.co/image/ab676161000051747d888623c984600e6af1fdc5', 'width': 320}, {'height': 160, 'url': 'https://i.scdn.co/image/ab6761610000f1787d888623c984600e6af1fdc5', 'width': 160}]\n", + "name ---> Miguel Bosé\n", + "popularity ---> 67\n", + "type ---> artist\n", + "uri ---> spotify:artist:7mWCSSOYqm4E9mB7V4ot6S\n" + ] + } + ], + "source": [ + "for key in key_list:\n", + " print(key, '--->' ,response[key])" + ] + }, + { + "cell_type": "code", + "execution_count": 17, + "id": "fb23ee98", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "https://api.spotify.com/v1/artists/7mWCSSOYqm4E9mB7V4ot6S\n" + ] + }, + { + "data": { + "text/plain": [ + "" + ] + }, + "execution_count": 17, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "full_endpoint_01 = full_endpoint + related_artists\n", + "print(full_endpoint)\n", + "\n", + "response_1 = requests.get(full_endpoint_01, headers=header_info)\n", + "response_1" + ] + }, + { + "cell_type": "code", + "execution_count": 18, + "id": "7d51ef56", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{'artists': [{'external_urls': {'spotify': 'https://open.spotify.com/artist/5YekZn3GGnPIURNA6RG124'},\n", + " 'followers': {'href': None, 'total': 711076},\n", + " 'genres': ['latin arena pop', 'latin pop', 'mexican pop'],\n", + " 'href': 'https://api.spotify.com/v1/artists/5YekZn3GGnPIURNA6RG124',\n", + " 'id': '5YekZn3GGnPIURNA6RG124',\n", + " 'images': [{'height': 640,\n", + " 'url': 'https://i.scdn.co/image/ab6761610000e5eb8b292ea605f0b366b81b66d5',\n", + " 'width': 640},\n", + " {'height': 320,\n", + " 'url': 'https://i.scdn.co/image/ab676161000051748b292ea605f0b366b81b66d5',\n", + " 'width': 320},\n", + " {'height': 160,\n", + " 'url': 'https://i.scdn.co/image/ab6761610000f1788b292ea605f0b366b81b66d5',\n", + " 'width': 160}],\n", + " 'name': 'Ana Torroja',\n", + " 'popularity': 57,\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:5YekZn3GGnPIURNA6RG124'},\n", + " {'external_urls': {'spotify': 'https://open.spotify.com/artist/5BMgsAFg8rZQc3tqs5BB8G'},\n", + " 'followers': {'href': None, 'total': 1714889},\n", + " 'genres': ['cantautor',\n", + " 'latin alternative',\n", + " 'latin pop',\n", + " 'rock en espanol',\n", + " 'spanish pop',\n", + " 'spanish pop rock'],\n", + " 'href': 'https://api.spotify.com/v1/artists/5BMgsAFg8rZQc3tqs5BB8G',\n", + " 'id': '5BMgsAFg8rZQc3tqs5BB8G',\n", + " 'images': [{'height': 605,\n", + " 'url': 'https://i.scdn.co/image/d6b66ff338e079e9db9ad7841fc34e56ba1c4eb3',\n", + " 'width': 600},\n", + " {'height': 202,\n", + " 'url': 'https://i.scdn.co/image/e3fa2e604da0e7bd31c9d0ad10e50e6fda255924',\n", + " 'width': 200},\n", + " {'height': 65,\n", + " 'url': 'https://i.scdn.co/image/901ff649cfb04d22f4f14a1ea1f5ed40b3e4cc22',\n", + " 'width': 64}],\n", + " 'name': 'Mecano',\n", + " 'popularity': 64,\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:5BMgsAFg8rZQc3tqs5BB8G'},\n", + " {'external_urls': {'spotify': 'https://open.spotify.com/artist/7DC1oixQ38ba8Lyk47RlS5'},\n", + " 'followers': {'href': None, 'total': 357375},\n", + " 'genres': ['cantautor', 'spanish pop'],\n", + " 'href': 'https://api.spotify.com/v1/artists/7DC1oixQ38ba8Lyk47RlS5',\n", + " 'id': '7DC1oixQ38ba8Lyk47RlS5',\n", + " 'images': [{'height': 693,\n", + " 'url': 'https://i.scdn.co/image/77dda715f5df8fe2bb2c6ef2e7b620338419f5c4',\n", + " 'width': 1000},\n", + " {'height': 444,\n", + " 'url': 'https://i.scdn.co/image/3457ddfaa27ed7ec5d39c71281ef17f88eccb860',\n", + " 'width': 640},\n", + " {'height': 139,\n", + " 'url': 'https://i.scdn.co/image/12c8ecf87761801ca8046bb31285f7e046217086',\n", + " 'width': 200},\n", + " {'height': 44,\n", + " 'url': 'https://i.scdn.co/image/882b7730bcdcb8e9fe95668fc32cf65c811ee663',\n", + " 'width': 63}],\n", + " 'name': 'Presuntos Implicados',\n", + " 'popularity': 44,\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:7DC1oixQ38ba8Lyk47RlS5'},\n", + " {'external_urls': {'spotify': 'https://open.spotify.com/artist/15FscPIs0VO23BCCMaPglf'},\n", + " 'followers': {'href': None, 'total': 337125},\n", + " 'genres': ['latin pop', 'spanish new wave', 'spanish pop'],\n", + " 'href': 'https://api.spotify.com/v1/artists/15FscPIs0VO23BCCMaPglf',\n", + " 'id': '15FscPIs0VO23BCCMaPglf',\n", + " 'images': [{'height': 640,\n", + " 'url': 'https://i.scdn.co/image/ab6761610000e5ebadf8dd0c9b605aec3ff024ac',\n", + " 'width': 640},\n", + " {'height': 320,\n", + " 'url': 'https://i.scdn.co/image/ab67616100005174adf8dd0c9b605aec3ff024ac',\n", + " 'width': 320},\n", + " {'height': 160,\n", + " 'url': 'https://i.scdn.co/image/ab6761610000f178adf8dd0c9b605aec3ff024ac',\n", + " 'width': 160}],\n", + " 'name': 'Amistades Peligrosas',\n", + " 'popularity': 49,\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:15FscPIs0VO23BCCMaPglf'},\n", + " {'external_urls': {'spotify': 'https://open.spotify.com/artist/368rTiMKMrz3b03az6B14w'},\n", + " 'followers': {'href': None, 'total': 419750},\n", + " 'genres': ['latin pop', 'spanish pop'],\n", + " 'href': 'https://api.spotify.com/v1/artists/368rTiMKMrz3b03az6B14w',\n", + " 'id': '368rTiMKMrz3b03az6B14w',\n", + " 'images': [{'height': 640,\n", + " 'url': 'https://i.scdn.co/image/ab6761610000e5eb4fc9bd4ffbe271ef8661b51e',\n", + " 'width': 640},\n", + " {'height': 320,\n", + " 'url': 'https://i.scdn.co/image/ab676161000051744fc9bd4ffbe271ef8661b51e',\n", + " 'width': 320},\n", + " {'height': 160,\n", + " 'url': 'https://i.scdn.co/image/ab6761610000f1784fc9bd4ffbe271ef8661b51e',\n", + " 'width': 160}],\n", + " 'name': 'Marta Sánchez',\n", + " 'popularity': 61,\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:368rTiMKMrz3b03az6B14w'},\n", + " {'external_urls': {'spotify': 'https://open.spotify.com/artist/0r8toju2ecKaVtItkzAnNi'},\n", + " 'followers': {'href': None, 'total': 1501891},\n", + " 'genres': ['latin arena pop', 'latin pop', 'mexican pop'],\n", + " 'href': 'https://api.spotify.com/v1/artists/0r8toju2ecKaVtItkzAnNi',\n", + " 'id': '0r8toju2ecKaVtItkzAnNi',\n", + " 'images': [{'height': 640,\n", + " 'url': 'https://i.scdn.co/image/ab6761610000e5eb42f305eae2574365774fbb6a',\n", + " 'width': 640},\n", + " {'height': 320,\n", + " 'url': 'https://i.scdn.co/image/ab6761610000517442f305eae2574365774fbb6a',\n", + " 'width': 320},\n", + " {'height': 160,\n", + " 'url': 'https://i.scdn.co/image/ab6761610000f17842f305eae2574365774fbb6a',\n", + " 'width': 160}],\n", + " 'name': 'Aleks Syntek',\n", + " 'popularity': 63,\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:0r8toju2ecKaVtItkzAnNi'},\n", + " {'external_urls': {'spotify': 'https://open.spotify.com/artist/4zbqGb99bANxJBsvwRr2zT'},\n", + " 'followers': {'href': None, 'total': 791005},\n", + " 'genres': ['latin pop', 'ranchera'],\n", + " 'href': 'https://api.spotify.com/v1/artists/4zbqGb99bANxJBsvwRr2zT',\n", + " 'id': '4zbqGb99bANxJBsvwRr2zT',\n", + " 'images': [{'height': 640,\n", + " 'url': 'https://i.scdn.co/image/ab6761610000e5eb3843a6259038f25fe8ffab1f',\n", + " 'width': 640},\n", + " {'height': 320,\n", + " 'url': 'https://i.scdn.co/image/ab676161000051743843a6259038f25fe8ffab1f',\n", + " 'width': 320},\n", + " {'height': 160,\n", + " 'url': 'https://i.scdn.co/image/ab6761610000f1783843a6259038f25fe8ffab1f',\n", + " 'width': 160}],\n", + " 'name': 'Flans',\n", + " 'popularity': 57,\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:4zbqGb99bANxJBsvwRr2zT'},\n", + " {'external_urls': {'spotify': 'https://open.spotify.com/artist/2DmYtFBKcxb3ajwWWgA576'},\n", + " 'followers': {'href': None, 'total': 2756131},\n", + " 'genres': ['latin pop', 'mexican pop', 'ranchera'],\n", + " 'href': 'https://api.spotify.com/v1/artists/2DmYtFBKcxb3ajwWWgA576',\n", + " 'id': '2DmYtFBKcxb3ajwWWgA576',\n", + " 'images': [{'height': 640,\n", + " 'url': 'https://i.scdn.co/image/ab6761610000e5eba3917d80a09bffd0a05a3e89',\n", + " 'width': 640},\n", + " {'height': 320,\n", + " 'url': 'https://i.scdn.co/image/ab67616100005174a3917d80a09bffd0a05a3e89',\n", + " 'width': 320},\n", + " {'height': 160,\n", + " 'url': 'https://i.scdn.co/image/ab6761610000f178a3917d80a09bffd0a05a3e89',\n", + " 'width': 160}],\n", + " 'name': 'Emmanuel',\n", + " 'popularity': 67,\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:2DmYtFBKcxb3ajwWWgA576'},\n", + " {'external_urls': {'spotify': 'https://open.spotify.com/artist/0zGM73sadbAOBLev02P8LO'},\n", + " 'followers': {'href': None, 'total': 765717},\n", + " 'genres': ['latin arena pop',\n", + " 'latin pop',\n", + " 'mexican pop',\n", + " 'spanish pop',\n", + " 'spanish pop rock'],\n", + " 'href': 'https://api.spotify.com/v1/artists/0zGM73sadbAOBLev02P8LO',\n", + " 'id': '0zGM73sadbAOBLev02P8LO',\n", + " 'images': [{'height': 640,\n", + " 'url': 'https://i.scdn.co/image/ab6761610000e5eb1c87d7ed67eee9ba00985447',\n", + " 'width': 640},\n", + " {'height': 320,\n", + " 'url': 'https://i.scdn.co/image/ab676161000051741c87d7ed67eee9ba00985447',\n", + " 'width': 320},\n", + " {'height': 160,\n", + " 'url': 'https://i.scdn.co/image/ab6761610000f1781c87d7ed67eee9ba00985447',\n", + " 'width': 160}],\n", + " 'name': 'Monica Naranjo',\n", + " 'popularity': 56,\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:0zGM73sadbAOBLev02P8LO'},\n", + " {'external_urls': {'spotify': 'https://open.spotify.com/artist/3zhijRRIZX2B6G2T7vJl9p'},\n", + " 'followers': {'href': None, 'total': 2098260},\n", + " 'genres': ['latin pop', 'mexican pop'],\n", + " 'href': 'https://api.spotify.com/v1/artists/3zhijRRIZX2B6G2T7vJl9p',\n", + " 'id': '3zhijRRIZX2B6G2T7vJl9p',\n", + " 'images': [{'height': 640,\n", + " 'url': 'https://i.scdn.co/image/ab6761610000e5eb3e16dd210daca896df659aff',\n", + " 'width': 640},\n", + " {'height': 320,\n", + " 'url': 'https://i.scdn.co/image/ab676161000051743e16dd210daca896df659aff',\n", + " 'width': 320},\n", + " {'height': 160,\n", + " 'url': 'https://i.scdn.co/image/ab6761610000f1783e16dd210daca896df659aff',\n", + " 'width': 160}],\n", + " 'name': 'Mijares',\n", + " 'popularity': 67,\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:3zhijRRIZX2B6G2T7vJl9p'},\n", + " {'external_urls': {'spotify': 'https://open.spotify.com/artist/3YHFRVdfHlJ98iAc50PIYk'},\n", + " 'followers': {'href': None, 'total': 307477},\n", + " 'genres': ['latin alternative',\n", + " 'latin pop',\n", + " 'mexican rock',\n", + " 'rock en espanol'],\n", + " 'href': 'https://api.spotify.com/v1/artists/3YHFRVdfHlJ98iAc50PIYk',\n", + " 'id': '3YHFRVdfHlJ98iAc50PIYk',\n", + " 'images': [{'height': 640,\n", + " 'url': 'https://i.scdn.co/image/ab6761610000e5eba930ac00ac3eabc9de737522',\n", + " 'width': 640},\n", + " {'height': 320,\n", + " 'url': 'https://i.scdn.co/image/ab67616100005174a930ac00ac3eabc9de737522',\n", + " 'width': 320},\n", + " {'height': 160,\n", + " 'url': 'https://i.scdn.co/image/ab6761610000f178a930ac00ac3eabc9de737522',\n", + " 'width': 160}],\n", + " 'name': 'Benny',\n", + " 'popularity': 57,\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:3YHFRVdfHlJ98iAc50PIYk'},\n", + " {'external_urls': {'spotify': 'https://open.spotify.com/artist/5enSNzCwMx61gCMv9jaV4Q'},\n", + " 'followers': {'href': None, 'total': 548156},\n", + " 'genres': ['colombian pop', 'latin pop', 'mexican pop'],\n", + " 'href': 'https://api.spotify.com/v1/artists/5enSNzCwMx61gCMv9jaV4Q',\n", + " 'id': '5enSNzCwMx61gCMv9jaV4Q',\n", + " 'images': [{'height': 377,\n", + " 'url': 'https://i.scdn.co/image/17eb12c7d1754be4ae28be151e6c855719967934',\n", + " 'width': 250},\n", + " {'height': 302,\n", + " 'url': 'https://i.scdn.co/image/41073f7445c343e5c0b4216a46fd1e02a669579c',\n", + " 'width': 200},\n", + " {'height': 97,\n", + " 'url': 'https://i.scdn.co/image/db3e1f80c0efad4855869fab64b323f0a39e1e0e',\n", + " 'width': 64}],\n", + " 'name': 'Soraya',\n", + " 'popularity': 32,\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:5enSNzCwMx61gCMv9jaV4Q'},\n", + " {'external_urls': {'spotify': 'https://open.spotify.com/artist/4OgNARLQSC4yy7Dsa5cqxx'},\n", + " 'followers': {'href': None, 'total': 2368308},\n", + " 'genres': ['latin pop', 'mexican pop'],\n", + " 'href': 'https://api.spotify.com/v1/artists/4OgNARLQSC4yy7Dsa5cqxx',\n", + " 'id': '4OgNARLQSC4yy7Dsa5cqxx',\n", + " 'images': [{'height': 640,\n", + " 'url': 'https://i.scdn.co/image/ab6761610000e5eb08d697859c0b6ad074734d04',\n", + " 'width': 640},\n", + " {'height': 320,\n", + " 'url': 'https://i.scdn.co/image/ab6761610000517408d697859c0b6ad074734d04',\n", + " 'width': 320},\n", + " {'height': 160,\n", + " 'url': 'https://i.scdn.co/image/ab6761610000f17808d697859c0b6ad074734d04',\n", + " 'width': 160}],\n", + " 'name': 'Yuri',\n", + " 'popularity': 66,\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:4OgNARLQSC4yy7Dsa5cqxx'},\n", + " {'external_urls': {'spotify': 'https://open.spotify.com/artist/1FbygZnWsyUjzjTGLhWVlO'},\n", + " 'followers': {'href': None, 'total': 1648853},\n", + " 'genres': ['latin pop', 'mexican pop'],\n", + " 'href': 'https://api.spotify.com/v1/artists/1FbygZnWsyUjzjTGLhWVlO',\n", + " 'id': '1FbygZnWsyUjzjTGLhWVlO',\n", + " 'images': [{'height': 640,\n", + " 'url': 'https://i.scdn.co/image/ab6761610000e5eb9923e41a8c2a8e39dd01dc71',\n", + " 'width': 640},\n", + " {'height': 320,\n", + " 'url': 'https://i.scdn.co/image/ab676161000051749923e41a8c2a8e39dd01dc71',\n", + " 'width': 320},\n", + " {'height': 160,\n", + " 'url': 'https://i.scdn.co/image/ab6761610000f1789923e41a8c2a8e39dd01dc71',\n", + " 'width': 160}],\n", + " 'name': 'Timbiriche',\n", + " 'popularity': 62,\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:1FbygZnWsyUjzjTGLhWVlO'},\n", + " {'external_urls': {'spotify': 'https://open.spotify.com/artist/1ZVoRDO29AlDXiMkRLMZSK'},\n", + " 'followers': {'href': None, 'total': 1513913},\n", + " 'genres': ['chilean rock',\n", + " 'latin alternative',\n", + " 'latin pop',\n", + " 'latin rock',\n", + " 'rock en espanol'],\n", + " 'href': 'https://api.spotify.com/v1/artists/1ZVoRDO29AlDXiMkRLMZSK',\n", + " 'id': '1ZVoRDO29AlDXiMkRLMZSK',\n", + " 'images': [{'height': 1000,\n", + " 'url': 'https://i.scdn.co/image/809530f901c9697984f669b6f4a6fea1dc9762f6',\n", + " 'width': 1000},\n", + " {'height': 640,\n", + " 'url': 'https://i.scdn.co/image/97eac48f205e1fc7a582c53dc146463666e6b6db',\n", + " 'width': 640},\n", + " {'height': 200,\n", + " 'url': 'https://i.scdn.co/image/c95a4d58727d5f50c889252d659c695f5e6f2c1a',\n", + " 'width': 200},\n", + " {'height': 64,\n", + " 'url': 'https://i.scdn.co/image/06e94f65da338e9cb5e40764034e428e4c2887f2',\n", + " 'width': 64}],\n", + " 'name': 'La Ley',\n", + " 'popularity': 63,\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:1ZVoRDO29AlDXiMkRLMZSK'},\n", + " {'external_urls': {'spotify': 'https://open.spotify.com/artist/5v287QKYZ7Dyuw4CNzv89p'},\n", + " 'followers': {'href': None, 'total': 1115626},\n", + " 'genres': ['latin arena pop', 'latin pop', 'mexican pop'],\n", + " 'href': 'https://api.spotify.com/v1/artists/5v287QKYZ7Dyuw4CNzv89p',\n", + " 'id': '5v287QKYZ7Dyuw4CNzv89p',\n", + " 'images': [{'height': 640,\n", + " 'url': 'https://i.scdn.co/image/ab67616d0000b273e415825edc259f350d02a044',\n", + " 'width': 640},\n", + " {'height': 300,\n", + " 'url': 'https://i.scdn.co/image/ab67616d00001e02e415825edc259f350d02a044',\n", + " 'width': 300},\n", + " {'height': 64,\n", + " 'url': 'https://i.scdn.co/image/ab67616d00004851e415825edc259f350d02a044',\n", + " 'width': 64}],\n", + " 'name': 'Magneto',\n", + " 'popularity': 57,\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:5v287QKYZ7Dyuw4CNzv89p'},\n", + " {'external_urls': {'spotify': 'https://open.spotify.com/artist/61hAcjvvUS6EXMpeeHwaDi'},\n", + " 'followers': {'href': None, 'total': 983192},\n", + " 'genres': ['latin pop', 'mexican pop'],\n", + " 'href': 'https://api.spotify.com/v1/artists/61hAcjvvUS6EXMpeeHwaDi',\n", + " 'id': '61hAcjvvUS6EXMpeeHwaDi',\n", + " 'images': [{'height': 640,\n", + " 'url': 'https://i.scdn.co/image/ab6761610000e5ebc2cbaa9fc1565bb2188b7a3f',\n", + " 'width': 640},\n", + " {'height': 320,\n", + " 'url': 'https://i.scdn.co/image/ab67616100005174c2cbaa9fc1565bb2188b7a3f',\n", + " 'width': 320},\n", + " {'height': 160,\n", + " 'url': 'https://i.scdn.co/image/ab6761610000f178c2cbaa9fc1565bb2188b7a3f',\n", + " 'width': 160}],\n", + " 'name': 'Kabah',\n", + " 'popularity': 57,\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:61hAcjvvUS6EXMpeeHwaDi'},\n", + " {'external_urls': {'spotify': 'https://open.spotify.com/artist/2Qm12OdHFDHSpWhBMpO16L'},\n", + " 'followers': {'href': None, 'total': 473883},\n", + " 'genres': ['latin pop', 'mexican pop'],\n", + " 'href': 'https://api.spotify.com/v1/artists/2Qm12OdHFDHSpWhBMpO16L',\n", + " 'id': '2Qm12OdHFDHSpWhBMpO16L',\n", + " 'images': [{'height': 640,\n", + " 'url': 'https://i.scdn.co/image/ab6761610000e5ebb60db9dab1687c34b4b40ee8',\n", + " 'width': 640},\n", + " {'height': 320,\n", + " 'url': 'https://i.scdn.co/image/ab67616100005174b60db9dab1687c34b4b40ee8',\n", + " 'width': 320},\n", + " {'height': 160,\n", + " 'url': 'https://i.scdn.co/image/ab6761610000f178b60db9dab1687c34b4b40ee8',\n", + " 'width': 160}],\n", + " 'name': 'Calo',\n", + " 'popularity': 52,\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:2Qm12OdHFDHSpWhBMpO16L'},\n", + " {'external_urls': {'spotify': 'https://open.spotify.com/artist/7FZj349hdLfD6qzXkJLuAh'},\n", + " 'followers': {'href': None, 'total': 2874079},\n", + " 'genres': ['latin arena pop', 'latin pop', 'spanish pop rock'],\n", + " 'href': 'https://api.spotify.com/v1/artists/7FZj349hdLfD6qzXkJLuAh',\n", + " 'id': '7FZj349hdLfD6qzXkJLuAh',\n", + " 'images': [{'height': 640,\n", + " 'url': 'https://i.scdn.co/image/ab6761610000e5eb7d744f844ffd5d7bddf0abd8',\n", + " 'width': 640},\n", + " {'height': 320,\n", + " 'url': 'https://i.scdn.co/image/ab676161000051747d744f844ffd5d7bddf0abd8',\n", + " 'width': 320},\n", + " {'height': 160,\n", + " 'url': 'https://i.scdn.co/image/ab6761610000f1787d744f844ffd5d7bddf0abd8',\n", + " 'width': 160}],\n", + " 'name': 'La Quinta Estacion',\n", + " 'popularity': 65,\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:7FZj349hdLfD6qzXkJLuAh'},\n", + " {'external_urls': {'spotify': 'https://open.spotify.com/artist/3QmmtMrEf7aQrsd1VtejAV'},\n", + " 'followers': {'href': None, 'total': 858998},\n", + " 'genres': ['latin alternative',\n", + " 'latin arena pop',\n", + " 'latin pop',\n", + " 'mexican pop',\n", + " 'mexican rock',\n", + " 'rock en espanol'],\n", + " 'href': 'https://api.spotify.com/v1/artists/3QmmtMrEf7aQrsd1VtejAV',\n", + " 'id': '3QmmtMrEf7aQrsd1VtejAV',\n", + " 'images': [{'height': 640,\n", + " 'url': 'https://i.scdn.co/image/ab6761610000e5ebd566822e04b8fd235fe4bbfb',\n", + " 'width': 640},\n", + " {'height': 320,\n", + " 'url': 'https://i.scdn.co/image/ab67616100005174d566822e04b8fd235fe4bbfb',\n", + " 'width': 320},\n", + " {'height': 160,\n", + " 'url': 'https://i.scdn.co/image/ab6761610000f178d566822e04b8fd235fe4bbfb',\n", + " 'width': 160}],\n", + " 'name': 'Mœnia',\n", + " 'popularity': 62,\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:3QmmtMrEf7aQrsd1VtejAV'}]}" + ] + }, + "execution_count": 18, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "response_1 = response_1.json()\n", + "response_1" + ] + }, + { + "cell_type": "code", + "execution_count": 20, + "id": "9fb7274a", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "dict_keys(['artists'])" + ] + }, + "execution_count": 20, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "key_list2 = response_1.keys()\n", + "key_list2" + ] + }, + { + "cell_type": "code", + "execution_count": 21, + "id": "e479ba45", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[{'external_urls': {'spotify': 'https://open.spotify.com/artist/5YekZn3GGnPIURNA6RG124'},\n", + " 'followers': {'href': None, 'total': 711076},\n", + " 'genres': ['latin arena pop', 'latin pop', 'mexican pop'],\n", + " 'href': 'https://api.spotify.com/v1/artists/5YekZn3GGnPIURNA6RG124',\n", + " 'id': '5YekZn3GGnPIURNA6RG124',\n", + " 'images': [{'height': 640,\n", + " 'url': 'https://i.scdn.co/image/ab6761610000e5eb8b292ea605f0b366b81b66d5',\n", + " 'width': 640},\n", + " {'height': 320,\n", + " 'url': 'https://i.scdn.co/image/ab676161000051748b292ea605f0b366b81b66d5',\n", + " 'width': 320},\n", + " {'height': 160,\n", + " 'url': 'https://i.scdn.co/image/ab6761610000f1788b292ea605f0b366b81b66d5',\n", + " 'width': 160}],\n", + " 'name': 'Ana Torroja',\n", + " 'popularity': 57,\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:5YekZn3GGnPIURNA6RG124'},\n", + " {'external_urls': {'spotify': 'https://open.spotify.com/artist/5BMgsAFg8rZQc3tqs5BB8G'},\n", + " 'followers': {'href': None, 'total': 1714889},\n", + " 'genres': ['cantautor',\n", + " 'latin alternative',\n", + " 'latin pop',\n", + " 'rock en espanol',\n", + " 'spanish pop',\n", + " 'spanish pop rock'],\n", + " 'href': 'https://api.spotify.com/v1/artists/5BMgsAFg8rZQc3tqs5BB8G',\n", + " 'id': '5BMgsAFg8rZQc3tqs5BB8G',\n", + " 'images': [{'height': 605,\n", + " 'url': 'https://i.scdn.co/image/d6b66ff338e079e9db9ad7841fc34e56ba1c4eb3',\n", + " 'width': 600},\n", + " {'height': 202,\n", + " 'url': 'https://i.scdn.co/image/e3fa2e604da0e7bd31c9d0ad10e50e6fda255924',\n", + " 'width': 200},\n", + " {'height': 65,\n", + " 'url': 'https://i.scdn.co/image/901ff649cfb04d22f4f14a1ea1f5ed40b3e4cc22',\n", + " 'width': 64}],\n", + " 'name': 'Mecano',\n", + " 'popularity': 64,\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:5BMgsAFg8rZQc3tqs5BB8G'},\n", + " {'external_urls': {'spotify': 'https://open.spotify.com/artist/7DC1oixQ38ba8Lyk47RlS5'},\n", + " 'followers': {'href': None, 'total': 357375},\n", + " 'genres': ['cantautor', 'spanish pop'],\n", + " 'href': 'https://api.spotify.com/v1/artists/7DC1oixQ38ba8Lyk47RlS5',\n", + " 'id': '7DC1oixQ38ba8Lyk47RlS5',\n", + " 'images': [{'height': 693,\n", + " 'url': 'https://i.scdn.co/image/77dda715f5df8fe2bb2c6ef2e7b620338419f5c4',\n", + " 'width': 1000},\n", + " {'height': 444,\n", + " 'url': 'https://i.scdn.co/image/3457ddfaa27ed7ec5d39c71281ef17f88eccb860',\n", + " 'width': 640},\n", + " {'height': 139,\n", + " 'url': 'https://i.scdn.co/image/12c8ecf87761801ca8046bb31285f7e046217086',\n", + " 'width': 200},\n", + " {'height': 44,\n", + " 'url': 'https://i.scdn.co/image/882b7730bcdcb8e9fe95668fc32cf65c811ee663',\n", + " 'width': 63}],\n", + " 'name': 'Presuntos Implicados',\n", + " 'popularity': 44,\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:7DC1oixQ38ba8Lyk47RlS5'},\n", + " {'external_urls': {'spotify': 'https://open.spotify.com/artist/15FscPIs0VO23BCCMaPglf'},\n", + " 'followers': {'href': None, 'total': 337125},\n", + " 'genres': ['latin pop', 'spanish new wave', 'spanish pop'],\n", + " 'href': 'https://api.spotify.com/v1/artists/15FscPIs0VO23BCCMaPglf',\n", + " 'id': '15FscPIs0VO23BCCMaPglf',\n", + " 'images': [{'height': 640,\n", + " 'url': 'https://i.scdn.co/image/ab6761610000e5ebadf8dd0c9b605aec3ff024ac',\n", + " 'width': 640},\n", + " {'height': 320,\n", + " 'url': 'https://i.scdn.co/image/ab67616100005174adf8dd0c9b605aec3ff024ac',\n", + " 'width': 320},\n", + " {'height': 160,\n", + " 'url': 'https://i.scdn.co/image/ab6761610000f178adf8dd0c9b605aec3ff024ac',\n", + " 'width': 160}],\n", + " 'name': 'Amistades Peligrosas',\n", + " 'popularity': 49,\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:15FscPIs0VO23BCCMaPglf'},\n", + " {'external_urls': {'spotify': 'https://open.spotify.com/artist/368rTiMKMrz3b03az6B14w'},\n", + " 'followers': {'href': None, 'total': 419750},\n", + " 'genres': ['latin pop', 'spanish pop'],\n", + " 'href': 'https://api.spotify.com/v1/artists/368rTiMKMrz3b03az6B14w',\n", + " 'id': '368rTiMKMrz3b03az6B14w',\n", + " 'images': [{'height': 640,\n", + " 'url': 'https://i.scdn.co/image/ab6761610000e5eb4fc9bd4ffbe271ef8661b51e',\n", + " 'width': 640},\n", + " {'height': 320,\n", + " 'url': 'https://i.scdn.co/image/ab676161000051744fc9bd4ffbe271ef8661b51e',\n", + " 'width': 320},\n", + " {'height': 160,\n", + " 'url': 'https://i.scdn.co/image/ab6761610000f1784fc9bd4ffbe271ef8661b51e',\n", + " 'width': 160}],\n", + " 'name': 'Marta Sánchez',\n", + " 'popularity': 61,\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:368rTiMKMrz3b03az6B14w'},\n", + " {'external_urls': {'spotify': 'https://open.spotify.com/artist/0r8toju2ecKaVtItkzAnNi'},\n", + " 'followers': {'href': None, 'total': 1501891},\n", + " 'genres': ['latin arena pop', 'latin pop', 'mexican pop'],\n", + " 'href': 'https://api.spotify.com/v1/artists/0r8toju2ecKaVtItkzAnNi',\n", + " 'id': '0r8toju2ecKaVtItkzAnNi',\n", + " 'images': [{'height': 640,\n", + " 'url': 'https://i.scdn.co/image/ab6761610000e5eb42f305eae2574365774fbb6a',\n", + " 'width': 640},\n", + " {'height': 320,\n", + " 'url': 'https://i.scdn.co/image/ab6761610000517442f305eae2574365774fbb6a',\n", + " 'width': 320},\n", + " {'height': 160,\n", + " 'url': 'https://i.scdn.co/image/ab6761610000f17842f305eae2574365774fbb6a',\n", + " 'width': 160}],\n", + " 'name': 'Aleks Syntek',\n", + " 'popularity': 63,\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:0r8toju2ecKaVtItkzAnNi'},\n", + " {'external_urls': {'spotify': 'https://open.spotify.com/artist/4zbqGb99bANxJBsvwRr2zT'},\n", + " 'followers': {'href': None, 'total': 791005},\n", + " 'genres': ['latin pop', 'ranchera'],\n", + " 'href': 'https://api.spotify.com/v1/artists/4zbqGb99bANxJBsvwRr2zT',\n", + " 'id': '4zbqGb99bANxJBsvwRr2zT',\n", + " 'images': [{'height': 640,\n", + " 'url': 'https://i.scdn.co/image/ab6761610000e5eb3843a6259038f25fe8ffab1f',\n", + " 'width': 640},\n", + " {'height': 320,\n", + " 'url': 'https://i.scdn.co/image/ab676161000051743843a6259038f25fe8ffab1f',\n", + " 'width': 320},\n", + " {'height': 160,\n", + " 'url': 'https://i.scdn.co/image/ab6761610000f1783843a6259038f25fe8ffab1f',\n", + " 'width': 160}],\n", + " 'name': 'Flans',\n", + " 'popularity': 57,\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:4zbqGb99bANxJBsvwRr2zT'},\n", + " {'external_urls': {'spotify': 'https://open.spotify.com/artist/2DmYtFBKcxb3ajwWWgA576'},\n", + " 'followers': {'href': None, 'total': 2756131},\n", + " 'genres': ['latin pop', 'mexican pop', 'ranchera'],\n", + " 'href': 'https://api.spotify.com/v1/artists/2DmYtFBKcxb3ajwWWgA576',\n", + " 'id': '2DmYtFBKcxb3ajwWWgA576',\n", + " 'images': [{'height': 640,\n", + " 'url': 'https://i.scdn.co/image/ab6761610000e5eba3917d80a09bffd0a05a3e89',\n", + " 'width': 640},\n", + " {'height': 320,\n", + " 'url': 'https://i.scdn.co/image/ab67616100005174a3917d80a09bffd0a05a3e89',\n", + " 'width': 320},\n", + " {'height': 160,\n", + " 'url': 'https://i.scdn.co/image/ab6761610000f178a3917d80a09bffd0a05a3e89',\n", + " 'width': 160}],\n", + " 'name': 'Emmanuel',\n", + " 'popularity': 67,\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:2DmYtFBKcxb3ajwWWgA576'},\n", + " {'external_urls': {'spotify': 'https://open.spotify.com/artist/0zGM73sadbAOBLev02P8LO'},\n", + " 'followers': {'href': None, 'total': 765717},\n", + " 'genres': ['latin arena pop',\n", + " 'latin pop',\n", + " 'mexican pop',\n", + " 'spanish pop',\n", + " 'spanish pop rock'],\n", + " 'href': 'https://api.spotify.com/v1/artists/0zGM73sadbAOBLev02P8LO',\n", + " 'id': '0zGM73sadbAOBLev02P8LO',\n", + " 'images': [{'height': 640,\n", + " 'url': 'https://i.scdn.co/image/ab6761610000e5eb1c87d7ed67eee9ba00985447',\n", + " 'width': 640},\n", + " {'height': 320,\n", + " 'url': 'https://i.scdn.co/image/ab676161000051741c87d7ed67eee9ba00985447',\n", + " 'width': 320},\n", + " {'height': 160,\n", + " 'url': 'https://i.scdn.co/image/ab6761610000f1781c87d7ed67eee9ba00985447',\n", + " 'width': 160}],\n", + " 'name': 'Monica Naranjo',\n", + " 'popularity': 56,\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:0zGM73sadbAOBLev02P8LO'},\n", + " {'external_urls': {'spotify': 'https://open.spotify.com/artist/3zhijRRIZX2B6G2T7vJl9p'},\n", + " 'followers': {'href': None, 'total': 2098260},\n", + " 'genres': ['latin pop', 'mexican pop'],\n", + " 'href': 'https://api.spotify.com/v1/artists/3zhijRRIZX2B6G2T7vJl9p',\n", + " 'id': '3zhijRRIZX2B6G2T7vJl9p',\n", + " 'images': [{'height': 640,\n", + " 'url': 'https://i.scdn.co/image/ab6761610000e5eb3e16dd210daca896df659aff',\n", + " 'width': 640},\n", + " {'height': 320,\n", + " 'url': 'https://i.scdn.co/image/ab676161000051743e16dd210daca896df659aff',\n", + " 'width': 320},\n", + " {'height': 160,\n", + " 'url': 'https://i.scdn.co/image/ab6761610000f1783e16dd210daca896df659aff',\n", + " 'width': 160}],\n", + " 'name': 'Mijares',\n", + " 'popularity': 67,\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:3zhijRRIZX2B6G2T7vJl9p'},\n", + " {'external_urls': {'spotify': 'https://open.spotify.com/artist/3YHFRVdfHlJ98iAc50PIYk'},\n", + " 'followers': {'href': None, 'total': 307477},\n", + " 'genres': ['latin alternative',\n", + " 'latin pop',\n", + " 'mexican rock',\n", + " 'rock en espanol'],\n", + " 'href': 'https://api.spotify.com/v1/artists/3YHFRVdfHlJ98iAc50PIYk',\n", + " 'id': '3YHFRVdfHlJ98iAc50PIYk',\n", + " 'images': [{'height': 640,\n", + " 'url': 'https://i.scdn.co/image/ab6761610000e5eba930ac00ac3eabc9de737522',\n", + " 'width': 640},\n", + " {'height': 320,\n", + " 'url': 'https://i.scdn.co/image/ab67616100005174a930ac00ac3eabc9de737522',\n", + " 'width': 320},\n", + " {'height': 160,\n", + " 'url': 'https://i.scdn.co/image/ab6761610000f178a930ac00ac3eabc9de737522',\n", + " 'width': 160}],\n", + " 'name': 'Benny',\n", + " 'popularity': 57,\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:3YHFRVdfHlJ98iAc50PIYk'},\n", + " {'external_urls': {'spotify': 'https://open.spotify.com/artist/5enSNzCwMx61gCMv9jaV4Q'},\n", + " 'followers': {'href': None, 'total': 548156},\n", + " 'genres': ['colombian pop', 'latin pop', 'mexican pop'],\n", + " 'href': 'https://api.spotify.com/v1/artists/5enSNzCwMx61gCMv9jaV4Q',\n", + " 'id': '5enSNzCwMx61gCMv9jaV4Q',\n", + " 'images': [{'height': 377,\n", + " 'url': 'https://i.scdn.co/image/17eb12c7d1754be4ae28be151e6c855719967934',\n", + " 'width': 250},\n", + " {'height': 302,\n", + " 'url': 'https://i.scdn.co/image/41073f7445c343e5c0b4216a46fd1e02a669579c',\n", + " 'width': 200},\n", + " {'height': 97,\n", + " 'url': 'https://i.scdn.co/image/db3e1f80c0efad4855869fab64b323f0a39e1e0e',\n", + " 'width': 64}],\n", + " 'name': 'Soraya',\n", + " 'popularity': 32,\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:5enSNzCwMx61gCMv9jaV4Q'},\n", + " {'external_urls': {'spotify': 'https://open.spotify.com/artist/4OgNARLQSC4yy7Dsa5cqxx'},\n", + " 'followers': {'href': None, 'total': 2368308},\n", + " 'genres': ['latin pop', 'mexican pop'],\n", + " 'href': 'https://api.spotify.com/v1/artists/4OgNARLQSC4yy7Dsa5cqxx',\n", + " 'id': '4OgNARLQSC4yy7Dsa5cqxx',\n", + " 'images': [{'height': 640,\n", + " 'url': 'https://i.scdn.co/image/ab6761610000e5eb08d697859c0b6ad074734d04',\n", + " 'width': 640},\n", + " {'height': 320,\n", + " 'url': 'https://i.scdn.co/image/ab6761610000517408d697859c0b6ad074734d04',\n", + " 'width': 320},\n", + " {'height': 160,\n", + " 'url': 'https://i.scdn.co/image/ab6761610000f17808d697859c0b6ad074734d04',\n", + " 'width': 160}],\n", + " 'name': 'Yuri',\n", + " 'popularity': 66,\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:4OgNARLQSC4yy7Dsa5cqxx'},\n", + " {'external_urls': {'spotify': 'https://open.spotify.com/artist/1FbygZnWsyUjzjTGLhWVlO'},\n", + " 'followers': {'href': None, 'total': 1648853},\n", + " 'genres': ['latin pop', 'mexican pop'],\n", + " 'href': 'https://api.spotify.com/v1/artists/1FbygZnWsyUjzjTGLhWVlO',\n", + " 'id': '1FbygZnWsyUjzjTGLhWVlO',\n", + " 'images': [{'height': 640,\n", + " 'url': 'https://i.scdn.co/image/ab6761610000e5eb9923e41a8c2a8e39dd01dc71',\n", + " 'width': 640},\n", + " {'height': 320,\n", + " 'url': 'https://i.scdn.co/image/ab676161000051749923e41a8c2a8e39dd01dc71',\n", + " 'width': 320},\n", + " {'height': 160,\n", + " 'url': 'https://i.scdn.co/image/ab6761610000f1789923e41a8c2a8e39dd01dc71',\n", + " 'width': 160}],\n", + " 'name': 'Timbiriche',\n", + " 'popularity': 62,\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:1FbygZnWsyUjzjTGLhWVlO'},\n", + " {'external_urls': {'spotify': 'https://open.spotify.com/artist/1ZVoRDO29AlDXiMkRLMZSK'},\n", + " 'followers': {'href': None, 'total': 1513913},\n", + " 'genres': ['chilean rock',\n", + " 'latin alternative',\n", + " 'latin pop',\n", + " 'latin rock',\n", + " 'rock en espanol'],\n", + " 'href': 'https://api.spotify.com/v1/artists/1ZVoRDO29AlDXiMkRLMZSK',\n", + " 'id': '1ZVoRDO29AlDXiMkRLMZSK',\n", + " 'images': [{'height': 1000,\n", + " 'url': 'https://i.scdn.co/image/809530f901c9697984f669b6f4a6fea1dc9762f6',\n", + " 'width': 1000},\n", + " {'height': 640,\n", + " 'url': 'https://i.scdn.co/image/97eac48f205e1fc7a582c53dc146463666e6b6db',\n", + " 'width': 640},\n", + " {'height': 200,\n", + " 'url': 'https://i.scdn.co/image/c95a4d58727d5f50c889252d659c695f5e6f2c1a',\n", + " 'width': 200},\n", + " {'height': 64,\n", + " 'url': 'https://i.scdn.co/image/06e94f65da338e9cb5e40764034e428e4c2887f2',\n", + " 'width': 64}],\n", + " 'name': 'La Ley',\n", + " 'popularity': 63,\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:1ZVoRDO29AlDXiMkRLMZSK'},\n", + " {'external_urls': {'spotify': 'https://open.spotify.com/artist/5v287QKYZ7Dyuw4CNzv89p'},\n", + " 'followers': {'href': None, 'total': 1115626},\n", + " 'genres': ['latin arena pop', 'latin pop', 'mexican pop'],\n", + " 'href': 'https://api.spotify.com/v1/artists/5v287QKYZ7Dyuw4CNzv89p',\n", + " 'id': '5v287QKYZ7Dyuw4CNzv89p',\n", + " 'images': [{'height': 640,\n", + " 'url': 'https://i.scdn.co/image/ab67616d0000b273e415825edc259f350d02a044',\n", + " 'width': 640},\n", + " {'height': 300,\n", + " 'url': 'https://i.scdn.co/image/ab67616d00001e02e415825edc259f350d02a044',\n", + " 'width': 300},\n", + " {'height': 64,\n", + " 'url': 'https://i.scdn.co/image/ab67616d00004851e415825edc259f350d02a044',\n", + " 'width': 64}],\n", + " 'name': 'Magneto',\n", + " 'popularity': 57,\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:5v287QKYZ7Dyuw4CNzv89p'},\n", + " {'external_urls': {'spotify': 'https://open.spotify.com/artist/61hAcjvvUS6EXMpeeHwaDi'},\n", + " 'followers': {'href': None, 'total': 983192},\n", + " 'genres': ['latin pop', 'mexican pop'],\n", + " 'href': 'https://api.spotify.com/v1/artists/61hAcjvvUS6EXMpeeHwaDi',\n", + " 'id': '61hAcjvvUS6EXMpeeHwaDi',\n", + " 'images': [{'height': 640,\n", + " 'url': 'https://i.scdn.co/image/ab6761610000e5ebc2cbaa9fc1565bb2188b7a3f',\n", + " 'width': 640},\n", + " {'height': 320,\n", + " 'url': 'https://i.scdn.co/image/ab67616100005174c2cbaa9fc1565bb2188b7a3f',\n", + " 'width': 320},\n", + " {'height': 160,\n", + " 'url': 'https://i.scdn.co/image/ab6761610000f178c2cbaa9fc1565bb2188b7a3f',\n", + " 'width': 160}],\n", + " 'name': 'Kabah',\n", + " 'popularity': 57,\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:61hAcjvvUS6EXMpeeHwaDi'},\n", + " {'external_urls': {'spotify': 'https://open.spotify.com/artist/2Qm12OdHFDHSpWhBMpO16L'},\n", + " 'followers': {'href': None, 'total': 473883},\n", + " 'genres': ['latin pop', 'mexican pop'],\n", + " 'href': 'https://api.spotify.com/v1/artists/2Qm12OdHFDHSpWhBMpO16L',\n", + " 'id': '2Qm12OdHFDHSpWhBMpO16L',\n", + " 'images': [{'height': 640,\n", + " 'url': 'https://i.scdn.co/image/ab6761610000e5ebb60db9dab1687c34b4b40ee8',\n", + " 'width': 640},\n", + " {'height': 320,\n", + " 'url': 'https://i.scdn.co/image/ab67616100005174b60db9dab1687c34b4b40ee8',\n", + " 'width': 320},\n", + " {'height': 160,\n", + " 'url': 'https://i.scdn.co/image/ab6761610000f178b60db9dab1687c34b4b40ee8',\n", + " 'width': 160}],\n", + " 'name': 'Calo',\n", + " 'popularity': 52,\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:2Qm12OdHFDHSpWhBMpO16L'},\n", + " {'external_urls': {'spotify': 'https://open.spotify.com/artist/7FZj349hdLfD6qzXkJLuAh'},\n", + " 'followers': {'href': None, 'total': 2874079},\n", + " 'genres': ['latin arena pop', 'latin pop', 'spanish pop rock'],\n", + " 'href': 'https://api.spotify.com/v1/artists/7FZj349hdLfD6qzXkJLuAh',\n", + " 'id': '7FZj349hdLfD6qzXkJLuAh',\n", + " 'images': [{'height': 640,\n", + " 'url': 'https://i.scdn.co/image/ab6761610000e5eb7d744f844ffd5d7bddf0abd8',\n", + " 'width': 640},\n", + " {'height': 320,\n", + " 'url': 'https://i.scdn.co/image/ab676161000051747d744f844ffd5d7bddf0abd8',\n", + " 'width': 320},\n", + " {'height': 160,\n", + " 'url': 'https://i.scdn.co/image/ab6761610000f1787d744f844ffd5d7bddf0abd8',\n", + " 'width': 160}],\n", + " 'name': 'La Quinta Estacion',\n", + " 'popularity': 65,\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:7FZj349hdLfD6qzXkJLuAh'},\n", + " {'external_urls': {'spotify': 'https://open.spotify.com/artist/3QmmtMrEf7aQrsd1VtejAV'},\n", + " 'followers': {'href': None, 'total': 858998},\n", + " 'genres': ['latin alternative',\n", + " 'latin arena pop',\n", + " 'latin pop',\n", + " 'mexican pop',\n", + " 'mexican rock',\n", + " 'rock en espanol'],\n", + " 'href': 'https://api.spotify.com/v1/artists/3QmmtMrEf7aQrsd1VtejAV',\n", + " 'id': '3QmmtMrEf7aQrsd1VtejAV',\n", + " 'images': [{'height': 640,\n", + " 'url': 'https://i.scdn.co/image/ab6761610000e5ebd566822e04b8fd235fe4bbfb',\n", + " 'width': 640},\n", + " {'height': 320,\n", + " 'url': 'https://i.scdn.co/image/ab67616100005174d566822e04b8fd235fe4bbfb',\n", + " 'width': 320},\n", + " {'height': 160,\n", + " 'url': 'https://i.scdn.co/image/ab6761610000f178d566822e04b8fd235fe4bbfb',\n", + " 'width': 160}],\n", + " 'name': 'Mœnia',\n", + " 'popularity': 62,\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:3QmmtMrEf7aQrsd1VtejAV'}]" + ] + }, + "execution_count": 21, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "response_1['artists']" + ] + }, + { + "cell_type": "code", + "execution_count": 22, + "id": "08eda3d5", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'Ana Torroja'" + ] + }, + "execution_count": 22, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "response_1['artists'][0]['name']" + ] + }, + { + "cell_type": "code", + "execution_count": 23, + "id": "797c721c", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "['Ana Torroja',\n", + " 'Mecano',\n", + " 'Presuntos Implicados',\n", + " 'Amistades Peligrosas',\n", + " 'Marta Sánchez',\n", + " 'Aleks Syntek',\n", + " 'Flans',\n", + " 'Emmanuel',\n", + " 'Monica Naranjo',\n", + " 'Mijares',\n", + " 'Benny',\n", + " 'Soraya',\n", + " 'Yuri',\n", + " 'Timbiriche',\n", + " 'La Ley',\n", + " 'Magneto',\n", + " 'Kabah',\n", + " 'Calo',\n", + " 'La Quinta Estacion',\n", + " 'Mœnia']" + ] + }, + "execution_count": 23, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "artists_list = [response_1['artists'][artista]['name'] for artista in range(len(response_1['artists']))]\n", + "artists_list" + ] + }, + { + "cell_type": "code", + "execution_count": 24, + "id": "3885db47", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "https://api.spotify.com/v1/artists/7mWCSSOYqm4E9mB7V4ot6S/top-tracks?country=us\n" + ] + }, + { + "data": { + "text/plain": [ + "" + ] + }, + "execution_count": 24, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "full_endpoint_02 = full_endpoint + top_tracks + country\n", + "print(full_endpoint_02)\n", + "\n", + "response_02 = requests.get(full_endpoint_02, headers=header_info)\n", + "response_02" + ] + }, + { + "cell_type": "code", + "execution_count": 25, + "id": "70aaea23", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "https://api.spotify.com/v1/artists/{}/top-tracks?country=us\n" + ] + }, + { + "ename": "KeyError", + "evalue": "'tracks'", + "output_type": "error", + "traceback": [ + "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[1;31mKeyError\u001b[0m Traceback (most recent call last)", + "Cell \u001b[1;32mIn[25], line 6\u001b[0m\n\u001b[0;32m 4\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m artist \u001b[38;5;129;01min\u001b[39;00m artists_list:\n\u001b[0;32m 5\u001b[0m response \u001b[38;5;241m=\u001b[39m requests\u001b[38;5;241m.\u001b[39mget(full_endpoint_03\u001b[38;5;241m.\u001b[39mformat(artist), headers\u001b[38;5;241m=\u001b[39mheader_info)\n\u001b[1;32m----> 6\u001b[0m \u001b[38;5;28mprint\u001b[39m([response\u001b[38;5;241m.\u001b[39mjson()[\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mtracks\u001b[39m\u001b[38;5;124m'\u001b[39m][track][\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mname\u001b[39m\u001b[38;5;124m'\u001b[39m] \u001b[38;5;28;01mfor\u001b[39;00m track \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28mrange\u001b[39m(\u001b[38;5;28mlen\u001b[39m(\u001b[43mresponse\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mjson\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43mtracks\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m]\u001b[49m))])\n", + "\u001b[1;31mKeyError\u001b[0m: 'tracks'" + ] + } + ], "source": [ - "# Start building your playlist!!!\n", + "full_endpoint_03 = base_url + resource + '{}' + top_tracks + country\n", + "print(full_endpoint_03)\n", "\n", - "\n" + "for artist in artists_list:\n", + " response = requests.get(full_endpoint_03.format(artist), headers=header_info)\n", + " print([response.json()['tracks'][track]['name'] for track in range(len(response.json()['tracks']))])" + ] + }, + { + "cell_type": "code", + "execution_count": 304, + "id": "0e5aa7a7", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'https://api.spotify.com/v1/artists/7mWCSSOYqm4E9mB7V4ot6S'" + ] + }, + "execution_count": 304, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "artist_id = '7mWCSSOYqm4E9mB7V4ot6S'\n", + "related_artists = '/related-artists'\n", + "top_tracks = '/top-tracks'\n", + "country = '?country=us'\n", + "\n", + "full_endpoint = base_url + resource + artist_id\n", + "full_endpoint" + ] + }, + { + "cell_type": "code", + "execution_count": 305, + "id": "58a84fc6", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{'external_urls': {'spotify': 'https://open.spotify.com/artist/7mWCSSOYqm4E9mB7V4ot6S'},\n", + " 'followers': {'href': None, 'total': 2594918},\n", + " 'genres': ['latin pop', 'mexican pop'],\n", + " 'href': 'https://api.spotify.com/v1/artists/7mWCSSOYqm4E9mB7V4ot6S',\n", + " 'id': '7mWCSSOYqm4E9mB7V4ot6S',\n", + " 'images': [{'height': 640,\n", + " 'url': 'https://i.scdn.co/image/ab6761610000e5eb7d888623c984600e6af1fdc5',\n", + " 'width': 640},\n", + " {'height': 320,\n", + " 'url': 'https://i.scdn.co/image/ab676161000051747d888623c984600e6af1fdc5',\n", + " 'width': 320},\n", + " {'height': 160,\n", + " 'url': 'https://i.scdn.co/image/ab6761610000f1787d888623c984600e6af1fdc5',\n", + " 'width': 160}],\n", + " 'name': 'Miguel Bosé',\n", + " 'popularity': 66,\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:7mWCSSOYqm4E9mB7V4ot6S'}" + ] + }, + "execution_count": 305, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "#API\n", + "response = requests.get(url, headers=header_info).json()\n", + "response" + ] + }, + { + "cell_type": "code", + "execution_count": 249, + "id": "26706832", + "metadata": {}, + "outputs": [ + { + "ename": "SyntaxError", + "evalue": "invalid syntax (2597450222.py, line 6)", + "output_type": "error", + "traceback": [ + "\u001b[1;36m Cell \u001b[1;32mIn[249], line 6\u001b[1;36m\u001b[0m\n\u001b[1;33m response =\u001b[0m\n\u001b[1;37m ^\u001b[0m\n\u001b[1;31mSyntaxError\u001b[0m\u001b[1;31m:\u001b[0m invalid syntax\n" + ] + } + ], + "source": [ + "def get_top_tracks(id_artist):\n", + " resorces = '/artist'\n", + " parameters = f'/{id_artist}/top-tracks?market=ES'\n", + " \n", + " url = base_url + response + parameters\n", + " response = request.get(url, headers=header_info).json)\n", + " " ] }, { @@ -180,16 +1442,592 @@ "![I quit](https://media.giphy.com/media/gui67fZ3xIneM/giphy.gif)" ] }, + { + "cell_type": "code", + "execution_count": 135, + "id": "48bd571a", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": 257, + "id": "54797c28", + "metadata": {}, + "outputs": [ + { + "ename": "SyntaxError", + "evalue": "invalid syntax (2597450222.py, line 6)", + "output_type": "error", + "traceback": [ + "\u001b[1;36m Cell \u001b[1;32mIn[257], line 6\u001b[1;36m\u001b[0m\n\u001b[1;33m response =\u001b[0m\n\u001b[1;37m ^\u001b[0m\n\u001b[1;31mSyntaxError\u001b[0m\u001b[1;31m:\u001b[0m invalid syntax\n" + ] + } + ], + "source": [ + "def get_top_tracks(id_artist):\n", + " resorces = '/artist'\n", + " parameterr = f'/{id_artist}/top-tracks?market=ES'\n", + " \n", + " url = base_url + response + parameters\n", + " response = " + ] + }, { "cell_type": "code", "execution_count": null, + "id": "8b6df7be", + "metadata": {}, + "outputs": [], + "source": [ + "id_selected ='7mWCSSOYqm4E9mB7V4ot6S'" + ] + }, + { + "cell_type": "code", + "execution_count": 137, + "id": "b60b88fe", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'https://api.spotify.com/v1/artists/7mWCSSOYqm4E9mB7V4ot6S/related-artists'" + ] + }, + "execution_count": 137, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# Here you can complete your endpoint URI\n", + "artist_id = '7mWCSSOYqm4E9mB7V4ot6S'\n", + "method = '/related-artists'\n", + "full_endpoint = base_url + resource + artist_id + method\n", + "full_endpoint" + ] + }, + { + "cell_type": "code", + "execution_count": 147, "id": "2e5f0905", "metadata": {}, "outputs": [], "source": [ - "# Bonus\n", - "\n", - "\n" + "id_selected ='7mWCSSOYqm4E9mB7V4ot6S'" + ] + }, + { + "cell_type": "code", + "execution_count": 170, + "id": "fd2d7c32", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "https://api.spotify.com/v1/artists/7mWCSSOYqm4E9mB7V4ot6S\n" + ] + } + ], + "source": [ + "resources = 'artists'\n", + "parameters = f'/{id_selected}'\n", + "url = base_url + resources + parameters\n", + "print(url)" + ] + }, + { + "cell_type": "code", + "execution_count": 171, + "id": "625e84ad", + "metadata": {}, + "outputs": [], + "source": [ + "#API\n", + "response = requests.get(url, headers=header_info).json()" + ] + }, + { + "cell_type": "code", + "execution_count": 172, + "id": "2dd0018c", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{'external_urls': {'spotify': 'https://open.spotify.com/artist/7mWCSSOYqm4E9mB7V4ot6S'},\n", + " 'followers': {'href': None, 'total': 2593743},\n", + " 'genres': ['latin pop', 'mexican pop'],\n", + " 'href': 'https://api.spotify.com/v1/artists/7mWCSSOYqm4E9mB7V4ot6S',\n", + " 'id': '7mWCSSOYqm4E9mB7V4ot6S',\n", + " 'images': [{'height': 640,\n", + " 'url': 'https://i.scdn.co/image/ab6761610000e5eb7d888623c984600e6af1fdc5',\n", + " 'width': 640},\n", + " {'height': 320,\n", + " 'url': 'https://i.scdn.co/image/ab676161000051747d888623c984600e6af1fdc5',\n", + " 'width': 320},\n", + " {'height': 160,\n", + " 'url': 'https://i.scdn.co/image/ab6761610000f1787d888623c984600e6af1fdc5',\n", + " 'width': 160}],\n", + " 'name': 'Miguel Bosé',\n", + " 'popularity': 66,\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:7mWCSSOYqm4E9mB7V4ot6S'}" + ] + }, + "execution_count": 172, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "response" + ] + }, + { + "cell_type": "code", + "execution_count": 175, + "id": "6ad3a0a6", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": 176, + "id": "32cef6d2", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
idnamegenrespopularityfollowers
07mWCSSOYqm4E9mB7V4ot6SMiguel Bosé[latin pop, mexican pop]66{'href': None, 'total': 2593743}
\n", + "
" + ], + "text/plain": [ + " id name genres popularity \\\n", + "0 7mWCSSOYqm4E9mB7V4ot6S Miguel Bosé [latin pop, mexican pop] 66 \n", + "\n", + " followers \n", + "0 {'href': None, 'total': 2593743} " + ] + }, + "execution_count": 176, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "aed70d4a", + "metadata": {}, + "outputs": [], + "source": [ + "#rename columns\n", + "df_artist.rename(columns)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "0919e8f3", + "metadata": {}, + "outputs": [], + "source": [ + "#LETS GET THE RELATED ARTIST INFO" + ] + }, + { + "cell_type": "code", + "execution_count": 177, + "id": "222f1790", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "https://api.spotify.com/v1/artists/7mWCSSOYqm4E9mB7V4ot6S/related-artists\n" + ] + } + ], + "source": [ + "parameters = f'/{id_selected}/related-artists'\n", + "url = base_url + resources + parameters\n", + "print(url)" + ] + }, + { + "cell_type": "code", + "execution_count": 178, + "id": "b4e7b21a", + "metadata": {}, + "outputs": [], + "source": [ + "#API call\n", + "response = requests.get(url, headers=header_info).json()" + ] + }, + { + "cell_type": "code", + "execution_count": 182, + "id": "1df433d0", + "metadata": {}, + "outputs": [], + "source": [ + "#build a related artists df\n", + "df_related_artists = pd.DataFrame(response['artists']) [['id', 'name', 'genres', 'popularity', 'followers']]" + ] + }, + { + "cell_type": "code", + "execution_count": 183, + "id": "7774ccef", + "metadata": {}, + "outputs": [], + "source": [ + "df_related_artists = df_related_artists.rename(columns={'id': 'related_id', 'name': 'related_name', 'genres': 'related_genres', 'popularity': 'related_popularity', 'followers': 'related_followers'})" + ] + }, + { + "cell_type": "code", + "execution_count": 184, + "id": "2cf5a82b", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
related_idrelated_namerelated_genresrelated_popularityrelated_followers
05YekZn3GGnPIURNA6RG124Ana Torroja[latin arena pop, latin pop, mexican pop]56{'href': None, 'total': 702902}
15BMgsAFg8rZQc3tqs5BB8GMecano[cantautor, latin alternative, latin pop, rock...62{'href': None, 'total': 1686981}
27DC1oixQ38ba8Lyk47RlS5Presuntos Implicados[cantautor, spanish pop]43{'href': None, 'total': 353629}
315FscPIs0VO23BCCMaPglfAmistades Peligrosas[latin pop, spanish new wave, spanish pop]48{'href': None, 'total': 329862}
4368rTiMKMrz3b03az6B14wMarta Sánchez[latin pop, spanish pop]60{'href': None, 'total': 407815}
50r8toju2ecKaVtItkzAnNiAleks Syntek[latin arena pop, latin pop, mexican pop]61{'href': None, 'total': 1490218}
64zbqGb99bANxJBsvwRr2zTFlans[latin pop, ranchera]56{'href': None, 'total': 777254}
72DmYtFBKcxb3ajwWWgA576Emmanuel[latin pop, mexican pop, ranchera]65{'href': None, 'total': 2717320}
80zGM73sadbAOBLev02P8LOMonica Naranjo[latin arena pop, latin pop, mexican pop, span...55{'href': None, 'total': 755830}
93zhijRRIZX2B6G2T7vJl9pMijares[latin pop, mexican pop]63{'href': None, 'total': 2067018}
103YHFRVdfHlJ98iAc50PIYkBenny[latin alternative, latin pop, mexican rock, r...56{'href': None, 'total': 301578}
114OgNARLQSC4yy7Dsa5cqxxYuri[latin pop, mexican pop]61{'href': None, 'total': 2340576}
125enSNzCwMx61gCMv9jaV4QSoraya[colombian pop, latin pop, mexican pop]32{'href': None, 'total': 541764}
131FbygZnWsyUjzjTGLhWVlOTimbiriche[latin pop, mexican pop]61{'href': None, 'total': 1629955}
141ZVoRDO29AlDXiMkRLMZSKLa Ley[chilean rock, latin alternative, latin pop, l...62{'href': None, 'total': 1501452}
155v287QKYZ7Dyuw4CNzv89pMagneto[latin arena pop, latin pop, mexican pop]56{'href': None, 'total': 1106274}
167FZj349hdLfD6qzXkJLuAhLa Quinta Estacion[latin arena pop, latin pop, spanish pop rock]64{'href': None, 'total': 2829287}
173QmmtMrEf7aQrsd1VtejAVMœnia[latin alternative, latin arena pop, latin pop...61{'href': None, 'total': 851938}
1861hAcjvvUS6EXMpeeHwaDiKabah[latin pop, mexican pop]55{'href': None, 'total': 974160}
192Qm12OdHFDHSpWhBMpO16LCalo[latin pop, mexican pop]51{'href': None, 'total': 465338}
\n", + "
" + ], + "text/plain": [ + " related_id related_name \\\n", + "0 5YekZn3GGnPIURNA6RG124 Ana Torroja \n", + "1 5BMgsAFg8rZQc3tqs5BB8G Mecano \n", + "2 7DC1oixQ38ba8Lyk47RlS5 Presuntos Implicados \n", + "3 15FscPIs0VO23BCCMaPglf Amistades Peligrosas \n", + "4 368rTiMKMrz3b03az6B14w Marta Sánchez \n", + "5 0r8toju2ecKaVtItkzAnNi Aleks Syntek \n", + "6 4zbqGb99bANxJBsvwRr2zT Flans \n", + "7 2DmYtFBKcxb3ajwWWgA576 Emmanuel \n", + "8 0zGM73sadbAOBLev02P8LO Monica Naranjo \n", + "9 3zhijRRIZX2B6G2T7vJl9p Mijares \n", + "10 3YHFRVdfHlJ98iAc50PIYk Benny \n", + "11 4OgNARLQSC4yy7Dsa5cqxx Yuri \n", + "12 5enSNzCwMx61gCMv9jaV4Q Soraya \n", + "13 1FbygZnWsyUjzjTGLhWVlO Timbiriche \n", + "14 1ZVoRDO29AlDXiMkRLMZSK La Ley \n", + "15 5v287QKYZ7Dyuw4CNzv89p Magneto \n", + "16 7FZj349hdLfD6qzXkJLuAh La Quinta Estacion \n", + "17 3QmmtMrEf7aQrsd1VtejAV Mœnia \n", + "18 61hAcjvvUS6EXMpeeHwaDi Kabah \n", + "19 2Qm12OdHFDHSpWhBMpO16L Calo \n", + "\n", + " related_genres related_popularity \\\n", + "0 [latin arena pop, latin pop, mexican pop] 56 \n", + "1 [cantautor, latin alternative, latin pop, rock... 62 \n", + "2 [cantautor, spanish pop] 43 \n", + "3 [latin pop, spanish new wave, spanish pop] 48 \n", + "4 [latin pop, spanish pop] 60 \n", + "5 [latin arena pop, latin pop, mexican pop] 61 \n", + "6 [latin pop, ranchera] 56 \n", + "7 [latin pop, mexican pop, ranchera] 65 \n", + "8 [latin arena pop, latin pop, mexican pop, span... 55 \n", + "9 [latin pop, mexican pop] 63 \n", + "10 [latin alternative, latin pop, mexican rock, r... 56 \n", + "11 [latin pop, mexican pop] 61 \n", + "12 [colombian pop, latin pop, mexican pop] 32 \n", + "13 [latin pop, mexican pop] 61 \n", + "14 [chilean rock, latin alternative, latin pop, l... 62 \n", + "15 [latin arena pop, latin pop, mexican pop] 56 \n", + "16 [latin arena pop, latin pop, spanish pop rock] 64 \n", + "17 [latin alternative, latin arena pop, latin pop... 61 \n", + "18 [latin pop, mexican pop] 55 \n", + "19 [latin pop, mexican pop] 51 \n", + "\n", + " related_followers \n", + "0 {'href': None, 'total': 702902} \n", + "1 {'href': None, 'total': 1686981} \n", + "2 {'href': None, 'total': 353629} \n", + "3 {'href': None, 'total': 329862} \n", + "4 {'href': None, 'total': 407815} \n", + "5 {'href': None, 'total': 1490218} \n", + "6 {'href': None, 'total': 777254} \n", + "7 {'href': None, 'total': 2717320} \n", + "8 {'href': None, 'total': 755830} \n", + "9 {'href': None, 'total': 2067018} \n", + "10 {'href': None, 'total': 301578} \n", + "11 {'href': None, 'total': 2340576} \n", + "12 {'href': None, 'total': 541764} \n", + "13 {'href': None, 'total': 1629955} \n", + "14 {'href': None, 'total': 1501452} \n", + "15 {'href': None, 'total': 1106274} \n", + "16 {'href': None, 'total': 2829287} \n", + "17 {'href': None, 'total': 851938} \n", + "18 {'href': None, 'total': 974160} \n", + "19 {'href': None, 'total': 465338} " + ] + }, + "execution_count": 184, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "df_related_artists" + ] + }, + { + "cell_type": "code", + "execution_count": 185, + "id": "9df0bfca", + "metadata": {}, + "outputs": [], + "source": [ + "#add a column with select id artist\n", + "df_related_artists ['artists_id'] = id_selected" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "314f7630", + "metadata": {}, + "outputs": [], + "source": [ + "#join artits and related artist to merge info\n", + "...." ] }, { @@ -221,9 +2059,9 @@ ], "metadata": { "kernelspec": { - "display_name": "Python [conda env:.conda-ironhack]", + "display_name": "Python (pm1_env)", "language": "python", - "name": "conda-env-.conda-ironhack-py" + "name": "pm1_env" }, "language_info": { "codemirror_mode": { @@ -235,7 +2073,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.7.11" + "version": "3.10.13" } }, "nbformat": 4,