├── .gitignore ├── README.md ├── get-all-players-for-league.ipynb ├── get-all-season-stats.ipynb ├── get-assist-combo-summary.ipynb ├── get-assist-networks.ipynb ├── get-endgame-breakeven-2-pct.ipynb ├── get-four-factor-on-off.ipynb ├── get-game-logs.ipynb ├── get-game-stats.ipynb ├── get-games.ipynb ├── get-league-year-over-year-plots.ipynb ├── get-leverage.ipynb ├── get-lineup-opponent-summary.ipynb ├── get-lineup-player-stats.ipynb ├── get-lineup-subunit-stats.ipynb ├── get-number-of-starter-stats-by-team.ipynb ├── get-on-off.ipynb ├── get-pace-efficiency-by-season.ipynb ├── get-pace-efficiency-summary.ipynb ├── get-playing-time-distribution.ipynb ├── get-possession-length-frequency.ipynb ├── get-possessions.ipynb ├── get-relative-off-def-efficiency.ipynb ├── get-scatter-plots.ipynb ├── get-score-margin-breakdown.ipynb ├── get-score-time-summary.ipynb ├── get-shot-query-summary.ipynb ├── get-shots.ipynb ├── get-team-leverage-summary.ipynb ├── get-team-players-for-season.ipynb ├── get-teams.ipynb ├── get-top-results.ipynb ├── get-totals.ipynb ├── get-win-probability.ipynb ├── get-wowy-combination-stats.ipynb ├── get-wowy-combo-playing-time-distribution.ipynb ├── get-wowy-stats.ipynb ├── live-game.ipynb └── live-games.ipynb /.gitignore: -------------------------------------------------------------------------------- 1 | .ipynb_checkpoints/ 2 | 3 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # pbpstats-api-code-examples 2 | Code examples for using the [pbpstats.com](https://pbpstats.com) API 3 | 4 | For documentation see [here](https://api.pbpstats.com/docs) -------------------------------------------------------------------------------- /get-all-season-stats.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "id": "59cb6de5-1bc9-4c64-8c63-75522df140dd", 6 | "metadata": {}, 7 | "source": [ 8 | "This endpoint can be used to get career stats by season for a player/team/lineup" 9 | ] 10 | }, 11 | { 12 | "cell_type": "code", 13 | "execution_count": 1, 14 | "id": "18d1387d-34e8-4260-9fd2-da725acab59e", 15 | "metadata": {}, 16 | "outputs": [], 17 | "source": [ 18 | "import requests" 19 | ] 20 | }, 21 | { 22 | "cell_type": "markdown", 23 | "id": "53d1585f-49ee-4745-9949-6a67bea56616", 24 | "metadata": {}, 25 | "source": [ 26 | "### Warriors Death Lineup" 27 | ] 28 | }, 29 | { 30 | "cell_type": "code", 31 | "execution_count": 2, 32 | "id": "e0c071e2-f2d4-4025-a06a-eb91e0c80de7", 33 | "metadata": {}, 34 | "outputs": [], 35 | "source": [ 36 | "url = \"https://api.pbpstats.com/get-all-season-stats/nba\"\n", 37 | "params = {\n", 38 | " \"EntityType\": \"Lineup\", # Use LineupOpponent to get opponent stats\n", 39 | " \"EntityId\": \"201939-202691-203084-203110-2738\"\n", 40 | "}\n", 41 | "response = requests.get(url, params=params)\n", 42 | "response_json = response.json()" 43 | ] 44 | }, 45 | { 46 | "cell_type": "markdown", 47 | "id": "ca3f4569-d8ca-45ab-99ea-50e93b509770", 48 | "metadata": {}, 49 | "source": [ 50 | "### Miami Heat" 51 | ] 52 | }, 53 | { 54 | "cell_type": "code", 55 | "execution_count": 3, 56 | "id": "4996fc30-448a-4978-bb77-419291dddf21", 57 | "metadata": {}, 58 | "outputs": [], 59 | "source": [ 60 | "url = \"https://api.pbpstats.com/get-all-season-stats/nba\"\n", 61 | "params = {\n", 62 | " \"EntityType\": \"Opponent\",\n", 63 | " \"EntityId\": \"1610612748\"\n", 64 | "}\n", 65 | "response = requests.get(url, params=params)\n", 66 | "response_json = response.json()" 67 | ] 68 | }, 69 | { 70 | "cell_type": "markdown", 71 | "id": "00ee8344-8aaa-42b8-9d0d-175424ae6784", 72 | "metadata": {}, 73 | "source": [ 74 | "### Miami Heat - Opponent" 75 | ] 76 | }, 77 | { 78 | "cell_type": "code", 79 | "execution_count": 4, 80 | "id": "e2d3f061-154a-4e0c-a5aa-435ba1f2d802", 81 | "metadata": {}, 82 | "outputs": [], 83 | "source": [ 84 | "url = \"https://api.pbpstats.com/get-all-season-stats/nba\"\n", 85 | "params = {\n", 86 | " \"EntityType\": \"Team\",\n", 87 | " \"EntityId\": \"1610612748\"\n", 88 | "}\n", 89 | "response = requests.get(url, params=params)\n", 90 | "response_json = response.json()" 91 | ] 92 | }, 93 | { 94 | "cell_type": "markdown", 95 | "id": "99e73608-b60f-4111-b671-d440febe9072", 96 | "metadata": {}, 97 | "source": [ 98 | "### Sue Bird" 99 | ] 100 | }, 101 | { 102 | "cell_type": "code", 103 | "execution_count": 5, 104 | "id": "7d159804-239d-4e57-ac55-a52f4b6a84f8", 105 | "metadata": {}, 106 | "outputs": [], 107 | "source": [ 108 | "url = \"https://api.pbpstats.com/get-all-season-stats/wnba\"\n", 109 | "params = {\n", 110 | " \"EntityType\": \"Player\",\n", 111 | " \"EntityId\": \"100720\"\n", 112 | "}\n", 113 | "response = requests.get(url, params=params)\n", 114 | "response_json = response.json()" 115 | ] 116 | }, 117 | { 118 | "cell_type": "code", 119 | "execution_count": null, 120 | "id": "e9d307ac-7cc5-431b-9a3e-8bea5785e1e1", 121 | "metadata": {}, 122 | "outputs": [], 123 | "source": [] 124 | } 125 | ], 126 | "metadata": { 127 | "kernelspec": { 128 | "display_name": "playground", 129 | "language": "python", 130 | "name": "playground" 131 | }, 132 | "language_info": { 133 | "codemirror_mode": { 134 | "name": "ipython", 135 | "version": 3 136 | }, 137 | "file_extension": ".py", 138 | "mimetype": "text/x-python", 139 | "name": "python", 140 | "nbconvert_exporter": "python", 141 | "pygments_lexer": "ipython3", 142 | "version": "3.8.9" 143 | } 144 | }, 145 | "nbformat": 4, 146 | "nbformat_minor": 5 147 | } 148 | -------------------------------------------------------------------------------- /get-assist-combo-summary.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "id": "ba43f25b-6ba1-48fc-9553-90197b03897c", 6 | "metadata": {}, 7 | "source": [ 8 | "This endpoint can be used to get assist counts for all passer to scorer assist combinations" 9 | ] 10 | }, 11 | { 12 | "cell_type": "code", 13 | "execution_count": 1, 14 | "id": "47ec0e83-e6a0-461f-acab-ce96c3235664", 15 | "metadata": {}, 16 | "outputs": [], 17 | "source": [ 18 | "import requests" 19 | ] 20 | }, 21 | { 22 | "cell_type": "markdown", 23 | "id": "cf81879c-9499-46e3-a146-6955982e6562", 24 | "metadata": {}, 25 | "source": [ 26 | "### NBA" 27 | ] 28 | }, 29 | { 30 | "cell_type": "code", 31 | "execution_count": 2, 32 | "id": "1330ff35-0488-4377-8564-e2ecb017aec2", 33 | "metadata": {}, 34 | "outputs": [ 35 | { 36 | "data": { 37 | "text/plain": [ 38 | "{'arc3': 0,\n", 39 | " 'assist_player': 'Trae Young',\n", 40 | " 'assist_player_id': '1629027',\n", 41 | " 'atrim': 158,\n", 42 | " 'corner3': 0,\n", 43 | " 'longmidrange': 0,\n", 44 | " 'scorer_player': 'Clint Capela',\n", 45 | " 'scorer_player_id': '203991',\n", 46 | " 'shortmidrange': 6,\n", 47 | " 'team': 'ATL',\n", 48 | " 'team_id': '1610612737',\n", 49 | " 'total': 164,\n", 50 | " 'total2s': 164,\n", 51 | " 'total3s': 0}" 52 | ] 53 | }, 54 | "execution_count": 2, 55 | "metadata": {}, 56 | "output_type": "execute_result" 57 | } 58 | ], 59 | "source": [ 60 | "url = \"https://api.pbpstats.com/get-assist-combo-summary/nba\"\n", 61 | "params = {\n", 62 | " \"Season\": \"2021-22\",\n", 63 | " \"SeasonType\": \"Regular Season\"\n", 64 | "}\n", 65 | "response = requests.get(url, params=params)\n", 66 | "response_json = response.json()\n", 67 | "response_json['results'][0]" 68 | ] 69 | }, 70 | { 71 | "cell_type": "markdown", 72 | "id": "ab35bb54-5fd4-4db9-ae7c-749820a8f0cf", 73 | "metadata": {}, 74 | "source": [ 75 | "### WNBA" 76 | ] 77 | }, 78 | { 79 | "cell_type": "code", 80 | "execution_count": 3, 81 | "id": "bbd2bd3b-cfe1-46b1-adf2-b8a1754a361b", 82 | "metadata": {}, 83 | "outputs": [ 84 | { 85 | "data": { 86 | "text/plain": [ 87 | "{'arc3': 4,\n", 88 | " 'assist_player': 'Jordin Canada',\n", 89 | " 'assist_player_id': '1628886',\n", 90 | " 'atrim': 6,\n", 91 | " 'corner3': 0,\n", 92 | " 'longmidrange': 0,\n", 93 | " 'scorer_player': 'Nneka Ogwumike',\n", 94 | " 'scorer_player_id': '203014',\n", 95 | " 'shortmidrange': 5,\n", 96 | " 'team': 'LAS',\n", 97 | " 'team_id': '1611661320',\n", 98 | " 'total': 15,\n", 99 | " 'total2s': 11,\n", 100 | " 'total3s': 4}" 101 | ] 102 | }, 103 | "execution_count": 3, 104 | "metadata": {}, 105 | "output_type": "execute_result" 106 | } 107 | ], 108 | "source": [ 109 | "url = \"https://api.pbpstats.com/get-assist-combo-summary/wnba\"\n", 110 | "params = {\n", 111 | " \"Season\": \"2022\",\n", 112 | " \"SeasonType\": \"Regular Season\"\n", 113 | "}\n", 114 | "response = requests.get(url, params=params)\n", 115 | "response_json = response.json()\n", 116 | "response_json['results'][0]" 117 | ] 118 | }, 119 | { 120 | "cell_type": "code", 121 | "execution_count": null, 122 | "id": "33c01565-c9c8-4aed-999b-638afa07a7ac", 123 | "metadata": {}, 124 | "outputs": [], 125 | "source": [] 126 | } 127 | ], 128 | "metadata": { 129 | "kernelspec": { 130 | "display_name": "playground", 131 | "language": "python", 132 | "name": "playground" 133 | }, 134 | "language_info": { 135 | "codemirror_mode": { 136 | "name": "ipython", 137 | "version": 3 138 | }, 139 | "file_extension": ".py", 140 | "mimetype": "text/x-python", 141 | "name": "python", 142 | "nbconvert_exporter": "python", 143 | "pygments_lexer": "ipython3", 144 | "version": "3.8.9" 145 | } 146 | }, 147 | "nbformat": 4, 148 | "nbformat_minor": 5 149 | } 150 | -------------------------------------------------------------------------------- /get-endgame-breakeven-2-pct.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "id": "ba8c58cb-2671-42ae-9a70-404a976f94b1", 6 | "metadata": {}, 7 | "source": [ 8 | "This endpoint can be used to get the breakeven 2pt percentage needed for a 2pt shot to be better than a 3pt shot for a given percentage" 9 | ] 10 | }, 11 | { 12 | "cell_type": "code", 13 | "execution_count": 1, 14 | "id": "5d3577ce-2630-4a3c-8ffd-70c03b02b585", 15 | "metadata": {}, 16 | "outputs": [], 17 | "source": [ 18 | "import requests" 19 | ] 20 | }, 21 | { 22 | "cell_type": "markdown", 23 | "id": "f0874acf-8a37-48e1-8ee8-557c795fffeb", 24 | "metadata": {}, 25 | "source": [ 26 | "### NBA - down 3 with 20 seconds left and a 30% 3pt shot" 27 | ] 28 | }, 29 | { 30 | "cell_type": "code", 31 | "execution_count": 2, 32 | "id": "b1b27804-b1fd-4c21-bd07-8de61fbd4ca1", 33 | "metadata": {}, 34 | "outputs": [ 35 | { 36 | "data": { 37 | "text/plain": [ 38 | "{'breakeven2_pct': 55}" 39 | ] 40 | }, 41 | "execution_count": 2, 42 | "metadata": {}, 43 | "output_type": "execute_result" 44 | } 45 | ], 46 | "source": [ 47 | "league = \"nba\"\n", 48 | "margin = -3 # from the perspective of the team with the ball\n", 49 | "seconds_remaining = 20 # This is time remaining after the shot is made or rebounded\n", 50 | "three_point_pct = 30\n", 51 | "\n", 52 | "url = f\"https://api.pbpstats.com/get-endgame-breakeven-2-pct/{league}/{margin}/{seconds_remaining}/{three_point_pct}\"\n", 53 | "\n", 54 | "response = requests.get(url)\n", 55 | "response_json = response.json()\n", 56 | "response_json" 57 | ] 58 | }, 59 | { 60 | "cell_type": "markdown", 61 | "id": "a77401a7-3a3a-402f-9176-fa6de1e035d2", 62 | "metadata": {}, 63 | "source": [ 64 | "A 55% 2pt shot is equivalent to a 30% 3pt shot in terms of the impact on your win probability" 65 | ] 66 | }, 67 | { 68 | "cell_type": "code", 69 | "execution_count": null, 70 | "id": "2ff0477a-60b5-479c-87cd-08ddc21a0a25", 71 | "metadata": {}, 72 | "outputs": [], 73 | "source": [] 74 | } 75 | ], 76 | "metadata": { 77 | "kernelspec": { 78 | "display_name": "playground", 79 | "language": "python", 80 | "name": "playground" 81 | }, 82 | "language_info": { 83 | "codemirror_mode": { 84 | "name": "ipython", 85 | "version": 3 86 | }, 87 | "file_extension": ".py", 88 | "mimetype": "text/x-python", 89 | "name": "python", 90 | "nbconvert_exporter": "python", 91 | "pygments_lexer": "ipython3", 92 | "version": "3.8.9" 93 | } 94 | }, 95 | "nbformat": 4, 96 | "nbformat_minor": 5 97 | } 98 | -------------------------------------------------------------------------------- /get-four-factor-on-off.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "id": "0810d32a-4835-4680-8675-f801ba40b0f1", 6 | "metadata": {}, 7 | "source": [ 8 | "This endpoint can be used to get a team's four factors stats with a player on and off the floor" 9 | ] 10 | }, 11 | { 12 | "cell_type": "code", 13 | "execution_count": 1, 14 | "id": "9fbd3b26-bd96-49cf-92bd-3df696322692", 15 | "metadata": {}, 16 | "outputs": [], 17 | "source": [ 18 | "import requests" 19 | ] 20 | }, 21 | { 22 | "cell_type": "markdown", 23 | "id": "d4b04c25-5a67-415d-8aa9-2d191cb53dc0", 24 | "metadata": {}, 25 | "source": [ 26 | "### Stephen Curry" 27 | ] 28 | }, 29 | { 30 | "cell_type": "code", 31 | "execution_count": 2, 32 | "id": "4732fbd9-5817-4d06-ae38-5687c725cbce", 33 | "metadata": {}, 34 | "outputs": [ 35 | { 36 | "data": { 37 | "text/plain": [ 38 | "{'offense_results': [{'On': 0.5680137999014293,\n", 39 | " 'Off': 0.529663810151615,\n", 40 | " 'stat': 'eFG%'},\n", 41 | " {'On': 0.2578558225508318, 'Off': 0.24407582938388625, 'stat': 'OReb%'},\n", 42 | " {'On': 0.22695909314933466, 'Off': 0.24522083058668426, 'stat': 'FTr'},\n", 43 | " {'On': 0.15394708069101246, 'Off': 0.14821222606689735, 'stat': 'TOV%'}],\n", 44 | " 'defense_results': [{'On': 0.5001244090569793,\n", 45 | " 'Off': 0.5199351701782821,\n", 46 | " 'stat': 'eFG%'},\n", 47 | " {'On': 0.25564550489987214, 'Off': 0.23860438942037143, 'stat': 'OReb%'},\n", 48 | " {'On': 0.25255038566807664, 'Off': 0.28038897893030795, 'stat': 'FTr'},\n", 49 | " {'On': 0.15474613686534217, 'Off': 0.138912610304583, 'stat': 'TOV%'}],\n", 50 | " 'minutes_on': 2211,\n", 51 | " 'minutes_off': 1737}" 52 | ] 53 | }, 54 | "execution_count": 2, 55 | "metadata": {}, 56 | "output_type": "execute_result" 57 | } 58 | ], 59 | "source": [ 60 | "url = \"https://api.pbpstats.com/get-four-factor-on-off/nba\"\n", 61 | "params = {\n", 62 | " \"Season\": \"2021-22\",\n", 63 | " \"SeasonType\": \"Regular Season\",\n", 64 | " \"TeamId\": \"1610612744\",\n", 65 | " \"PlayerId\": \"201939\"\n", 66 | "}\n", 67 | "response = requests.get(url, params=params)\n", 68 | "response_json = response.json()\n", 69 | "response_json" 70 | ] 71 | }, 72 | { 73 | "cell_type": "markdown", 74 | "id": "4da88036-039e-4002-b4bc-a7d6e822865c", 75 | "metadata": {}, 76 | "source": [ 77 | "### Sue Bird" 78 | ] 79 | }, 80 | { 81 | "cell_type": "code", 82 | "execution_count": 3, 83 | "id": "b6328345-dba8-4704-964a-da95399f9bd1", 84 | "metadata": {}, 85 | "outputs": [ 86 | { 87 | "data": { 88 | "text/plain": [ 89 | "{'offense_results': [{'On': 0.46366782006920415,\n", 90 | " 'Off': 0.44575471698113206,\n", 91 | " 'stat': 'eFG%'},\n", 92 | " {'On': 0.21839080459770116, 'Off': 0.2932330827067669, 'stat': 'OReb%'},\n", 93 | " {'On': 0.19377162629757785, 'Off': 0.27358490566037735, 'stat': 'FTr'},\n", 94 | " {'On': 0.17964071856287425, 'Off': 0.1336206896551724, 'stat': 'TOV%'}],\n", 95 | " 'defense_results': [{'On': 0.5324909747292419,\n", 96 | " 'Off': 0.4444444444444444,\n", 97 | " 'stat': 'eFG%'},\n", 98 | " {'On': 0.26206896551724135, 'Off': 0.2857142857142857, 'stat': 'OReb%'},\n", 99 | " {'On': 0.16967509025270758, 'Off': 0.2474747474747475, 'stat': 'FTr'},\n", 100 | " {'On': 0.21646341463414634, 'Off': 0.2301255230125523, 'stat': 'TOV%'}],\n", 101 | " 'minutes_on': 161,\n", 102 | " 'minutes_off': 124}" 103 | ] 104 | }, 105 | "execution_count": 3, 106 | "metadata": {}, 107 | "output_type": "execute_result" 108 | } 109 | ], 110 | "source": [ 111 | "url = \"https://api.pbpstats.com/get-four-factor-on-off/wnba\"\n", 112 | "params = {\n", 113 | " \"Season\": \"2022\",\n", 114 | " \"SeasonType\": \"Regular Season\",\n", 115 | " \"TeamId\": \"1611661328\",\n", 116 | " \"PlayerId\": \"100720\"\n", 117 | "}\n", 118 | "response = requests.get(url, params=params)\n", 119 | "response_json = response.json()\n", 120 | "response_json" 121 | ] 122 | }, 123 | { 124 | "cell_type": "code", 125 | "execution_count": null, 126 | "id": "95991f27-702d-4e69-ad98-c79a2b1653ef", 127 | "metadata": {}, 128 | "outputs": [], 129 | "source": [] 130 | } 131 | ], 132 | "metadata": { 133 | "kernelspec": { 134 | "display_name": "playground", 135 | "language": "python", 136 | "name": "playground" 137 | }, 138 | "language_info": { 139 | "codemirror_mode": { 140 | "name": "ipython", 141 | "version": 3 142 | }, 143 | "file_extension": ".py", 144 | "mimetype": "text/x-python", 145 | "name": "python", 146 | "nbconvert_exporter": "python", 147 | "pygments_lexer": "ipython3", 148 | "version": "3.8.9" 149 | } 150 | }, 151 | "nbformat": 4, 152 | "nbformat_minor": 5 153 | } 154 | -------------------------------------------------------------------------------- /get-game-logs.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "id": "09eea106-2f99-44ff-af4a-3d39c22c4f6e", 6 | "metadata": {}, 7 | "source": [ 8 | "This endpoint can be used to get game logs for a player/team/lineup" 9 | ] 10 | }, 11 | { 12 | "cell_type": "code", 13 | "execution_count": 1, 14 | "id": "cfb95a7a-1b7a-4830-89bd-7456fc2c6cf3", 15 | "metadata": {}, 16 | "outputs": [], 17 | "source": [ 18 | "import requests" 19 | ] 20 | }, 21 | { 22 | "cell_type": "markdown", 23 | "id": "36800518-5756-4749-b424-ffb695d1496c", 24 | "metadata": {}, 25 | "source": [ 26 | "# Atlanta Hawks" 27 | ] 28 | }, 29 | { 30 | "cell_type": "code", 31 | "execution_count": 2, 32 | "id": "98bab259-5b97-4bdc-9a37-28660c17290a", 33 | "metadata": {}, 34 | "outputs": [], 35 | "source": [ 36 | "url = \"https://api.pbpstats.com/get-game-logs/nba\"\n", 37 | "params = {\n", 38 | " \"Season\": \"2021-22\", # To get for multiple seasons, separate seasons by comma\n", 39 | " \"SeasonType\": \"Regular Season\",\n", 40 | " \"EntityId\": \"1610612737\",\n", 41 | " \"EntityType\": \"Team\" # Use Opponent to get opponent stats\n", 42 | "}\n", 43 | "response = requests.get(url, params=params)\n", 44 | "response_json = response.json()\n", 45 | "totals = response_json['single_row_table_data']\n", 46 | "game_logs = response_json['multi_row_table_data']" 47 | ] 48 | }, 49 | { 50 | "cell_type": "markdown", 51 | "id": "3bad76c7-8568-4aec-8070-7548bee5a59f", 52 | "metadata": {}, 53 | "source": [ 54 | "# Al Horford, Marcus Smart, Jaylen Brown, Jayson Tatum, Robert Williams III" 55 | ] 56 | }, 57 | { 58 | "cell_type": "code", 59 | "execution_count": 3, 60 | "id": "264ae561-56a4-4ca3-a765-56f8c3e76363", 61 | "metadata": {}, 62 | "outputs": [], 63 | "source": [ 64 | "url = \"https://api.pbpstats.com/get-game-logs/nba\"\n", 65 | "params = {\n", 66 | " \"Season\": \"2021-22\", # To get for multiple seasons, separate seasons by comma\n", 67 | " \"SeasonType\": \"Regular Season\",\n", 68 | " \"EntityId\": \"1627759-1628369-1629057-201143-203935\",\n", 69 | " \"EntityType\": \"Lineup\" # Use LineupOpponent to get opponent stats\n", 70 | "}\n", 71 | "response = requests.get(url, params=params)\n", 72 | "response_json = response.json()\n", 73 | "totals = response_json['single_row_table_data']\n", 74 | "game_logs = response_json['multi_row_table_data']" 75 | ] 76 | }, 77 | { 78 | "cell_type": "markdown", 79 | "id": "3e275060-975e-440e-bbda-a745c45238da", 80 | "metadata": {}, 81 | "source": [ 82 | "### Nia Coffey" 83 | ] 84 | }, 85 | { 86 | "cell_type": "code", 87 | "execution_count": 4, 88 | "id": "a8e6175c-99cd-438e-8518-7e64381cc433", 89 | "metadata": {}, 90 | "outputs": [], 91 | "source": [ 92 | "url = \"https://api.pbpstats.com/get-game-logs/wnba\"\n", 93 | "params = {\n", 94 | " \"Season\": \"2021,2022\",\n", 95 | " \"SeasonType\": \"Regular Season\",\n", 96 | " \"EntityId\": \"1628269\",\n", 97 | " \"EntityType\": \"Player\"\n", 98 | "}\n", 99 | "response = requests.get(url, params=params)\n", 100 | "response_json = response.json()\n", 101 | "totals = response_json['single_row_table_data']\n", 102 | "game_logs = response_json['multi_row_table_data']" 103 | ] 104 | }, 105 | { 106 | "cell_type": "code", 107 | "execution_count": null, 108 | "id": "635e68c5-c9c1-4171-8537-af8fe2ab2ef7", 109 | "metadata": {}, 110 | "outputs": [], 111 | "source": [] 112 | } 113 | ], 114 | "metadata": { 115 | "kernelspec": { 116 | "display_name": "playground", 117 | "language": "python", 118 | "name": "playground" 119 | }, 120 | "language_info": { 121 | "codemirror_mode": { 122 | "name": "ipython", 123 | "version": 3 124 | }, 125 | "file_extension": ".py", 126 | "mimetype": "text/x-python", 127 | "name": "python", 128 | "nbconvert_exporter": "python", 129 | "pygments_lexer": "ipython3", 130 | "version": "3.8.9" 131 | } 132 | }, 133 | "nbformat": 4, 134 | "nbformat_minor": 5 135 | } 136 | -------------------------------------------------------------------------------- /get-games.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "id": "0b192f8d-8044-4e90-93f3-d24360b0b39c", 6 | "metadata": {}, 7 | "source": [ 8 | "This endpoint can be used to get all games, with some basic game data, for a league, season and season type" 9 | ] 10 | }, 11 | { 12 | "cell_type": "code", 13 | "execution_count": 1, 14 | "id": "1db25c44-3101-41a9-a0b4-ce1408363b34", 15 | "metadata": {}, 16 | "outputs": [], 17 | "source": [ 18 | "import requests" 19 | ] 20 | }, 21 | { 22 | "cell_type": "markdown", 23 | "id": "7753004e-d14a-4c7e-b09a-0370bfe3f1bb", 24 | "metadata": {}, 25 | "source": [ 26 | "### NBA - Regular season" 27 | ] 28 | }, 29 | { 30 | "cell_type": "code", 31 | "execution_count": 2, 32 | "id": "f09ec5f7-67bd-4976-8de8-778c8323ac89", 33 | "metadata": {}, 34 | "outputs": [ 35 | { 36 | "data": { 37 | "text/plain": [ 38 | "{'GameId': '0022100902',\n", 39 | " 'Date': '2022-02-25',\n", 40 | " 'HomeTeamId': '1610612756',\n", 41 | " 'AwayTeamId': '1610612740',\n", 42 | " 'HomePoints': 102,\n", 43 | " 'AwayPoints': 117,\n", 44 | " 'HomePossessions': 98,\n", 45 | " 'AwayPossessions': 98,\n", 46 | " 'HomeTeamAbbreviation': 'PHX',\n", 47 | " 'AwayTeamAbbreviation': 'NOP'}" 48 | ] 49 | }, 50 | "execution_count": 2, 51 | "metadata": {}, 52 | "output_type": "execute_result" 53 | } 54 | ], 55 | "source": [ 56 | "games_url = \"https://api.pbpstats.com/get-games/nba\"\n", 57 | "games_params = {\n", 58 | " \"Season\": \"2021-22\",\n", 59 | " \"SeasonType\": \"Regular Season\"\n", 60 | "}\n", 61 | "games_response = requests.get(games_url, params=games_params)\n", 62 | "games = games_response.json()\n", 63 | "games[\"results\"][0]" 64 | ] 65 | }, 66 | { 67 | "cell_type": "markdown", 68 | "id": "ecfea5eb-74f2-4363-9c36-c314621e9670", 69 | "metadata": {}, 70 | "source": [ 71 | "### NBA - Playoffs" 72 | ] 73 | }, 74 | { 75 | "cell_type": "code", 76 | "execution_count": 3, 77 | "id": "3114126c-2387-4784-b091-7f8e129851d5", 78 | "metadata": {}, 79 | "outputs": [ 80 | { 81 | "data": { 82 | "text/plain": [ 83 | "{'GameId': '0042100124',\n", 84 | " 'Date': '2022-04-24',\n", 85 | " 'HomeTeamId': '1610612741',\n", 86 | " 'AwayTeamId': '1610612749',\n", 87 | " 'HomePoints': 95,\n", 88 | " 'AwayPoints': 119,\n", 89 | " 'HomePossessions': 100,\n", 90 | " 'AwayPossessions': 100,\n", 91 | " 'HomeTeamAbbreviation': 'CHI',\n", 92 | " 'AwayTeamAbbreviation': 'MIL'}" 93 | ] 94 | }, 95 | "execution_count": 3, 96 | "metadata": {}, 97 | "output_type": "execute_result" 98 | } 99 | ], 100 | "source": [ 101 | "games_url = \"https://api.pbpstats.com/get-games/nba\"\n", 102 | "games_params = {\n", 103 | " \"Season\": \"2021-22\",\n", 104 | " \"SeasonType\": \"Playoffs\"\n", 105 | "}\n", 106 | "games_response = requests.get(games_url, params=games_params)\n", 107 | "games = games_response.json()\n", 108 | "games[\"results\"][0]" 109 | ] 110 | }, 111 | { 112 | "cell_type": "markdown", 113 | "id": "93a65eb0-4be1-4531-b473-73d3b4204051", 114 | "metadata": {}, 115 | "source": [ 116 | "### NBA - Play in" 117 | ] 118 | }, 119 | { 120 | "cell_type": "code", 121 | "execution_count": 4, 122 | "id": "9553739c-510e-41db-9609-82513e9131db", 123 | "metadata": {}, 124 | "outputs": [ 125 | { 126 | "data": { 127 | "text/plain": [ 128 | "{'GameId': '0052100101',\n", 129 | " 'Date': '2022-04-12',\n", 130 | " 'HomeTeamId': '1610612751',\n", 131 | " 'AwayTeamId': '1610612739',\n", 132 | " 'HomePoints': 115,\n", 133 | " 'AwayPoints': 108,\n", 134 | " 'HomePossessions': 96,\n", 135 | " 'AwayPossessions': 96,\n", 136 | " 'HomeTeamAbbreviation': 'BKN',\n", 137 | " 'AwayTeamAbbreviation': 'CLE'}" 138 | ] 139 | }, 140 | "execution_count": 4, 141 | "metadata": {}, 142 | "output_type": "execute_result" 143 | } 144 | ], 145 | "source": [ 146 | "games_url = \"https://api.pbpstats.com/get-games/nba\"\n", 147 | "games_params = {\n", 148 | " \"Season\": \"2021-22\",\n", 149 | " \"SeasonType\": \"PlayIn\"\n", 150 | "}\n", 151 | "games_response = requests.get(games_url, params=games_params)\n", 152 | "games = games_response.json()\n", 153 | "games[\"results\"][0]" 154 | ] 155 | }, 156 | { 157 | "cell_type": "markdown", 158 | "id": "fbb25fe0-236e-4d46-8790-380a7597ebf4", 159 | "metadata": {}, 160 | "source": [ 161 | "### NBA - Any season type" 162 | ] 163 | }, 164 | { 165 | "cell_type": "code", 166 | "execution_count": 5, 167 | "id": "cf68cfa6-d5c4-480a-aa34-160146b3a1de", 168 | "metadata": {}, 169 | "outputs": [ 170 | { 171 | "data": { 172 | "text/plain": [ 173 | "{'GameId': '0022100902',\n", 174 | " 'Date': '2022-02-25',\n", 175 | " 'HomeTeamId': '1610612756',\n", 176 | " 'AwayTeamId': '1610612740',\n", 177 | " 'HomePoints': 102,\n", 178 | " 'AwayPoints': 117,\n", 179 | " 'HomePossessions': 98,\n", 180 | " 'AwayPossessions': 98,\n", 181 | " 'HomeTeamAbbreviation': 'PHX',\n", 182 | " 'AwayTeamAbbreviation': 'NOP'}" 183 | ] 184 | }, 185 | "execution_count": 5, 186 | "metadata": {}, 187 | "output_type": "execute_result" 188 | } 189 | ], 190 | "source": [ 191 | "games_url = \"https://api.pbpstats.com/get-games/nba\"\n", 192 | "games_params = {\n", 193 | " \"Season\": \"2021-22\",\n", 194 | " \"SeasonType\": \"All\"\n", 195 | "}\n", 196 | "games_response = requests.get(games_url, params=games_params)\n", 197 | "games = games_response.json()\n", 198 | "games[\"results\"][0]" 199 | ] 200 | }, 201 | { 202 | "cell_type": "markdown", 203 | "id": "386baaaa-c868-49a9-89bc-a07c9332d888", 204 | "metadata": {}, 205 | "source": [ 206 | "### NBA - Regular season for multiple seasons" 207 | ] 208 | }, 209 | { 210 | "cell_type": "code", 211 | "execution_count": 6, 212 | "id": "ae098d08-a395-4915-b8a0-9820c9b39d51", 213 | "metadata": {}, 214 | "outputs": [ 215 | { 216 | "data": { 217 | "text/plain": [ 218 | "{'GameId': '0022100902',\n", 219 | " 'Date': '2022-02-25',\n", 220 | " 'HomeTeamId': '1610612756',\n", 221 | " 'AwayTeamId': '1610612740',\n", 222 | " 'HomePoints': 102,\n", 223 | " 'AwayPoints': 117,\n", 224 | " 'HomePossessions': 98,\n", 225 | " 'AwayPossessions': 98,\n", 226 | " 'HomeTeamAbbreviation': 'PHX',\n", 227 | " 'AwayTeamAbbreviation': 'NOP'}" 228 | ] 229 | }, 230 | "execution_count": 6, 231 | "metadata": {}, 232 | "output_type": "execute_result" 233 | } 234 | ], 235 | "source": [ 236 | "games_url = \"https://api.pbpstats.com/get-games/nba\"\n", 237 | "games_params = {\n", 238 | " \"Season\": \"2021-22,2020-21\",\n", 239 | " \"SeasonType\": \"Regular Season\"\n", 240 | "}\n", 241 | "games_response = requests.get(games_url, params=games_params)\n", 242 | "games = games_response.json()\n", 243 | "games[\"results\"][0]" 244 | ] 245 | }, 246 | { 247 | "cell_type": "markdown", 248 | "id": "291a193b-5d26-4145-a935-e0404950762b", 249 | "metadata": {}, 250 | "source": [ 251 | "### WNBA - Regular season" 252 | ] 253 | }, 254 | { 255 | "cell_type": "code", 256 | "execution_count": 7, 257 | "id": "06cb71b6-9c6d-47b5-b71b-fe4c9dc4c923", 258 | "metadata": {}, 259 | "outputs": [ 260 | { 261 | "data": { 262 | "text/plain": [ 263 | "{'GameId': '1022200001',\n", 264 | " 'Date': '2022-05-06',\n", 265 | " 'HomeTeamId': '1611661322',\n", 266 | " 'AwayTeamId': '1611661325',\n", 267 | " 'HomePoints': 84,\n", 268 | " 'AwayPoints': 70,\n", 269 | " 'HomePossessions': 78,\n", 270 | " 'AwayPossessions': 76,\n", 271 | " 'HomeTeamAbbreviation': 'WAS',\n", 272 | " 'AwayTeamAbbreviation': 'IND'}" 273 | ] 274 | }, 275 | "execution_count": 7, 276 | "metadata": {}, 277 | "output_type": "execute_result" 278 | } 279 | ], 280 | "source": [ 281 | "games_url = \"https://api.pbpstats.com/get-games/wnba\"\n", 282 | "games_params = {\n", 283 | " \"Season\": \"2022\",\n", 284 | " \"SeasonType\": \"Regular Season\"\n", 285 | "}\n", 286 | "games_response = requests.get(games_url, params=games_params)\n", 287 | "games = games_response.json()\n", 288 | "games[\"results\"][0]" 289 | ] 290 | }, 291 | { 292 | "cell_type": "markdown", 293 | "id": "dc7c0eea-02ff-4afd-b6b1-0b3e5e173824", 294 | "metadata": {}, 295 | "source": [ 296 | "### WNBA - Playoffs" 297 | ] 298 | }, 299 | { 300 | "cell_type": "code", 301 | "execution_count": 8, 302 | "id": "5ce2d9e9-932b-4450-b85f-ae31c09d177b", 303 | "metadata": {}, 304 | "outputs": [ 305 | { 306 | "data": { 307 | "text/plain": [ 308 | "{'GameId': '1042100111',\n", 309 | " 'Date': '2021-09-23',\n", 310 | " 'HomeTeamId': '1611661329',\n", 311 | " 'AwayTeamId': '1611661321',\n", 312 | " 'HomePoints': 81,\n", 313 | " 'AwayPoints': 64,\n", 314 | " 'HomePossessions': 76,\n", 315 | " 'AwayPossessions': 76,\n", 316 | " 'HomeTeamAbbreviation': 'CHI',\n", 317 | " 'AwayTeamAbbreviation': 'DAL'}" 318 | ] 319 | }, 320 | "execution_count": 8, 321 | "metadata": {}, 322 | "output_type": "execute_result" 323 | } 324 | ], 325 | "source": [ 326 | "games_url = \"https://api.pbpstats.com/get-games/wnba\"\n", 327 | "games_params = {\n", 328 | " \"Season\": \"2021\",\n", 329 | " \"SeasonType\": \"Playoffs\"\n", 330 | "}\n", 331 | "games_response = requests.get(games_url, params=games_params)\n", 332 | "games = games_response.json()\n", 333 | "games[\"results\"][0]" 334 | ] 335 | }, 336 | { 337 | "cell_type": "markdown", 338 | "id": "6b83802d-d17c-4367-a3cf-6f931ad80d5e", 339 | "metadata": {}, 340 | "source": [ 341 | "### WNBA - Any season type" 342 | ] 343 | }, 344 | { 345 | "cell_type": "code", 346 | "execution_count": 9, 347 | "id": "42c043a3-0e10-4cd4-bf70-821b315f38fa", 348 | "metadata": {}, 349 | "outputs": [ 350 | { 351 | "data": { 352 | "text/plain": [ 353 | "{'GameId': '1022100174',\n", 354 | " 'Date': '2021-09-10',\n", 355 | " 'HomeTeamId': '1611661324',\n", 356 | " 'AwayTeamId': '1611661325',\n", 357 | " 'HomePoints': 89,\n", 358 | " 'AwayPoints': 72,\n", 359 | " 'HomePossessions': 77,\n", 360 | " 'AwayPossessions': 77,\n", 361 | " 'HomeTeamAbbreviation': 'MIN',\n", 362 | " 'AwayTeamAbbreviation': 'IND'}" 363 | ] 364 | }, 365 | "execution_count": 9, 366 | "metadata": {}, 367 | "output_type": "execute_result" 368 | } 369 | ], 370 | "source": [ 371 | "games_url = \"https://api.pbpstats.com/get-games/wnba\"\n", 372 | "games_params = {\n", 373 | " \"Season\": \"2021\",\n", 374 | " \"SeasonType\": \"All\"\n", 375 | "}\n", 376 | "games_response = requests.get(games_url, params=games_params)\n", 377 | "games = games_response.json()\n", 378 | "games[\"results\"][0]" 379 | ] 380 | }, 381 | { 382 | "cell_type": "markdown", 383 | "id": "58845c99-032e-42f0-93bf-a0a58b8e82b9", 384 | "metadata": {}, 385 | "source": [ 386 | "### WNBA - Regular season for multiple seasons" 387 | ] 388 | }, 389 | { 390 | "cell_type": "code", 391 | "execution_count": 10, 392 | "id": "ed470666-9d23-4f42-80dd-94d921e17229", 393 | "metadata": {}, 394 | "outputs": [ 395 | { 396 | "data": { 397 | "text/plain": [ 398 | "{'GameId': '1022200001',\n", 399 | " 'Date': '2022-05-06',\n", 400 | " 'HomeTeamId': '1611661322',\n", 401 | " 'AwayTeamId': '1611661325',\n", 402 | " 'HomePoints': 84,\n", 403 | " 'AwayPoints': 70,\n", 404 | " 'HomePossessions': 78,\n", 405 | " 'AwayPossessions': 76,\n", 406 | " 'HomeTeamAbbreviation': 'WAS',\n", 407 | " 'AwayTeamAbbreviation': 'IND'}" 408 | ] 409 | }, 410 | "execution_count": 10, 411 | "metadata": {}, 412 | "output_type": "execute_result" 413 | } 414 | ], 415 | "source": [ 416 | "games_url = \"https://api.pbpstats.com/get-games/wnba\"\n", 417 | "games_params = {\n", 418 | " \"Season\": \"2022,2021\",\n", 419 | " \"SeasonType\": \"Regular Season\"\n", 420 | "}\n", 421 | "games_response = requests.get(games_url, params=games_params)\n", 422 | "games = games_response.json()\n", 423 | "games[\"results\"][0]" 424 | ] 425 | }, 426 | { 427 | "cell_type": "code", 428 | "execution_count": null, 429 | "id": "435ee0f6-b0ab-4d69-9c45-e9000f2c6303", 430 | "metadata": {}, 431 | "outputs": [], 432 | "source": [] 433 | } 434 | ], 435 | "metadata": { 436 | "kernelspec": { 437 | "display_name": "playground", 438 | "language": "python", 439 | "name": "playground" 440 | }, 441 | "language_info": { 442 | "codemirror_mode": { 443 | "name": "ipython", 444 | "version": 3 445 | }, 446 | "file_extension": ".py", 447 | "mimetype": "text/x-python", 448 | "name": "python", 449 | "nbconvert_exporter": "python", 450 | "pygments_lexer": "ipython3", 451 | "version": "3.8.9" 452 | } 453 | }, 454 | "nbformat": 4, 455 | "nbformat_minor": 5 456 | } 457 | -------------------------------------------------------------------------------- /get-league-year-over-year-plots.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "id": "f517d19a-bcfb-461d-ac6b-db91321eb911", 6 | "metadata": {}, 7 | "source": [ 8 | "The endpoint can be used to get year-over-year league averages for various stats" 9 | ] 10 | }, 11 | { 12 | "cell_type": "code", 13 | "execution_count": 1, 14 | "id": "eec35838-c69a-4251-b121-fe875fb6e975", 15 | "metadata": {}, 16 | "outputs": [], 17 | "source": [ 18 | "import requests" 19 | ] 20 | }, 21 | { 22 | "cell_type": "markdown", 23 | "id": "d42cd01f-bdf1-4294-9256-92b67b755bae", 24 | "metadata": {}, 25 | "source": [ 26 | "### NBA Points per 100 possessions and seconds per 100 possessions" 27 | ] 28 | }, 29 | { 30 | "cell_type": "code", 31 | "execution_count": 2, 32 | "id": "a38be6b4-522b-4e7c-98a9-804f5653acb2", 33 | "metadata": {}, 34 | "outputs": [ 35 | { 36 | "data": { 37 | "text/plain": [ 38 | "[{'season': '2000-01', 'left_value': 102.714, 'right_value': 15.731},\n", 39 | " {'season': '2001-02', 'left_value': 104.247, 'right_value': 15.832},\n", 40 | " {'season': '2002-03', 'left_value': 103.277, 'right_value': 15.77},\n", 41 | " {'season': '2003-04', 'left_value': 102.538, 'right_value': 15.921},\n", 42 | " {'season': '2004-05', 'left_value': 105.698, 'right_value': 15.781},\n", 43 | " {'season': '2005-06', 'left_value': 106.084, 'right_value': 15.884},\n", 44 | " {'season': '2006-07', 'left_value': 106.508, 'right_value': 15.674},\n", 45 | " {'season': '2007-08', 'left_value': 107.43, 'right_value': 15.579},\n", 46 | " {'season': '2008-09', 'left_value': 108.182, 'right_value': 15.698},\n", 47 | " {'season': '2009-10', 'left_value': 107.776, 'right_value': 15.558},\n", 48 | " {'season': '2010-11', 'left_value': 107.479, 'right_value': 15.669},\n", 49 | " {'season': '2011-12', 'left_value': 104.634, 'right_value': 15.78},\n", 50 | " {'season': '2012-13', 'left_value': 105.904, 'right_value': 15.659},\n", 51 | " {'season': '2013-14', 'left_value': 106.808, 'right_value': 15.35},\n", 52 | " {'season': '2014-15', 'left_value': 105.873, 'right_value': 15.367},\n", 53 | " {'season': '2015-16', 'left_value': 106.659, 'right_value': 15.072},\n", 54 | " {'season': '2016-17', 'left_value': 109.282, 'right_value': 15.004},\n", 55 | " {'season': '2017-18', 'left_value': 109.276, 'right_value': 14.885},\n", 56 | " {'season': '2018-19', 'left_value': 110.97, 'right_value': 14.465},\n", 57 | " {'season': '2019-20', 'left_value': 111.204, 'right_value': 14.429},\n", 58 | " {'season': '2020-21', 'left_value': 112.881, 'right_value': 14.588},\n", 59 | " {'season': '2021-22', 'left_value': 112.55, 'right_value': 14.735}]" 60 | ] 61 | }, 62 | "execution_count": 2, 63 | "metadata": {}, 64 | "output_type": "execute_result" 65 | } 66 | ], 67 | "source": [ 68 | "url = \"https://api.pbpstats.com/get-league-year-over-year-plots/nba\"\n", 69 | "params = {\n", 70 | " \"SeasonType\": \"Regular Season\",\n", 71 | " \"LeftAxis\": \"PtsPer100Poss\",\n", 72 | " \"RightAxis\": \"SecondsPerPoss\"\n", 73 | "}\n", 74 | "response = requests.get(url, params=params)\n", 75 | "response_json = response.json()\n", 76 | "response_json['results']" 77 | ] 78 | }, 79 | { 80 | "cell_type": "markdown", 81 | "id": "d8e44cf9-e32e-4f80-b540-1fcad004a760", 82 | "metadata": {}, 83 | "source": [ 84 | "### WNBA Points per 100 possessions and seconds per 100 possessions" 85 | ] 86 | }, 87 | { 88 | "cell_type": "code", 89 | "execution_count": 3, 90 | "id": "217a65b1-a9dd-4ff8-85df-0f0a97e3815a", 91 | "metadata": {}, 92 | "outputs": [ 93 | { 94 | "data": { 95 | "text/plain": [ 96 | "[{'season': '2009', 'left_value': 99.718, 'right_value': 15.541},\n", 97 | " {'season': '2010', 'left_value': 101.799, 'right_value': 15.367},\n", 98 | " {'season': '2011', 'left_value': 100.191, 'right_value': 15.679},\n", 99 | " {'season': '2012', 'left_value': 100.051, 'right_value': 15.628},\n", 100 | " {'season': '2013', 'left_value': 98.459, 'right_value': 15.743},\n", 101 | " {'season': '2014', 'left_value': 100.201, 'right_value': 15.835},\n", 102 | " {'season': '2015', 'left_value': 99.105, 'right_value': 15.963},\n", 103 | " {'season': '2016', 'left_value': 104.192, 'right_value': 15.508},\n", 104 | " {'season': '2017', 'left_value': 103.491, 'right_value': 15.393},\n", 105 | " {'season': '2018', 'left_value': 104.742, 'right_value': 15.245},\n", 106 | " {'season': '2019', 'left_value': 100.222, 'right_value': 15.328},\n", 107 | " {'season': '2020', 'left_value': 103.512, 'right_value': 15.011},\n", 108 | " {'season': '2021', 'left_value': 101.798, 'right_value': 15.233},\n", 109 | " {'season': '2022', 'left_value': 101.746, 'right_value': 15.067}]" 110 | ] 111 | }, 112 | "execution_count": 3, 113 | "metadata": {}, 114 | "output_type": "execute_result" 115 | } 116 | ], 117 | "source": [ 118 | "url = \"https://api.pbpstats.com/get-league-year-over-year-plots/wnba\"\n", 119 | "params = {\n", 120 | " \"SeasonType\": \"Regular Season\",\n", 121 | " \"LeftAxis\": \"PtsPer100Poss\",\n", 122 | " \"RightAxis\": \"SecondsPerPoss\"\n", 123 | "}\n", 124 | "response = requests.get(url, params=params)\n", 125 | "response_json = response.json()\n", 126 | "response_json['results']" 127 | ] 128 | }, 129 | { 130 | "cell_type": "markdown", 131 | "id": "1b9e66a7-c6dc-415d-aac0-74c72ca33632", 132 | "metadata": {}, 133 | "source": [ 134 | "#### Available stat key options" 135 | ] 136 | }, 137 | { 138 | "cell_type": "code", 139 | "execution_count": 4, 140 | "id": "ecac6f85-c9da-48f3-829f-dec5f95a02b9", 141 | "metadata": {}, 142 | "outputs": [], 143 | "source": [ 144 | "stat_keys = [\n", 145 | " \"PtsPer100Poss\", # Points Per 100 Possessions\n", 146 | " \"SecondsPerPoss\", # Seconds Per Possession\n", 147 | " \"FG3APct\", # 3 Point Rate\n", 148 | " \"Fg3Pct\", # 3pt %\n", 149 | " \"AtRimFrequency\", # At Rim Shot Frequency\n", 150 | " \"AtRimAccuracy\", # At Rim FG%\n", 151 | " \"AtRimPctAssisted\", # At Rim % Assisted\n", 152 | " \"ShortMidRangeFrequency\", # Short Mid Range Shot Frequency\n", 153 | " \"ShortMidRangeAccuracy\", # Short Mid Range FG%\n", 154 | " \"ShortMidRangePctAssisted\", # Short Mid Range % Assisted\n", 155 | " \"LongMidRangeFrequency\", # Long Mid Range Shot Frequency\n", 156 | " \"LongMidRangeAccuracy\", # Long Mid Range FG%\n", 157 | " \"LongMidRangePctAssisted\", # Long Mid % Assisted\n", 158 | " \"Corner3Frequency\", # Corner 3 Shot Frequency\n", 159 | " \"Corner3Accuracy\", # Corner 3 FG%\n", 160 | " \"Corner3PctAssisted\", # Corner 3 % Assisted\n", 161 | " \"Arc3Frequency\", # Above The Break 3 Shot Frequency\n", 162 | " \"Arc3Accuracy\", # Above The Break 3 FG%\n", 163 | " \"Arc3PctAssisted\", # Above The Break 3 % Assisted\n", 164 | " \"LiveBallTurnoverPct\", # Live Ball TO%\n", 165 | " \"EfgPct\", # eFG%\n", 166 | " \"DefFTReboundPct\", # DReb% - Missed FTs\n", 167 | " \"OffFTReboundPct\", # OReb% - Missed FTs\n", 168 | " \"DefTwoPtReboundPct\", # DReb% - Missed 2s\n", 169 | " \"OffTwoPtReboundPct\", # OReb% - Missed 2s\n", 170 | " \"DefThreePtReboundPct\", # DReb% - Missed 3s\n", 171 | " \"OffThreePtReboundPct\", # OReb% - Missed 3s\n", 172 | " \"DefFGReboundPct\", # DReb% - Missed FGs\n", 173 | " \"OffFGReboundPct\", # OReb% - Missed FGs\n", 174 | " \"OffAtRimReboundPct\", # At Rim OReb%\n", 175 | " \"OffShortMidRangeReboundPct\", # Short Mid-Range OReb%\n", 176 | " \"OffLongMidRangeReboundPct\", # Long Mid-Range OReb%\n", 177 | " \"OffArc3ReboundPct\", # Arc 3 OReb%\n", 178 | " \"OffCorner3ReboundPct\", # Corner 3 OReb%\n", 179 | " \"DefAtRimReboundPct\", # At Rim DReb%\n", 180 | " \"DefShortMidRangeReboundPct\", # Short Mid-Range DReb%\n", 181 | " \"DefLongMidRangeReboundPct\", # Long Mid-Range DReb%\n", 182 | " \"DefArc3ReboundPct\", # Arc 3 DReb%\n", 183 | " \"DefCorner3ReboundPct\", # Corner 3 DReb%\n", 184 | " \"SecondChancePtsPer100PossSecondChance\", # Second Chance Efficiency\n", 185 | " \"PenaltyPtsPer100PossPenalty\", # Penalty Efficiency\n", 186 | " \"SecondChanceOffPossPer100Poss\", # Second Chance Possessions Per 100 Possessions\n", 187 | " \"FirstChancePtsPer100Poss\", # First Chance Points Per 100 Possessions\n", 188 | " \"SecondChancePtsPer100Poss\", # Second Chance Points Per 100 Possessions\n", 189 | " \"PenaltyOffPossPer100Poss\", # Penalty Possessions Per 100 Possessions\n", 190 | " \"Avg2ptShotDistance\", # Avg 2pt Shot Distance\n", 191 | " \"Avg3ptShotDistance\" # Avg 3pt Shot Distance \n", 192 | "]" 193 | ] 194 | }, 195 | { 196 | "cell_type": "code", 197 | "execution_count": null, 198 | "id": "6f0b7c14-8b55-47b8-ae53-bf4c6c772b4a", 199 | "metadata": {}, 200 | "outputs": [], 201 | "source": [] 202 | } 203 | ], 204 | "metadata": { 205 | "kernelspec": { 206 | "display_name": "playground", 207 | "language": "python", 208 | "name": "playground" 209 | }, 210 | "language_info": { 211 | "codemirror_mode": { 212 | "name": "ipython", 213 | "version": 3 214 | }, 215 | "file_extension": ".py", 216 | "mimetype": "text/x-python", 217 | "name": "python", 218 | "nbconvert_exporter": "python", 219 | "pygments_lexer": "ipython3", 220 | "version": "3.8.9" 221 | } 222 | }, 223 | "nbformat": 4, 224 | "nbformat_minor": 5 225 | } 226 | -------------------------------------------------------------------------------- /get-leverage.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "id": "aaec7154-db85-477b-bcc6-661ac08c60bd", 6 | "metadata": {}, 7 | "source": [ 8 | "This endpoint can be used to get the leverage for a given conditions" 9 | ] 10 | }, 11 | { 12 | "cell_type": "code", 13 | "execution_count": 1, 14 | "id": "191e75da-11e7-43f3-b787-6f708fb63933", 15 | "metadata": {}, 16 | "outputs": [], 17 | "source": [ 18 | "import requests" 19 | ] 20 | }, 21 | { 22 | "cell_type": "markdown", 23 | "id": "8677acbf-39e6-4a4f-94ce-e97dc56d110e", 24 | "metadata": {}, 25 | "source": [ 26 | "### NBA - Down 5, with the ball, possession starting with 60 seconds left and ending with 45 seconds left, and a 55% pregame win probability" 27 | ] 28 | }, 29 | { 30 | "cell_type": "code", 31 | "execution_count": 2, 32 | "id": "bde0882a-58c7-426d-bc8e-cde73db20756", 33 | "metadata": {}, 34 | "outputs": [ 35 | { 36 | "data": { 37 | "text/plain": [ 38 | "{'leverage': 0.06444948202563708}" 39 | ] 40 | }, 41 | "execution_count": 2, 42 | "metadata": {}, 43 | "output_type": "execute_result" 44 | } 45 | ], 46 | "source": [ 47 | "league = \"nba\"\n", 48 | "margin = -5 # from the perspective of the team with the ball\n", 49 | "seconds_remaining = 60 # This is time remaining at the start of the possession\n", 50 | "pre_game_win_prob = 0.55 # 55% to win pregame\n", 51 | "end_of_possession_seconds_remaining = 45 # seconds remaining at end of possession\n", 52 | "\n", 53 | "url = f\"https://api.pbpstats.com/get-leverage/{league}/{margin}/{pre_game_win_prob}/{seconds_remaining}/{end_of_possession_seconds_remaining}\"\n", 54 | "\n", 55 | "response = requests.get(url)\n", 56 | "response_json = response.json()\n", 57 | "response_json" 58 | ] 59 | }, 60 | { 61 | "cell_type": "code", 62 | "execution_count": null, 63 | "id": "3f182dde-414b-4211-93c5-4e2591e56543", 64 | "metadata": {}, 65 | "outputs": [], 66 | "source": [] 67 | } 68 | ], 69 | "metadata": { 70 | "kernelspec": { 71 | "display_name": "playground", 72 | "language": "python", 73 | "name": "playground" 74 | }, 75 | "language_info": { 76 | "codemirror_mode": { 77 | "name": "ipython", 78 | "version": 3 79 | }, 80 | "file_extension": ".py", 81 | "mimetype": "text/x-python", 82 | "name": "python", 83 | "nbconvert_exporter": "python", 84 | "pygments_lexer": "ipython3", 85 | "version": "3.8.9" 86 | } 87 | }, 88 | "nbformat": 4, 89 | "nbformat_minor": 5 90 | } 91 | -------------------------------------------------------------------------------- /get-lineup-opponent-summary.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "id": "bcc4726e-f805-457e-9e9b-2f815d5899cc", 6 | "metadata": {}, 7 | "source": [ 8 | "This endpoint can be used to get lineup stats vs each lineup they have faced" 9 | ] 10 | }, 11 | { 12 | "cell_type": "code", 13 | "execution_count": 1, 14 | "id": "8124e0f7-dabe-41a7-a4da-9545599595d7", 15 | "metadata": {}, 16 | "outputs": [], 17 | "source": [ 18 | "import requests" 19 | ] 20 | }, 21 | { 22 | "cell_type": "markdown", 23 | "id": "f4c391b1-64ca-4a69-bae0-357a53677b55", 24 | "metadata": {}, 25 | "source": [ 26 | "### Al Horford, Marcus Smart, Jaylen Brown, Jayson Tatum, Robert Williams III" 27 | ] 28 | }, 29 | { 30 | "cell_type": "code", 31 | "execution_count": 2, 32 | "id": "937cb87e-4010-4996-a2dc-76e1f0a28b4a", 33 | "metadata": {}, 34 | "outputs": [ 35 | { 36 | "data": { 37 | "text/plain": [ 38 | "{'dreb_pct': 0.681818181818182,\n", 39 | " 'drebs': 15,\n", 40 | " 'drtg': 102.127659574468,\n", 41 | " 'efg': 0.520408163265306,\n", 42 | " 'fg2a': 31,\n", 43 | " 'fg2m': 18,\n", 44 | " 'fg2pct': 0.580645161290323,\n", 45 | " 'fg3a': 18,\n", 46 | " 'fg3m': 5,\n", 47 | " 'fg3pct': 0.277777777777778,\n", 48 | " 'ftr': 0.102040816326531,\n", 49 | " 'lineup': 'Terry Rozier, Miles Bridges, P.J. Washington, LaMelo Ball, Mason Plumlee',\n", 50 | " 'lineup_id': '1626179-1628970-1629023-1630163-203486',\n", 51 | " 'minutes': '23:36',\n", 52 | " 'net_rtg': 10.3723404255319,\n", 53 | " 'opp_efg': 0.55,\n", 54 | " 'opp_fg2a': 19,\n", 55 | " 'opp_fg2m': 10,\n", 56 | " 'opp_fg2pct': 0.526315789473684,\n", 57 | " 'opp_fg3a': 21,\n", 58 | " 'opp_fg3m': 8,\n", 59 | " 'opp_fg3pct': 0.380952380952381,\n", 60 | " 'opp_ftr': 0.15,\n", 61 | " 'opp_tov_pct': 0.234042553191489,\n", 62 | " 'opp_turnovers': 11,\n", 63 | " 'oreb_pct': 0.307692307692308,\n", 64 | " 'orebs': 8,\n", 65 | " 'ortg': 112.5,\n", 66 | " 'plus_minus': 6,\n", 67 | " 'pts_against': 48,\n", 68 | " 'pts_for': 54,\n", 69 | " 'seconds_played': 1416,\n", 70 | " 'team': 'CHA',\n", 71 | " 'total_possessions': 95,\n", 72 | " 'tov_pct': 0.104166666666667,\n", 73 | " 'turnovers': 5}" 74 | ] 75 | }, 76 | "execution_count": 2, 77 | "metadata": {}, 78 | "output_type": "execute_result" 79 | } 80 | ], 81 | "source": [ 82 | "url = \"https://api.pbpstats.com/get-lineup-opponent-summary/nba\"\n", 83 | "params = {\n", 84 | " \"LineupId\": \"1627759-1628369-1629057-201143-203935\", # lineup ids are hyphen separated player ids sorted as strings\n", 85 | " \"TeamId\": \"1610612738\",\n", 86 | " \"Season\": \"2021-22\",\n", 87 | " \"SeasonType\": \"Regular Season\"\n", 88 | "}\n", 89 | "response = requests.get(url, params=params)\n", 90 | "response_json = response.json()\n", 91 | "response_json['results'][0]" 92 | ] 93 | }, 94 | { 95 | "cell_type": "markdown", 96 | "id": "46af7966-2a7d-4f0d-bc9e-4bd8f54adaf9", 97 | "metadata": {}, 98 | "source": [ 99 | "### Chelsea Gray, Dearica Hamby, Kelsey Plum, A'ja Wilson, Jackie Young" 100 | ] 101 | }, 102 | { 103 | "cell_type": "code", 104 | "execution_count": 3, 105 | "id": "074ddf28-f4be-433c-a4c5-376ed967a2f2", 106 | "metadata": {}, 107 | "outputs": [ 108 | { 109 | "data": { 110 | "text/plain": [ 111 | "{'dreb_pct': 0.5625,\n", 112 | " 'drebs': 9,\n", 113 | " 'drtg': 132.142857142857,\n", 114 | " 'efg': 0.761904761904762,\n", 115 | " 'fg2a': 14,\n", 116 | " 'fg2m': 10,\n", 117 | " 'fg2pct': 0.714285714285714,\n", 118 | " 'fg3a': 7,\n", 119 | " 'fg3m': 4,\n", 120 | " 'fg3pct': 0.571428571428571,\n", 121 | " 'ftr': 0.571428571428571,\n", 122 | " 'lineup': 'Moriah Jefferson, Aerial Powers, Jessica Shepard, Sylvia Fowles, Kayla McBride',\n", 123 | " 'lineup_id': '1627669-1627672-1629491-201480-203825',\n", 124 | " 'minutes': '15:42',\n", 125 | " 'net_rtg': -2.14285714285714,\n", 126 | " 'opp_efg': 0.46551724137931,\n", 127 | " 'opp_fg2a': 23,\n", 128 | " 'opp_fg2m': 12,\n", 129 | " 'opp_fg2pct': 0.521739130434783,\n", 130 | " 'opp_fg3a': 6,\n", 131 | " 'opp_fg3m': 1,\n", 132 | " 'opp_fg3pct': 0.166666666666667,\n", 133 | " 'opp_ftr': 0.379310344827586,\n", 134 | " 'opp_tov_pct': 0.0357142857142857,\n", 135 | " 'opp_turnovers': 1,\n", 136 | " 'oreb_pct': 0.285714285714286,\n", 137 | " 'orebs': 2,\n", 138 | " 'ortg': 130.0,\n", 139 | " 'plus_minus': 2,\n", 140 | " 'pts_against': 37,\n", 141 | " 'pts_for': 39,\n", 142 | " 'seconds_played': 942,\n", 143 | " 'team': 'MIN',\n", 144 | " 'total_possessions': 58,\n", 145 | " 'tov_pct': 0.133333333333333,\n", 146 | " 'turnovers': 4}" 147 | ] 148 | }, 149 | "execution_count": 3, 150 | "metadata": {}, 151 | "output_type": "execute_result" 152 | } 153 | ], 154 | "source": [ 155 | "url = \"https://api.pbpstats.com/get-lineup-opponent-summary/wnba\"\n", 156 | "params = {\n", 157 | " \"LineupId\": \"1628276-1628932-1629498-203833-204324\", # lineup ids are hyphen separated player ids sorted as strings\n", 158 | " \"TeamId\": \"1611661319\",\n", 159 | " \"Season\": \"2022\",\n", 160 | " \"SeasonType\": \"Regular Season\"\n", 161 | "}\n", 162 | "response = requests.get(url, params=params)\n", 163 | "response_json = response.json()\n", 164 | "response_json['results'][0]" 165 | ] 166 | }, 167 | { 168 | "cell_type": "code", 169 | "execution_count": null, 170 | "id": "254e6902-fbcc-4b27-abf2-fdc08ad743cb", 171 | "metadata": {}, 172 | "outputs": [], 173 | "source": [] 174 | } 175 | ], 176 | "metadata": { 177 | "kernelspec": { 178 | "display_name": "playground", 179 | "language": "python", 180 | "name": "playground" 181 | }, 182 | "language_info": { 183 | "codemirror_mode": { 184 | "name": "ipython", 185 | "version": 3 186 | }, 187 | "file_extension": ".py", 188 | "mimetype": "text/x-python", 189 | "name": "python", 190 | "nbconvert_exporter": "python", 191 | "pygments_lexer": "ipython3", 192 | "version": "3.8.9" 193 | } 194 | }, 195 | "nbformat": 4, 196 | "nbformat_minor": 5 197 | } 198 | -------------------------------------------------------------------------------- /get-lineup-player-stats.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "id": "8d71414e-cfcc-452d-ab37-2d8b9c0626c0", 6 | "metadata": {}, 7 | "source": [ 8 | "This endpoint can be used to get player stats when a specific lineup is on the floor" 9 | ] 10 | }, 11 | { 12 | "cell_type": "code", 13 | "execution_count": 1, 14 | "id": "9500d34c-885f-451b-b920-32f24a7bb1b3", 15 | "metadata": {}, 16 | "outputs": [], 17 | "source": [ 18 | "import requests" 19 | ] 20 | }, 21 | { 22 | "cell_type": "markdown", 23 | "id": "21901369-4404-43eb-a8f5-4289508166ac", 24 | "metadata": {}, 25 | "source": [ 26 | "### Al Horford, Marcus Smart, Jaylen Brown, Jayson Tatum, Robert Williams III" 27 | ] 28 | }, 29 | { 30 | "cell_type": "code", 31 | "execution_count": 2, 32 | "id": "7853d472-79c4-4612-8244-871519b82a66", 33 | "metadata": {}, 34 | "outputs": [], 35 | "source": [ 36 | "url = \"https://api.pbpstats.com/get-lineup-player-stats/nba\"\n", 37 | "params = {\n", 38 | " \"LineupId\": \"1627759-1628369-1629057-201143-203935\", # lineup ids are hyphen separated player ids sorted as strings\n", 39 | " \"Season\": \"2021-22\",\n", 40 | " \"SeasonType\": \"Regular Season\"\n", 41 | "}\n", 42 | "response = requests.get(url, params=params)\n", 43 | "response_json = response.json()\n", 44 | "lineup_stats = response_json['single_row_table_data']\n", 45 | "player_stats = response_json['multi_row_table_data']" 46 | ] 47 | }, 48 | { 49 | "cell_type": "markdown", 50 | "id": "d57e866d-7aa5-4c63-b315-04ee59744054", 51 | "metadata": {}, 52 | "source": [ 53 | "### Chelsea Gray, Dearica Hamby, Kelsey Plum, A'ja Wilson, Jackie Young" 54 | ] 55 | }, 56 | { 57 | "cell_type": "code", 58 | "execution_count": 3, 59 | "id": "f6b15960-9f55-405b-acb8-bbf46e255333", 60 | "metadata": {}, 61 | "outputs": [], 62 | "source": [ 63 | "url = \"https://api.pbpstats.com/get-lineup-player-stats/wnba\"\n", 64 | "params = {\n", 65 | " \"LineupId\": \"1628276-1628932-1629498-203833-204324\", # lineup ids are hyphen separated player ids sorted as strings\n", 66 | " \"Season\": \"2022\",\n", 67 | " \"SeasonType\": \"Regular Season\"\n", 68 | "}\n", 69 | "response = requests.get(url, params=params)\n", 70 | "response_json = response.json()\n", 71 | "lineup_stats = response_json['single_row_table_data']\n", 72 | "player_stats = response_json['multi_row_table_data']" 73 | ] 74 | }, 75 | { 76 | "cell_type": "code", 77 | "execution_count": null, 78 | "id": "368d3495-d9c4-4029-9f7d-0b92766fb5e9", 79 | "metadata": {}, 80 | "outputs": [], 81 | "source": [] 82 | } 83 | ], 84 | "metadata": { 85 | "kernelspec": { 86 | "display_name": "playground", 87 | "language": "python", 88 | "name": "playground" 89 | }, 90 | "language_info": { 91 | "codemirror_mode": { 92 | "name": "ipython", 93 | "version": 3 94 | }, 95 | "file_extension": ".py", 96 | "mimetype": "text/x-python", 97 | "name": "python", 98 | "nbconvert_exporter": "python", 99 | "pygments_lexer": "ipython3", 100 | "version": "3.8.9" 101 | } 102 | }, 103 | "nbformat": 4, 104 | "nbformat_minor": 5 105 | } 106 | -------------------------------------------------------------------------------- /get-lineup-subunit-stats.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "id": "a23742ea-2afb-4eca-a873-d91924293bd7", 6 | "metadata": {}, 7 | "source": [ 8 | "This endpoint can be used to get stats for all sub units of 2, 3 or 4 players of a 5 player lineup" 9 | ] 10 | }, 11 | { 12 | "cell_type": "code", 13 | "execution_count": 1, 14 | "id": "75f143b2-1ca2-459a-9106-708e7ff598c1", 15 | "metadata": {}, 16 | "outputs": [], 17 | "source": [ 18 | "import requests" 19 | ] 20 | }, 21 | { 22 | "cell_type": "markdown", 23 | "id": "79569764-cdc7-4e09-9cf5-697dd63027ab", 24 | "metadata": {}, 25 | "source": [ 26 | "### Al Horford, Marcus Smart, Jaylen Brown, Jayson Tatum, Robert Williams III - sub unit size = 3" 27 | ] 28 | }, 29 | { 30 | "cell_type": "code", 31 | "execution_count": 2, 32 | "id": "27cf8d1a-1366-48bf-aec8-ac3d102f4426", 33 | "metadata": {}, 34 | "outputs": [ 35 | { 36 | "data": { 37 | "text/plain": [ 38 | "{'OffRtg': 120.84842214174857,\n", 39 | " 'DefRtg': 101.30821559392987,\n", 40 | " 'NetRtg': 19.5402065478187,\n", 41 | " 'Minutes': 959.0,\n", 42 | " 'On': 'Jaylen Brown, Jayson Tatum, Robert Williams III',\n", 43 | " 'Off': '',\n", 44 | " 'TeamWowyQueryParams': {'Season': '2021-22',\n", 45 | " 'SeasonType': 'Regular Season',\n", 46 | " 'TeamId': '1610612738',\n", 47 | " 'Type': 'Team',\n", 48 | " '0Exactly3OnFloor': '1627759,1628369,1629057'},\n", 49 | " 'OpponentWowyQueryParams': {'Season': '2021-22',\n", 50 | " 'SeasonType': 'Regular Season',\n", 51 | " 'TeamId': '1610612738',\n", 52 | " 'Type': 'Opponent',\n", 53 | " '0Exactly3OnFloor': '1627759,1628369,1629057'},\n", 54 | " 'RowId': 'On:1627759,1628369,1629057',\n", 55 | " 'Fg3Pct': 0.37551581843191195,\n", 56 | " 'Fg2Pct': 0.5853658536585366,\n", 57 | " 'OppFg3Pct': 0.3129973474801061,\n", 58 | " 'OppFg2Pct': 0.46948818897637795}" 59 | ] 60 | }, 61 | "execution_count": 2, 62 | "metadata": {}, 63 | "output_type": "execute_result" 64 | } 65 | ], 66 | "source": [ 67 | "url = \"https://api.pbpstats.com/get-lineup-subunit-stats/nba\"\n", 68 | "params = {\n", 69 | " \"LineupId\": \"1627759-1628369-1629057-201143-203935\", # lineup ids are hyphen separated player ids sorted as strings\n", 70 | " \"TeamId\": \"1610612738\",\n", 71 | " \"Season\": \"2021-22\",\n", 72 | " \"SeasonType\": \"Regular Season\",\n", 73 | " \"SubUnitSize\": 3\n", 74 | "}\n", 75 | "response = requests.get(url, params=params)\n", 76 | "response_json = response.json()\n", 77 | "response_json['results'][0]" 78 | ] 79 | }, 80 | { 81 | "cell_type": "markdown", 82 | "id": "36c8b585-6b4c-466d-b834-0dcbce667d61", 83 | "metadata": {}, 84 | "source": [ 85 | "### Chelsea Gray, Dearica Hamby, Kelsey Plum, A'ja Wilson, Jackie Young - sub unit size = 2" 86 | ] 87 | }, 88 | { 89 | "cell_type": "code", 90 | "execution_count": 3, 91 | "id": "4ca0f586-2a47-4fe0-aee5-b4e929d85f85", 92 | "metadata": {}, 93 | "outputs": [ 94 | { 95 | "data": { 96 | "text/plain": [ 97 | "{'OffRtg': 117.30337078651685,\n", 98 | " 'DefRtg': 94.34389140271493,\n", 99 | " 'NetRtg': 22.95947938380192,\n", 100 | " 'Minutes': 216.0,\n", 101 | " 'On': \"Kelsey Plum, A'ja Wilson\",\n", 102 | " 'Off': '',\n", 103 | " 'TeamWowyQueryParams': {'Season': '2022',\n", 104 | " 'SeasonType': 'Regular Season',\n", 105 | " 'TeamId': '1611661319',\n", 106 | " 'Type': 'Team',\n", 107 | " '0Exactly2OnFloor': '1628276,1628932'},\n", 108 | " 'OpponentWowyQueryParams': {'Season': '2022',\n", 109 | " 'SeasonType': 'Regular Season',\n", 110 | " 'TeamId': '1611661319',\n", 111 | " 'Type': 'Opponent',\n", 112 | " '0Exactly2OnFloor': '1628276,1628932'},\n", 113 | " 'RowId': 'On:1628276,1628932',\n", 114 | " 'Fg3Pct': 0.47368421052631576,\n", 115 | " 'Fg2Pct': 0.5371900826446281,\n", 116 | " 'OppFg3Pct': 0.3,\n", 117 | " 'OppFg2Pct': 0.46987951807228917}" 118 | ] 119 | }, 120 | "execution_count": 3, 121 | "metadata": {}, 122 | "output_type": "execute_result" 123 | } 124 | ], 125 | "source": [ 126 | "url = \"https://api.pbpstats.com/get-lineup-subunit-stats/wnba\"\n", 127 | "params = {\n", 128 | " \"LineupId\": \"1628276-1628932-1629498-203833-204324\", # lineup ids are hyphen separated player ids sorted as strings\n", 129 | " \"TeamId\": \"1611661319\",\n", 130 | " \"Season\": \"2022\",\n", 131 | " \"SeasonType\": \"Regular Season\",\n", 132 | " \"SubUnitSize\": 2\n", 133 | "}\n", 134 | "response = requests.get(url, params=params)\n", 135 | "response_json = response.json()\n", 136 | "response_json['results'][0]" 137 | ] 138 | }, 139 | { 140 | "cell_type": "code", 141 | "execution_count": null, 142 | "id": "2f74a94a-2215-4347-a4d6-b182425a1da0", 143 | "metadata": {}, 144 | "outputs": [], 145 | "source": [] 146 | } 147 | ], 148 | "metadata": { 149 | "kernelspec": { 150 | "display_name": "playground", 151 | "language": "python", 152 | "name": "playground" 153 | }, 154 | "language_info": { 155 | "codemirror_mode": { 156 | "name": "ipython", 157 | "version": 3 158 | }, 159 | "file_extension": ".py", 160 | "mimetype": "text/x-python", 161 | "name": "python", 162 | "nbconvert_exporter": "python", 163 | "pygments_lexer": "ipython3", 164 | "version": "3.8.9" 165 | } 166 | }, 167 | "nbformat": 4, 168 | "nbformat_minor": 5 169 | } 170 | -------------------------------------------------------------------------------- /get-pace-efficiency-by-season.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "id": "d3429512-af4b-489f-816c-67c43b5b1c68", 6 | "metadata": {}, 7 | "source": [ 8 | "This endpoint can be used to get the league average pace (seconds per possession) and efficiency (points per possession) for each season broken down by how the possession started" 9 | ] 10 | }, 11 | { 12 | "cell_type": "code", 13 | "execution_count": 1, 14 | "id": "178fecdc-adb1-4635-8ec8-3894c9a431f0", 15 | "metadata": {}, 16 | "outputs": [], 17 | "source": [ 18 | "import requests" 19 | ] 20 | }, 21 | { 22 | "cell_type": "markdown", 23 | "id": "daac6ac3-7204-41d9-af53-4067bdfb521c", 24 | "metadata": {}, 25 | "source": [ 26 | "### NBA" 27 | ] 28 | }, 29 | { 30 | "cell_type": "code", 31 | "execution_count": 2, 32 | "id": "71c4d959-173b-4a60-9ec2-de56ca1e91d7", 33 | "metadata": {}, 34 | "outputs": [ 35 | { 36 | "data": { 37 | "text/plain": [ 38 | "{'AllOffPoss': 237691,\n", 39 | " 'AllPoints': 259753,\n", 40 | " 'AllPointsPerPoss': 1.0928179863772713,\n", 41 | " 'AllSeconds': 3566400,\n", 42 | " 'AllSecondsPerPoss': 15.004354392888246,\n", 43 | " 'OffArc3MissOffPoss': 21862,\n", 44 | " 'OffArc3MissPoints': 23975,\n", 45 | " 'OffArc3MissPointsPerPoss': 1.0966517244533895,\n", 46 | " 'OffArc3MissSeconds': 274563,\n", 47 | " 'OffArc3MissSecondsPerPoss': 12.558915012350196,\n", 48 | " 'OffAtRimMissOffPoss': 10533,\n", 49 | " 'OffAtRimMissPoints': 11893,\n", 50 | " 'OffAtRimMissPointsPerPoss': 1.1291180100636096,\n", 51 | " 'OffAtRimMissSeconds': 113036,\n", 52 | " 'OffAtRimMissSecondsPerPoss': 10.7316054305516,\n", 53 | " 'OffCorner3MissOffPoss': 6529,\n", 54 | " 'OffCorner3MissPoints': 7356,\n", 55 | " 'OffCorner3MissPointsPerPoss': 1.126665645581253,\n", 56 | " 'OffCorner3MissSeconds': 80388,\n", 57 | " 'OffCorner3MissSecondsPerPoss': 12.312452136621229,\n", 58 | " 'OffDeadballOffPoss': 23516,\n", 59 | " 'OffDeadballPoints': 24838,\n", 60 | " 'OffDeadballPointsPerPoss': 1.0562170437149174,\n", 61 | " 'OffDeadballSeconds': 379034,\n", 62 | " 'OffDeadballSecondsPerPoss': 16.118132335431195,\n", 63 | " 'OffFTMakeOffPoss': 20974,\n", 64 | " 'OffFTMakePoints': 22087,\n", 65 | " 'OffFTMakePointsPerPoss': 1.0530657003909603,\n", 66 | " 'OffFTMakeSeconds': 340410,\n", 67 | " 'OffFTMakeSecondsPerPoss': 16.230094402593686,\n", 68 | " 'OffFTMissOffPoss': 5246,\n", 69 | " 'OffFTMissPoints': 5635,\n", 70 | " 'OffFTMissPointsPerPoss': 1.0741517346549752,\n", 71 | " 'OffFTMissSeconds': 85231,\n", 72 | " 'OffFTMissSecondsPerPoss': 16.246854746473502,\n", 73 | " 'OffLiveBallTurnoverOffPoss': 18361,\n", 74 | " 'OffLiveBallTurnoverPoints': 23229,\n", 75 | " 'OffLiveBallTurnoverPointsPerPoss': 1.265127171722673,\n", 76 | " 'OffLiveBallTurnoverSeconds': 170739,\n", 77 | " 'OffLiveBallTurnoverSecondsPerPoss': 9.299003322259136,\n", 78 | " 'OffMadeFGOffPoss': 80046,\n", 79 | " 'OffMadeFGPoints': 85466,\n", 80 | " 'OffMadeFGPointsPerPoss': 1.0677110661369713,\n", 81 | " 'OffMadeFGSeconds': 1434374,\n", 82 | " 'OffMadeFGSecondsPerPoss': 17.919371361467157,\n", 83 | " 'OffMidRangeMissOffPoss': 29074,\n", 84 | " 'OffMidRangeMissPoints': 31907,\n", 85 | " 'OffMidRangeMissPointsPerPoss': 1.0974410125885672,\n", 86 | " 'OffMidRangeMissSeconds': 357014,\n", 87 | " 'OffMidRangeMissSecondsPerPoss': 12.279493705716447,\n", 88 | " 'OffMissed2OffPoss': 39607,\n", 89 | " 'OffMissed2Points': 43800,\n", 90 | " 'OffMissed2PointsPerPoss': 1.1058651248516675,\n", 91 | " 'OffMissed2Seconds': 470050,\n", 92 | " 'OffMissed2SecondsPerPoss': 11.867851642386446,\n", 93 | " 'OffMissed3OffPoss': 28391,\n", 94 | " 'OffMissed3Points': 31331,\n", 95 | " 'OffMissed3PointsPerPoss': 1.1035539431509986,\n", 96 | " 'OffMissed3Seconds': 354951,\n", 97 | " 'OffMissed3SecondsPerPoss': 12.502236624282343,\n", 98 | " 'OffMissedFGOffPoss': 67998,\n", 99 | " 'OffMissedFGPoints': 75131,\n", 100 | " 'OffMissedFGPointsPerPoss': 1.104900144121886,\n", 101 | " 'OffMissedFGSeconds': 825001,\n", 102 | " 'OffMissedFGSecondsPerPoss': 12.13272449189682,\n", 103 | " 'OffTimeoutOffPoss': 15582,\n", 104 | " 'OffTimeoutPoints': 16325,\n", 105 | " 'OffTimeoutPointsPerPoss': 1.0476832242330896,\n", 106 | " 'OffTimeoutSeconds': 273984,\n", 107 | " 'OffTimeoutSecondsPerPoss': 17.583365421640355,\n", 108 | " 'season': '2016-17'}" 109 | ] 110 | }, 111 | "execution_count": 2, 112 | "metadata": {}, 113 | "output_type": "execute_result" 114 | } 115 | ], 116 | "source": [ 117 | "url = \"https://api.pbpstats.com/get-pace-efficiency-by-season/nba\"\n", 118 | "params = {\n", 119 | " \"SeasonType\": \"Regular Season\",\n", 120 | "}\n", 121 | "response = requests.get(url, params=params)\n", 122 | "response_json = response.json()\n", 123 | "response_json['results'][0]" 124 | ] 125 | }, 126 | { 127 | "cell_type": "markdown", 128 | "id": "5f267a19-9dc7-4fae-9ec4-a9fc4cbe2d4a", 129 | "metadata": {}, 130 | "source": [ 131 | "### WNBA" 132 | ] 133 | }, 134 | { 135 | "cell_type": "code", 136 | "execution_count": 3, 137 | "id": "6c3cb984-adf2-4e97-bce4-7e6806151a8a", 138 | "metadata": {}, 139 | "outputs": [ 140 | { 141 | "data": { 142 | "text/plain": [ 143 | "{'AllOffPoss': 21184,\n", 144 | " 'AllPoints': 21928,\n", 145 | " 'AllPointsPerPoss': 1.0351208459214503,\n", 146 | " 'AllSeconds': 318000,\n", 147 | " 'AllSecondsPerPoss': 15.011329305135952,\n", 148 | " 'OffArc3MissOffPoss': 1946,\n", 149 | " 'OffArc3MissPoints': 2038,\n", 150 | " 'OffArc3MissPointsPerPoss': 1.0472764645426516,\n", 151 | " 'OffArc3MissSeconds': 22488,\n", 152 | " 'OffArc3MissSecondsPerPoss': 11.55601233299075,\n", 153 | " 'OffAtRimMissOffPoss': 580,\n", 154 | " 'OffAtRimMissPoints': 622,\n", 155 | " 'OffAtRimMissPointsPerPoss': 1.0724137931034483,\n", 156 | " 'OffAtRimMissSeconds': 6268,\n", 157 | " 'OffAtRimMissSecondsPerPoss': 10.806896551724138,\n", 158 | " 'OffCorner3MissOffPoss': 307,\n", 159 | " 'OffCorner3MissPoints': 330,\n", 160 | " 'OffCorner3MissPointsPerPoss': 1.0749185667752443,\n", 161 | " 'OffCorner3MissSeconds': 3501,\n", 162 | " 'OffCorner3MissSecondsPerPoss': 11.403908794788274,\n", 163 | " 'OffDeadballOffPoss': 2700,\n", 164 | " 'OffDeadballPoints': 2640,\n", 165 | " 'OffDeadballPointsPerPoss': 0.9777777777777777,\n", 166 | " 'OffDeadballSeconds': 46645,\n", 167 | " 'OffDeadballSecondsPerPoss': 17.275925925925925,\n", 168 | " 'OffFTMakeOffPoss': 1970,\n", 169 | " 'OffFTMakePoints': 2044,\n", 170 | " 'OffFTMakePointsPerPoss': 1.0375634517766497,\n", 171 | " 'OffFTMakeSeconds': 34229,\n", 172 | " 'OffFTMakeSecondsPerPoss': 17.375126903553298,\n", 173 | " 'OffFTMissOffPoss': 333,\n", 174 | " 'OffFTMissPoints': 349,\n", 175 | " 'OffFTMissPointsPerPoss': 1.048048048048048,\n", 176 | " 'OffFTMissSeconds': 5083,\n", 177 | " 'OffFTMissSecondsPerPoss': 15.264264264264265,\n", 178 | " 'OffLiveBallTurnoverOffPoss': 1976,\n", 179 | " 'OffLiveBallTurnoverPoints': 2442,\n", 180 | " 'OffLiveBallTurnoverPointsPerPoss': 1.23582995951417,\n", 181 | " 'OffLiveBallTurnoverSeconds': 18478,\n", 182 | " 'OffLiveBallTurnoverSecondsPerPoss': 9.351214574898785,\n", 183 | " 'OffMadeFGOffPoss': 6781,\n", 184 | " 'OffMadeFGPoints': 6822,\n", 185 | " 'OffMadeFGPointsPerPoss': 1.0060463058545936,\n", 186 | " 'OffMadeFGSeconds': 122369,\n", 187 | " 'OffMadeFGSecondsPerPoss': 18.045863441970212,\n", 188 | " 'OffMidRangeMissOffPoss': 2960,\n", 189 | " 'OffMidRangeMissPoints': 2999,\n", 190 | " 'OffMidRangeMissPointsPerPoss': 1.0131756756756756,\n", 191 | " 'OffMidRangeMissSeconds': 32882,\n", 192 | " 'OffMidRangeMissSecondsPerPoss': 11.108783783783784,\n", 193 | " 'OffMissed2OffPoss': 3540,\n", 194 | " 'OffMissed2Points': 3621,\n", 195 | " 'OffMissed2PointsPerPoss': 1.0228813559322034,\n", 196 | " 'OffMissed2Seconds': 39150,\n", 197 | " 'OffMissed2SecondsPerPoss': 11.059322033898304,\n", 198 | " 'OffMissed3OffPoss': 2253,\n", 199 | " 'OffMissed3Points': 2368,\n", 200 | " 'OffMissed3PointsPerPoss': 1.0510430537061695,\n", 201 | " 'OffMissed3Seconds': 25989,\n", 202 | " 'OffMissed3SecondsPerPoss': 11.535286284953395,\n", 203 | " 'OffMissedFGOffPoss': 5793,\n", 204 | " 'OffMissedFGPoints': 5989,\n", 205 | " 'OffMissedFGPointsPerPoss': 1.0338339375107888,\n", 206 | " 'OffMissedFGSeconds': 65139,\n", 207 | " 'OffMissedFGSecondsPerPoss': 11.244432936302434,\n", 208 | " 'OffTimeoutOffPoss': 1214,\n", 209 | " 'OffTimeoutPoints': 1198,\n", 210 | " 'OffTimeoutPointsPerPoss': 0.9868204283360791,\n", 211 | " 'OffTimeoutSeconds': 22116,\n", 212 | " 'OffTimeoutSecondsPerPoss': 18.217462932454694,\n", 213 | " 'season': '2020'}" 214 | ] 215 | }, 216 | "execution_count": 3, 217 | "metadata": {}, 218 | "output_type": "execute_result" 219 | } 220 | ], 221 | "source": [ 222 | "url = \"https://api.pbpstats.com/get-pace-efficiency-by-season/wnba\"\n", 223 | "params = {\n", 224 | " \"SeasonType\": \"Regular Season\",\n", 225 | "}\n", 226 | "response = requests.get(url, params=params)\n", 227 | "response_json = response.json()\n", 228 | "response_json['results'][0]" 229 | ] 230 | }, 231 | { 232 | "cell_type": "code", 233 | "execution_count": null, 234 | "id": "d129d41a-b6b0-43de-ba12-f29d70139b82", 235 | "metadata": {}, 236 | "outputs": [], 237 | "source": [] 238 | } 239 | ], 240 | "metadata": { 241 | "kernelspec": { 242 | "display_name": "playground", 243 | "language": "python", 244 | "name": "playground" 245 | }, 246 | "language_info": { 247 | "codemirror_mode": { 248 | "name": "ipython", 249 | "version": 3 250 | }, 251 | "file_extension": ".py", 252 | "mimetype": "text/x-python", 253 | "name": "python", 254 | "nbconvert_exporter": "python", 255 | "pygments_lexer": "ipython3", 256 | "version": "3.8.9" 257 | } 258 | }, 259 | "nbformat": 4, 260 | "nbformat_minor": 5 261 | } 262 | -------------------------------------------------------------------------------- /get-pace-efficiency-summary.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "id": "f5c13c2c-d389-4239-9b1d-9c0c8a4f8ade", 6 | "metadata": {}, 7 | "source": [ 8 | "This endpoint can be used to get the pace (seconds per possession) and efficiency (points per possession) for each team broken down by how the possession started" 9 | ] 10 | }, 11 | { 12 | "cell_type": "code", 13 | "execution_count": 1, 14 | "id": "e1b859f5-6d11-4d27-acab-34ef83310dd4", 15 | "metadata": {}, 16 | "outputs": [], 17 | "source": [ 18 | "import requests" 19 | ] 20 | }, 21 | { 22 | "cell_type": "markdown", 23 | "id": "10373899-093f-4861-a9f8-66a56720081b", 24 | "metadata": {}, 25 | "source": [ 26 | "### NBA - Team" 27 | ] 28 | }, 29 | { 30 | "cell_type": "code", 31 | "execution_count": 2, 32 | "id": "25a0e7ce-1f2f-47f2-bf6a-c0800e750d44", 33 | "metadata": {}, 34 | "outputs": [ 35 | { 36 | "data": { 37 | "text/plain": [ 38 | "{'ppp': 1.16452698491836,\n", 39 | " 'ppp_off_deadball': 1.1491935483871,\n", 40 | " 'ppp_off_deadball_rank': 4,\n", 41 | " 'ppp_off_made_fg': 1.16974043715847,\n", 42 | " 'ppp_off_made_fg_rank': 1,\n", 43 | " 'ppp_off_made_ft': 1.06750392464678,\n", 44 | " 'ppp_off_made_ft_rank': 21,\n", 45 | " 'ppp_off_midrange_miss': 1.2334581772784,\n", 46 | " 'ppp_off_midrange_miss_rank': 1,\n", 47 | " 'ppp_off_missed3': 1.11212814645309,\n", 48 | " 'ppp_off_missed3_rank': 22,\n", 49 | " 'ppp_off_missed_fg': 1.16776699029126,\n", 50 | " 'ppp_off_missed_fg_rank': 12,\n", 51 | " 'ppp_off_missed_ft': 1.14788732394366,\n", 52 | " 'ppp_off_missed_ft_rank': 10,\n", 53 | " 'ppp_off_rim_miss': 1.19243986254296,\n", 54 | " 'ppp_off_rim_miss_rank': 15,\n", 55 | " 'ppp_off_steal': 1.33275261324042,\n", 56 | " 'ppp_off_steal_rank': 8,\n", 57 | " 'ppp_off_timeout': 1.05910165484634,\n", 58 | " 'ppp_off_timeout_rank': 22,\n", 59 | " 'ppp_rank': 2,\n", 60 | " 'spp': 14.7681665212514,\n", 61 | " 'spp_off_deadball': 15.6048387096774,\n", 62 | " 'spp_off_deadball_rank': 5,\n", 63 | " 'spp_off_made_fg': 17.7042349726776,\n", 64 | " 'spp_off_made_fg_rank': 11,\n", 65 | " 'spp_off_made_ft': 16.7331240188383,\n", 66 | " 'spp_off_made_ft_rank': 19,\n", 67 | " 'spp_off_midrange_miss': 11.5343320848939,\n", 68 | " 'spp_off_midrange_miss_rank': 25,\n", 69 | " 'spp_off_missed3': 11.837528604119,\n", 70 | " 'spp_off_missed3_rank': 22,\n", 71 | " 'spp_off_missed_fg': 11.2842718446602,\n", 72 | " 'spp_off_missed_fg_rank': 21,\n", 73 | " 'spp_off_missed_ft': 15.2605633802817,\n", 74 | " 'spp_off_missed_ft_rank': 13,\n", 75 | " 'spp_off_rim_miss': 9.78694158075601,\n", 76 | " 'spp_off_rim_miss_rank': 21,\n", 77 | " 'spp_off_steal': 9.42160278745645,\n", 78 | " 'spp_off_steal_rank': 27,\n", 79 | " 'spp_off_timeout': 18.3120567375887,\n", 80 | " 'spp_off_timeout_rank': 21,\n", 81 | " 'spp_rank': 16,\n", 82 | " 'team_id': '1610612737',\n", 83 | " 'team_name': 'ATL'}" 84 | ] 85 | }, 86 | "execution_count": 2, 87 | "metadata": {}, 88 | "output_type": "execute_result" 89 | } 90 | ], 91 | "source": [ 92 | "url = \"https://api.pbpstats.com/get-pace-efficiency-summary/nba\"\n", 93 | "params = {\n", 94 | " \"Season\": \"2021-22\",\n", 95 | " \"SeasonType\": \"Regular Season\",\n", 96 | " \"Type\": \"Team\"\n", 97 | "}\n", 98 | "response = requests.get(url, params=params)\n", 99 | "response_json = response.json()\n", 100 | "response_json['results'][0]" 101 | ] 102 | }, 103 | { 104 | "cell_type": "markdown", 105 | "id": "40b72493-a4ec-4d98-85b2-bcc4a0109273", 106 | "metadata": {}, 107 | "source": [ 108 | "### WNBA - Opponent" 109 | ] 110 | }, 111 | { 112 | "cell_type": "code", 113 | "execution_count": 3, 114 | "id": "b64ee7f3-9b1d-429d-916a-3aa70ab2d496", 115 | "metadata": {}, 116 | "outputs": [ 117 | { 118 | "data": { 119 | "text/plain": [ 120 | "{'ppp': 1.02608695652174,\n", 121 | " 'ppp_off_deadball': 0.903225806451613,\n", 122 | " 'ppp_off_deadball_rank': 3,\n", 123 | " 'ppp_off_made_fg': 1.0,\n", 124 | " 'ppp_off_made_fg_rank': 8,\n", 125 | " 'ppp_off_made_ft': 0.956521739130435,\n", 126 | " 'ppp_off_made_ft_rank': 6,\n", 127 | " 'ppp_off_midrange_miss': 0.904109589041096,\n", 128 | " 'ppp_off_midrange_miss_rank': 3,\n", 129 | " 'ppp_off_missed3': 1.0,\n", 130 | " 'ppp_off_missed3_rank': 6,\n", 131 | " 'ppp_off_missed_fg': 0.989247311827957,\n", 132 | " 'ppp_off_missed_fg_rank': 6,\n", 133 | " 'ppp_off_missed_ft': 0.666666666666667,\n", 134 | " 'ppp_off_missed_ft_rank': 5,\n", 135 | " 'ppp_off_rim_miss': 0.9,\n", 136 | " 'ppp_off_rim_miss_rank': 3,\n", 137 | " 'ppp_off_steal': 1.421875,\n", 138 | " 'ppp_off_steal_rank': 12,\n", 139 | " 'ppp_off_timeout': 1.06060606060606,\n", 140 | " 'ppp_off_timeout_rank': 10,\n", 141 | " 'ppp_rank': 7,\n", 142 | " 'spp': 15.0977391304348,\n", 143 | " 'spp_off_deadball': 17.1645161290323,\n", 144 | " 'spp_off_deadball_rank': 7,\n", 145 | " 'spp_off_made_fg': 19.1886666666667,\n", 146 | " 'spp_off_made_fg_rank': 2,\n", 147 | " 'spp_off_made_ft': 15.5,\n", 148 | " 'spp_off_made_ft_rank': 12,\n", 149 | " 'spp_off_midrange_miss': 11.4068493150685,\n", 150 | " 'spp_off_midrange_miss_rank': 5,\n", 151 | " 'spp_off_missed3': 12.3466666666667,\n", 152 | " 'spp_off_missed3_rank': 3,\n", 153 | " 'spp_off_missed_fg': 11.9064516129032,\n", 154 | " 'spp_off_missed_fg_rank': 1,\n", 155 | " 'spp_off_missed_ft': 14.6666666666667,\n", 156 | " 'spp_off_missed_ft_rank': 7,\n", 157 | " 'spp_off_rim_miss': 11.75,\n", 158 | " 'spp_off_rim_miss_rank': 3,\n", 159 | " 'spp_off_steal': 10.85,\n", 160 | " 'spp_off_steal_rank': 1,\n", 161 | " 'spp_off_timeout': 16.3818181818182,\n", 162 | " 'spp_off_timeout_rank': 10,\n", 163 | " 'spp_rank': 6,\n", 164 | " 'team_id': '1611661313',\n", 165 | " 'team_name': 'NYL'}" 166 | ] 167 | }, 168 | "execution_count": 3, 169 | "metadata": {}, 170 | "output_type": "execute_result" 171 | } 172 | ], 173 | "source": [ 174 | "url = \"https://api.pbpstats.com/get-pace-efficiency-summary/wnba\"\n", 175 | "params = {\n", 176 | " \"Season\": \"2022\",\n", 177 | " \"SeasonType\": \"Regular Season\",\n", 178 | " \"Type\": \"Opponent\"\n", 179 | "}\n", 180 | "response = requests.get(url, params=params)\n", 181 | "response_json = response.json()\n", 182 | "response_json['results'][0]" 183 | ] 184 | }, 185 | { 186 | "cell_type": "code", 187 | "execution_count": null, 188 | "id": "896e3ea2-ce5f-429a-8ced-99149c759aa2", 189 | "metadata": {}, 190 | "outputs": [], 191 | "source": [] 192 | } 193 | ], 194 | "metadata": { 195 | "kernelspec": { 196 | "display_name": "playground", 197 | "language": "python", 198 | "name": "playground" 199 | }, 200 | "language_info": { 201 | "codemirror_mode": { 202 | "name": "ipython", 203 | "version": 3 204 | }, 205 | "file_extension": ".py", 206 | "mimetype": "text/x-python", 207 | "name": "python", 208 | "nbconvert_exporter": "python", 209 | "pygments_lexer": "ipython3", 210 | "version": "3.8.9" 211 | } 212 | }, 213 | "nbformat": 4, 214 | "nbformat_minor": 5 215 | } 216 | -------------------------------------------------------------------------------- /get-possessions.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "id": "65512eee-40df-49be-87f1-978e75e08890", 6 | "metadata": {}, 7 | "source": [ 8 | "This endpoint can be used to get stats and details for possessions that meet query parameters. If more than 500 possessions meet criteria, only 500 possessions will be returned.\n", 9 | "There is a lot of overlap with the get-wowy-stats endpoint so see those examples for more details on doing player and opponent on/off stuff" 10 | ] 11 | }, 12 | { 13 | "cell_type": "code", 14 | "execution_count": 1, 15 | "id": "f570d66c-dacb-41a8-bf01-14d8ec45fd8a", 16 | "metadata": {}, 17 | "outputs": [], 18 | "source": [ 19 | "import requests" 20 | ] 21 | }, 22 | { 23 | "cell_type": "markdown", 24 | "id": "0fe9668a-e260-446a-898c-334c52ccd696", 25 | "metadata": {}, 26 | "source": [ 27 | "### Hawks Very high leverage possessions with Trae Young on the floor" 28 | ] 29 | }, 30 | { 31 | "cell_type": "code", 32 | "execution_count": 2, 33 | "id": "d153e9c3-4cb3-4823-9d58-b1f88c224cb5", 34 | "metadata": {}, 35 | "outputs": [], 36 | "source": [ 37 | "url = \"https://api.pbpstats.com/get-possessions/nba\"\n", 38 | "params = {\n", 39 | " \"0Exactly1OnFloor\": \"1629027\", # format index(Exactly|GreaterThan|LessThan)number(OnFloor|OffFloor|PlayedInGame|DidNotPlayInGame|Started|CameOffBench)\n", 40 | " \"TeamId\": \"1610612737\",\n", 41 | " \"Season\": \"2021-22\",\n", 42 | " \"SeasonType\": \"Regular Season\",\n", 43 | " \"OffDef\": \"Offense\", # Offense or Defense\n", 44 | " \"StartType\": \"All\", # see below for possible values for StartType\n", 45 | " \"Leverage\": \"VeryHigh\"\n", 46 | "}\n", 47 | "response = requests.get(url, params=params)\n", 48 | "response_json = response.json()\n", 49 | "possessions = response_json[\"possessions\"]\n", 50 | "player_stats = response_json[\"player_results\"]\n", 51 | "team_stats = response_json[\"team_results\"]" 52 | ] 53 | }, 54 | { 55 | "cell_type": "markdown", 56 | "id": "ba729220-6a5b-4156-b0c3-73379cff33af", 57 | "metadata": {}, 58 | "source": [ 59 | "#### possible values for StartType" 60 | ] 61 | }, 62 | { 63 | "cell_type": "code", 64 | "execution_count": 3, 65 | "id": "e1d309d6-f5e6-4cbd-8850-fdbda0232d1c", 66 | "metadata": {}, 67 | "outputs": [], 68 | "source": [ 69 | "start_types = [\n", 70 | " \"All\", # All\n", 71 | " \"OffMissedFG\", # Off Any Missed FG\n", 72 | " \"OffMissed2\", # Off Any Missed 2\n", 73 | " \"OffMissed3\", # Off Any Missed 3\n", 74 | " \"OffMadeFG\", # Off Any Made FG\n", 75 | " \"OffMade2\", # Off Any Made 2\n", 76 | " \"OffMade3\", # Off Any Made 3\n", 77 | " \"OffAtRimMake\", # Off At Rim Make\n", 78 | " \"OffAtRimMiss\", # Off At Rim Miss\n", 79 | " \"OffAtRimBlock\", # Off At Rim Block\n", 80 | " \"OffShortMidRangeMake\", # Off Short Mid-Range Make\n", 81 | " \"OffShortMidRangeMiss\", # Off Short Mid-Range Miss\n", 82 | " \"OffLongMidRangeMake\", # Off Long Mid-Range Make\n", 83 | " \"OffLongMidRangeMiss\", # Off Long Mid-Range Miss\n", 84 | " \"OffArc3Make\", # Off Arc 3 Make\n", 85 | " \"OffArc3Miss\", # Off Arc 3 Miss\n", 86 | " \"OffCorner3Make\", # Off Corner 3 Make\n", 87 | " \"OffCorner3Miss\", # Off Corner 3 Miss\n", 88 | " \"OffFTMake\", # Off FT Make\n", 89 | " \"OffFTMiss\", # Off FT Miss\n", 90 | " \"OffLiveBallTurnover\", # Off Steal\n", 91 | " \"OffDeadball\", # Off Dead Ball\n", 92 | " \"OffTimeout\", # Off Timeout\n", 93 | "]" 94 | ] 95 | }, 96 | { 97 | "cell_type": "markdown", 98 | "id": "7915f194-4581-43e1-b3cb-ff2e92435d42", 99 | "metadata": {}, 100 | "source": [ 101 | "### Warriors 4th quarter possessions on which Steph Curry attempts a 3" 102 | ] 103 | }, 104 | { 105 | "cell_type": "code", 106 | "execution_count": 4, 107 | "id": "1dfbd8ae-1011-453a-9c51-dd59d291e521", 108 | "metadata": {}, 109 | "outputs": [], 110 | "source": [ 111 | "url = \"https://api.pbpstats.com/get-possessions/nba\"\n", 112 | "params = {\n", 113 | " \"TeamId\": \"1610612744\",\n", 114 | " \"Season\": \"2021-22\",\n", 115 | " \"SeasonType\": \"Regular Season\",\n", 116 | " \"OffDef\": \"Offense\", # Offense or Defense\n", 117 | " \"StartType\": \"All\",\n", 118 | " \"Period\": \"4\",\n", 119 | " \"EventType\": \"FG3A\", # options are FG3A, FG2A and Oreb\n", 120 | " \"EventPlayerId\": \"201939\"\n", 121 | "}\n", 122 | "response = requests.get(url, params=params)\n", 123 | "response_json = response.json()\n", 124 | "possessions = response_json[\"possessions\"]\n", 125 | "player_stats = response_json[\"player_results\"]\n", 126 | "team_stats = response_json[\"team_results\"]" 127 | ] 128 | }, 129 | { 130 | "cell_type": "markdown", 131 | "id": "9faf46d8-a29c-4a60-a473-45c5e6d925e4", 132 | "metadata": {}, 133 | "source": [ 134 | "### Warriors offensive possessions following a Steph Curry defensive rebound" 135 | ] 136 | }, 137 | { 138 | "cell_type": "code", 139 | "execution_count": 5, 140 | "id": "75acfc12-1910-4df5-ad43-8c1d8df25032", 141 | "metadata": {}, 142 | "outputs": [], 143 | "source": [ 144 | "url = \"https://api.pbpstats.com/get-possessions/nba\"\n", 145 | "params = {\n", 146 | " \"TeamId\": \"1610612744\",\n", 147 | " \"Season\": \"2021-22\",\n", 148 | " \"SeasonType\": \"Regular Season\",\n", 149 | " \"OffDef\": \"Offense\", # Offense or Defense\n", 150 | " \"StartType\": \"OffMissedFG\",\n", 151 | " \"ReboundPlayerId\": \"201939\"\n", 152 | "}\n", 153 | "response = requests.get(url, params=params)\n", 154 | "response_json = response.json()\n", 155 | "possessions = response_json[\"possessions\"]\n", 156 | "player_stats = response_json[\"player_results\"]\n", 157 | "team_stats = response_json[\"team_results\"]" 158 | ] 159 | }, 160 | { 161 | "cell_type": "markdown", 162 | "id": "2e27ef5d-5a39-4ee1-ab58-e92007650cb7", 163 | "metadata": {}, 164 | "source": [ 165 | "### Warriors defensive possessions following a Steph Curry missed 3" 166 | ] 167 | }, 168 | { 169 | "cell_type": "code", 170 | "execution_count": 6, 171 | "id": "13396066-4d98-4ea1-a6c4-63375ca6382a", 172 | "metadata": {}, 173 | "outputs": [], 174 | "source": [ 175 | "url = \"https://api.pbpstats.com/get-possessions/nba\"\n", 176 | "params = {\n", 177 | " \"TeamId\": \"1610612744\",\n", 178 | " \"Season\": \"2021-22\",\n", 179 | " \"SeasonType\": \"Regular Season\",\n", 180 | " \"OffDef\": \"Defense\", # Offense or Defense\n", 181 | " \"StartType\": \"OffMissed3\",\n", 182 | " \"ShooterPlayerId\": \"201939\"\n", 183 | "}\n", 184 | "response = requests.get(url, params=params)\n", 185 | "response_json = response.json()\n", 186 | "possessions = response_json[\"possessions\"]\n", 187 | "player_stats = response_json[\"player_results\"]\n", 188 | "team_stats = response_json[\"team_results\"]" 189 | ] 190 | }, 191 | { 192 | "cell_type": "markdown", 193 | "id": "4883e3c0-ea3a-4aaa-b36c-96e7e50b52d8", 194 | "metadata": {}, 195 | "source": [ 196 | "### Warriors 4th quarter and overtime possessions when down by 3 or less with the possession starting with less than 20 seconds remaining" 197 | ] 198 | }, 199 | { 200 | "cell_type": "code", 201 | "execution_count": 7, 202 | "id": "226ab240-4639-485a-8429-f3bb0b66c6f9", 203 | "metadata": {}, 204 | "outputs": [], 205 | "source": [ 206 | "url = \"https://api.pbpstats.com/get-possessions/nba\"\n", 207 | "params = {\n", 208 | " \"TeamId\": \"1610612744\",\n", 209 | " \"Season\": \"2021-22\",\n", 210 | " \"SeasonType\": \"Regular Season\",\n", 211 | " \"OffDef\": \"Offense\", # Offense or Defense\n", 212 | " \"StartType\": \"All\",\n", 213 | " \"FromMargin\": -3,\n", 214 | " \"ToMargin\": -1,\n", 215 | " \"FromTime\": 20, # in seconds remaining in the period at possession start\n", 216 | " \"ToTime\": 0, # in seconds remaining in the period at possession start\n", 217 | " \"Period\": \"4_OT\"\n", 218 | "}\n", 219 | "response = requests.get(url, params=params)\n", 220 | "response_json = response.json()\n", 221 | "possessions = response_json[\"possessions\"]\n", 222 | "player_stats = response_json[\"player_results\"]\n", 223 | "team_stats = response_json[\"team_results\"]" 224 | ] 225 | }, 226 | { 227 | "cell_type": "code", 228 | "execution_count": null, 229 | "id": "ff383f3b-b548-4ea8-b7ee-a19628db901c", 230 | "metadata": {}, 231 | "outputs": [], 232 | "source": [] 233 | } 234 | ], 235 | "metadata": { 236 | "kernelspec": { 237 | "display_name": "playground", 238 | "language": "python", 239 | "name": "playground" 240 | }, 241 | "language_info": { 242 | "codemirror_mode": { 243 | "name": "ipython", 244 | "version": 3 245 | }, 246 | "file_extension": ".py", 247 | "mimetype": "text/x-python", 248 | "name": "python", 249 | "nbconvert_exporter": "python", 250 | "pygments_lexer": "ipython3", 251 | "version": "3.8.9" 252 | } 253 | }, 254 | "nbformat": 4, 255 | "nbformat_minor": 5 256 | } 257 | -------------------------------------------------------------------------------- /get-scatter-plots.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "id": "0299ec69-61e3-455b-8db3-8fd436a95c11", 6 | "metadata": {}, 7 | "source": [ 8 | "This endpoint can be used to get stats for each team for the selected stats" 9 | ] 10 | }, 11 | { 12 | "cell_type": "code", 13 | "execution_count": 1, 14 | "id": "8b7dd84d-9e56-4153-9f1a-832bafd44aad", 15 | "metadata": {}, 16 | "outputs": [], 17 | "source": [ 18 | "import requests" 19 | ] 20 | }, 21 | { 22 | "cell_type": "markdown", 23 | "id": "a3e15076-0ee1-4ef3-b2c8-9976e24cea58", 24 | "metadata": {}, 25 | "source": [ 26 | "### Points per 100 possessions and seconds per possession" 27 | ] 28 | }, 29 | { 30 | "cell_type": "code", 31 | "execution_count": 2, 32 | "id": "df6e5e2a-1327-4fe5-b0cc-1e9a4560d584", 33 | "metadata": {}, 34 | "outputs": [ 35 | { 36 | "data": { 37 | "text/plain": [ 38 | "[{'id': '1610612754',\n", 39 | " 'label': 'IND',\n", 40 | " 'x': 113.0768279104293,\n", 41 | " 'y': 14.594828652727948},\n", 42 | " {'id': '1610612751',\n", 43 | " 'label': 'BKN',\n", 44 | " 'x': 114.55085374907202,\n", 45 | " 'y': 14.616184112843355},\n", 46 | " {'id': '1610612764',\n", 47 | " 'label': 'WAS',\n", 48 | " 'x': 111.46289575772745,\n", 49 | " 'y': 15.134150919784759},\n", 50 | " {'id': '1610612739',\n", 51 | " 'label': 'CLE',\n", 52 | " 'x': 112.14158842933267,\n", 53 | " 'y': 15.47690941385435},\n", 54 | " {'id': '1610612742',\n", 55 | " 'label': 'DAL',\n", 56 | " 'x': 113.75369205085399,\n", 57 | " 'y': 15.722100937459869},\n", 58 | " {'id': '1610612747',\n", 59 | " 'label': 'LAL',\n", 60 | " 'x': 110.9876841342671,\n", 61 | " 'y': 14.503380825887467},\n", 62 | " {'id': '1610612745',\n", 63 | " 'label': 'HOU',\n", 64 | " 'x': 109.16039796165978,\n", 65 | " 'y': 14.597427808784275},\n", 66 | " {'id': '1610612737',\n", 67 | " 'label': 'ATL',\n", 68 | " 'x': 116.45269849183596,\n", 69 | " 'y': 14.768166521251402},\n", 70 | " {'id': '1610612746',\n", 71 | " 'label': 'LAC',\n", 72 | " 'x': 110.72362685265911,\n", 73 | " 'y': 14.813426329555362},\n", 74 | " {'id': '1610612741',\n", 75 | " 'label': 'CHI',\n", 76 | " 'x': 113.77424167081054,\n", 77 | " 'y': 14.674167081054202},\n", 78 | " {'id': '1610612740',\n", 79 | " 'label': 'NOP',\n", 80 | " 'x': 112.30576441102757,\n", 81 | " 'y': 14.885714285714286},\n", 82 | " {'id': '1610612761',\n", 83 | " 'label': 'TOR',\n", 84 | " 'x': 113.32912192040429,\n", 85 | " 'y': 15.11724573594441},\n", 86 | " {'id': '1610612748',\n", 87 | " 'label': 'MIA',\n", 88 | " 'x': 114.30381350563789,\n", 89 | " 'y': 15.106423413150893},\n", 90 | " {'id': '1610612765',\n", 91 | " 'label': 'DET',\n", 92 | " 'x': 106.67659468850832,\n", 93 | " 'y': 14.839041945892282},\n", 94 | " {'id': '1610612758',\n", 95 | " 'label': 'SAC',\n", 96 | " 'x': 110.68281938325991,\n", 97 | " 'y': 14.250489476260402},\n", 98 | " {'id': '1610612756',\n", 99 | " 'label': 'PHX',\n", 100 | " 'x': 115.6188605108055,\n", 101 | " 'y': 14.272838899803537},\n", 102 | " {'id': '1610612762',\n", 103 | " 'label': 'UTA',\n", 104 | " 'x': 117.46311940486697,\n", 105 | " 'y': 15.076913377884251},\n", 106 | " {'id': '1610612750',\n", 107 | " 'label': 'MIN',\n", 108 | " 'x': 114.81884057971016,\n", 109 | " 'y': 14.027415458937199},\n", 110 | " {'id': '1610612744',\n", 111 | " 'label': 'GSW',\n", 112 | " 'x': 113.26530612244898,\n", 113 | " 'y': 14.395470383275262},\n", 114 | " {'id': '1610612752',\n", 115 | " 'label': 'NYK',\n", 116 | " 'x': 110.95437793874699,\n", 117 | " 'y': 15.344516456983099},\n", 118 | " {'id': '1610612753',\n", 119 | " 'label': 'ORL',\n", 120 | " 'x': 104.84543670264966,\n", 121 | " 'y': 14.571270853778215},\n", 122 | " {'id': '1610612755',\n", 123 | " 'label': 'PHI',\n", 124 | " 'x': 114.21512732801216,\n", 125 | " 'y': 15.38654503990878},\n", 126 | " {'id': '1610612757',\n", 127 | " 'label': 'POR',\n", 128 | " 'x': 108.46718964014444,\n", 129 | " 'y': 14.803635910845474},\n", 130 | " {'id': '1610612766',\n", 131 | " 'label': 'CHA',\n", 132 | " 'x': 114.76941747572815,\n", 133 | " 'y': 14.186893203883495},\n", 134 | " {'id': '1610612749',\n", 135 | " 'label': 'MIL',\n", 136 | " 'x': 115.50189047444812,\n", 137 | " 'y': 13.977192340529333},\n", 138 | " {'id': '1610612759',\n", 139 | " 'label': 'SAS',\n", 140 | " 'x': 113.13094367227507,\n", 141 | " 'y': 14.084613508900269},\n", 142 | " {'id': '1610612743',\n", 143 | " 'label': 'DEN',\n", 144 | " 'x': 115.06286567907382,\n", 145 | " 'y': 15.004232540769326},\n", 146 | " {'id': '1610612760',\n", 147 | " 'label': 'OKC',\n", 148 | " 'x': 104.75369458128078,\n", 149 | " 'y': 14.620566502463054},\n", 150 | " {'id': '1610612763',\n", 151 | " 'label': 'MEM',\n", 152 | " 'x': 115.75091575091574,\n", 153 | " 'y': 14.41904761904762},\n", 154 | " {'id': '1610612738',\n", 155 | " 'label': 'BOS',\n", 156 | " 'x': 114.70772311928903,\n", 157 | " 'y': 14.968832144198272}]" 158 | ] 159 | }, 160 | "execution_count": 2, 161 | "metadata": {}, 162 | "output_type": "execute_result" 163 | } 164 | ], 165 | "source": [ 166 | "url = \"https://api.pbpstats.com/get-scatter-plots/nba\"\n", 167 | "params = {\n", 168 | " \"Season\": \"2021-22\",\n", 169 | " \"SeasonType\": \"Regular Season\",\n", 170 | " \"Xaxis\": \"PtsPer100Poss\", # see list of available stat keys below\n", 171 | " \"Yaxis\": \"SecondsPerPoss\", # see list of available stat keys below\n", 172 | " \"XaxisType\": \"Team\", # Team or Opponent\n", 173 | " \"YaxisType\": \"Team\" # Team or Opponent\n", 174 | "}\n", 175 | "response = requests.get(url, params=params)\n", 176 | "response_json = response.json()\n", 177 | "response_json['results']" 178 | ] 179 | }, 180 | { 181 | "cell_type": "markdown", 182 | "id": "555caf8f-a3ee-4b92-b729-6edca3687bc9", 183 | "metadata": {}, 184 | "source": [ 185 | "### Available axis stat key options" 186 | ] 187 | }, 188 | { 189 | "cell_type": "code", 190 | "execution_count": 3, 191 | "id": "227eb00d-a5f9-46d2-beb5-d2a4ca291fe5", 192 | "metadata": {}, 193 | "outputs": [], 194 | "source": [ 195 | "stat_keys = [\n", 196 | " \"PtsPer100Poss\", # Points Per 100 Possessions\n", 197 | " \"SecondsPerPoss\", # Seconds Per Possession\n", 198 | " \"FG3APct\", # 3 Point Rate\n", 199 | " \"Fg3Pct\", # 3pt %\n", 200 | " \"AtRimFrequency\", # At Rim Shot Frequency\n", 201 | " \"AtRimAccuracy\", # At Rim FG%\n", 202 | " \"AtRimPctAssisted\", # At Rim % Assisted\n", 203 | " \"ShortMidRangeFrequency\", # Short Mid Range Shot Frequency\n", 204 | " \"ShortMidRangeAccuracy\", # Short Mid Range FG%\n", 205 | " \"ShortMidRangePctAssisted\", # Short Mid Range % Assisted\n", 206 | " \"LongMidRangeFrequency\", # Long Mid Range Shot Frequency\n", 207 | " \"LongMidRangeAccuracy\", # Long Mid Range FG%\n", 208 | " \"LongMidRangePctAssisted\", # Long Mid % Assisted\n", 209 | " \"Corner3Frequency\", # Corner 3 Shot Frequency\n", 210 | " \"Corner3Accuracy\", # Corner 3 FG%\n", 211 | " \"Corner3PctAssisted\", # Corner 3 % Assisted\n", 212 | " \"Arc3Frequency\", # Above The Break 3 Shot Frequency\n", 213 | " \"Arc3Accuracy\", # Above The Break 3 FG%\n", 214 | " \"Arc3PctAssisted\", # Above The Break 3 % Assisted\n", 215 | " \"LiveBallTurnoverPct\", # Live Ball TO%\n", 216 | " \"EfgPct\", # eFG%\n", 217 | " \"DefFTReboundPct\", # DReb% - Missed FTs\n", 218 | " \"OffFTReboundPct\", # OReb% - Missed FTs\n", 219 | " \"DefTwoPtReboundPct\", # DReb% - Missed 2s\n", 220 | " \"OffTwoPtReboundPct\", # OReb% - Missed 2s\n", 221 | " \"DefThreePtReboundPct\", # DReb% - Missed 3s\n", 222 | " \"OffThreePtReboundPct\", # OReb% - Missed 3s\n", 223 | " \"DefFGReboundPct\", # DReb% - Missed FGs\n", 224 | " \"OffFGReboundPct\", # OReb% - Missed FGs\n", 225 | " \"OffAtRimReboundPct\", # At Rim OReb%\n", 226 | " \"OffShortMidRangeReboundPct\", # Short Mid-Range OReb%\n", 227 | " \"OffLongMidRangeReboundPct\", # Long Mid-Range OReb%\n", 228 | " \"OffArc3ReboundPct\", # Arc 3 OReb%\n", 229 | " \"OffCorner3ReboundPct\", # Corner 3 OReb%\n", 230 | " \"DefAtRimReboundPct\", # At Rim DReb%\n", 231 | " \"DefShortMidRangeReboundPct\", # Short Mid-Range DReb%\n", 232 | " \"DefLongMidRangeReboundPct\", # Long Mid-Range DReb%\n", 233 | " \"DefArc3ReboundPct\", # Arc 3 DReb%\n", 234 | " \"DefCorner3ReboundPct\", # Corner 3 DReb%\n", 235 | " \"SecondChancePtsPer100PossSecondChance\", # Second Chance Efficiency\n", 236 | " \"PenaltyPtsPer100PossPenalty\", # Penalty Efficiency\n", 237 | " \"SecondChanceOffPossPer100Poss\", # Second Chance Possessions Per 100 Possessions\n", 238 | " \"FirstChancePtsPer100Poss\", # First Chance Points Per 100 Possessions\n", 239 | " \"SecondChancePtsPer100Poss\", # Second Chance Points Per 100 Possessions\n", 240 | " \"PenaltyOffPossPer100Poss\", # Penalty Possessions Per 100 Possessions\n", 241 | " \"Avg2ptShotDistance\", # Avg 2pt Shot Distance\n", 242 | " \"Avg3ptShotDistance\" # Avg 3pt Shot Distance \n", 243 | "]" 244 | ] 245 | }, 246 | { 247 | "cell_type": "code", 248 | "execution_count": null, 249 | "id": "03e9e88f-d75e-4ba9-9c9f-0c943bf2704f", 250 | "metadata": {}, 251 | "outputs": [], 252 | "source": [] 253 | } 254 | ], 255 | "metadata": { 256 | "kernelspec": { 257 | "display_name": "playground", 258 | "language": "python", 259 | "name": "playground" 260 | }, 261 | "language_info": { 262 | "codemirror_mode": { 263 | "name": "ipython", 264 | "version": 3 265 | }, 266 | "file_extension": ".py", 267 | "mimetype": "text/x-python", 268 | "name": "python", 269 | "nbconvert_exporter": "python", 270 | "pygments_lexer": "ipython3", 271 | "version": "3.8.9" 272 | } 273 | }, 274 | "nbformat": 4, 275 | "nbformat_minor": 5 276 | } 277 | -------------------------------------------------------------------------------- /get-score-margin-breakdown.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "id": "4d881bd9-b1b9-4995-b782-fcb9a9c3f91a", 6 | "metadata": {}, 7 | "source": [ 8 | "This endpoint can be used to get the the percentage of possessions a team was up/down by x points" 9 | ] 10 | }, 11 | { 12 | "cell_type": "code", 13 | "execution_count": 1, 14 | "id": "24be03da-2410-46a6-b876-3613ff31ef85", 15 | "metadata": {}, 16 | "outputs": [], 17 | "source": [ 18 | "import requests" 19 | ] 20 | }, 21 | { 22 | "cell_type": "markdown", 23 | "id": "372c4a97-11dc-4514-8f34-c2b742277c47", 24 | "metadata": {}, 25 | "source": [ 26 | "### 2015-16 Warriors" 27 | ] 28 | }, 29 | { 30 | "cell_type": "code", 31 | "execution_count": 2, 32 | "id": "569f0bcb-c2a2-4f22-90ea-be3f927671b2", 33 | "metadata": {}, 34 | "outputs": [ 35 | { 36 | "data": { 37 | "text/plain": [ 38 | "[{'margin': '-20+', 'frequency': 0.012161751292186074},\n", 39 | " {'margin': '-19', 'frequency': 0.002128306476132563},\n", 40 | " {'margin': '-18', 'frequency': 0.0023715415019762848},\n", 41 | " {'margin': '-17', 'frequency': 0.0033444816053511705},\n", 42 | " {'margin': '-16', 'frequency': 0.0018242626938279112},\n", 43 | " {'margin': '-15', 'frequency': 0.0037701429005776834},\n", 44 | " {'margin': '-14', 'frequency': 0.0030404378230465185},\n", 45 | " {'margin': '-13', 'frequency': 0.0030404378230465185},\n", 46 | " {'margin': '-12', 'frequency': 0.005229553055640012},\n", 47 | " {'margin': '-11', 'frequency': 0.006749771967163271},\n", 48 | " {'margin': '-10', 'frequency': 0.008999695956217696},\n", 49 | " {'margin': '-9', 'frequency': 0.007905138339920948},\n", 50 | " {'margin': '-8', 'frequency': 0.011614472484037701},\n", 51 | " {'margin': '-7', 'frequency': 0.012040133779264214},\n", 52 | " {'margin': '-6', 'frequency': 0.016783216783216783},\n", 53 | " {'margin': '-5', 'frequency': 0.02097902097902098},\n", 54 | " {'margin': '-4', 'frequency': 0.020796594709638187},\n", 55 | " {'margin': '-3', 'frequency': 0.030404378230465188},\n", 56 | " {'margin': '-2', 'frequency': 0.033870477348738215},\n", 57 | " {'margin': '-1', 'frequency': 0.036910915171784735},\n", 58 | " {'margin': '0', 'frequency': 0.052599574338704776},\n", 59 | " {'margin': '1', 'frequency': 0.039890544238370323},\n", 60 | " {'margin': '2', 'frequency': 0.04445120097294011},\n", 61 | " {'margin': '3', 'frequency': 0.041045910611128},\n", 62 | " {'margin': '4', 'frequency': 0.03928245667376102},\n", 63 | " {'margin': '5', 'frequency': 0.033566433566433566},\n", 64 | " {'margin': '6', 'frequency': 0.040863484341745214},\n", 65 | " {'margin': '7', 'frequency': 0.03192459714198845},\n", 66 | " {'margin': '8', 'frequency': 0.03678929765886288},\n", 67 | " {'margin': '9', 'frequency': 0.03417452113104287},\n", 68 | " {'margin': '10', 'frequency': 0.03368805107935543},\n", 69 | " {'margin': '11', 'frequency': 0.03235025843721496},\n", 70 | " {'margin': '12', 'frequency': 0.028032836728488903},\n", 71 | " {'margin': '13', 'frequency': 0.03593797506840985},\n", 72 | " {'margin': '14', 'frequency': 0.02766798418972332},\n", 73 | " {'margin': '15', 'frequency': 0.027059896625114016},\n", 74 | " {'margin': '16', 'frequency': 0.027120705381574947},\n", 75 | " {'margin': '17', 'frequency': 0.019823654606263303},\n", 76 | " {'margin': '18', 'frequency': 0.01818181818181818},\n", 77 | " {'margin': '19', 'frequency': 0.017573730617208877},\n", 78 | " {'margin': '20+', 'frequency': 0.09401033748859836}]" 79 | ] 80 | }, 81 | "execution_count": 2, 82 | "metadata": {}, 83 | "output_type": "execute_result" 84 | } 85 | ], 86 | "source": [ 87 | "url = \"https://api.pbpstats.com/get-score-margin-breakdown/nba\"\n", 88 | "params = {\n", 89 | " \"TeamId\": \"1610612744\",\n", 90 | " \"Season\": \"2015-16\",\n", 91 | " \"SeasonType\": \"Regular Season\",\n", 92 | " \"Period\": \"All\" # possible values: All, 1, 2, 3, 4, SecondHalf\n", 93 | "}\n", 94 | "response = requests.get(url, params=params)\n", 95 | "response_json = response.json()\n", 96 | "response_json[\"margins\"]" 97 | ] 98 | }, 99 | { 100 | "cell_type": "code", 101 | "execution_count": null, 102 | "id": "26799ebc-886f-4a90-950b-47bba6c5664c", 103 | "metadata": {}, 104 | "outputs": [], 105 | "source": [] 106 | } 107 | ], 108 | "metadata": { 109 | "kernelspec": { 110 | "display_name": "playground", 111 | "language": "python", 112 | "name": "playground" 113 | }, 114 | "language_info": { 115 | "codemirror_mode": { 116 | "name": "ipython", 117 | "version": 3 118 | }, 119 | "file_extension": ".py", 120 | "mimetype": "text/x-python", 121 | "name": "python", 122 | "nbconvert_exporter": "python", 123 | "pygments_lexer": "ipython3", 124 | "version": "3.8.9" 125 | } 126 | }, 127 | "nbformat": 4, 128 | "nbformat_minor": 5 129 | } 130 | -------------------------------------------------------------------------------- /get-score-time-summary.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "id": "41691011-598e-43ff-a0cf-5950470183b6", 6 | "metadata": {}, 7 | "source": [ 8 | "This endpoint can be used to get team and lineup stats based on score and time parameters" 9 | ] 10 | }, 11 | { 12 | "cell_type": "code", 13 | "execution_count": 1, 14 | "id": "0c30261d-b05b-41c1-813f-a48bc9e89299", 15 | "metadata": {}, 16 | "outputs": [], 17 | "source": [ 18 | "import requests" 19 | ] 20 | }, 21 | { 22 | "cell_type": "markdown", 23 | "id": "8f11e98d-17b0-44be-9874-9bc2f15be875", 24 | "metadata": {}, 25 | "source": [ 26 | "### 4th quarter and OT, game within 3 points with 2-5 minutes remaining" 27 | ] 28 | }, 29 | { 30 | "cell_type": "code", 31 | "execution_count": 2, 32 | "id": "9654ab7c-57ac-4d86-968a-fb448356d970", 33 | "metadata": {}, 34 | "outputs": [ 35 | { 36 | "data": { 37 | "text/plain": [ 38 | "[{'afg2m': 12,\n", 39 | " 'afg3m': 9,\n", 40 | " 'dead_ball_tos': 8,\n", 41 | " 'efg': 0.461165048543689,\n", 42 | " 'fg2a': 57,\n", 43 | " 'fg2m': 28,\n", 44 | " 'fg2m_assist_pct': 0.428571428571429,\n", 45 | " 'fg2pct': 0.491228070175439,\n", 46 | " 'fg3a': 46,\n", 47 | " 'fg3m': 13,\n", 48 | " 'fg3m_assist_pct': 0.692307692307692,\n", 49 | " 'fg3pct': 0.282608695652174,\n", 50 | " 'ftm': 25,\n", 51 | " 'live_ball_tos': 3,\n", 52 | " 'off_poss': 112,\n", 53 | " 'oreb_opps': 62,\n", 54 | " 'oreb_pct': 0.290322580645161,\n", 55 | " 'orebs': 18,\n", 56 | " 'ortg': 1.07142857142857,\n", 57 | " 'points': 120,\n", 58 | " 'putbacks': 2,\n", 59 | " 'take_fouls_drawn': 0,\n", 60 | " 'team_id': '1610612762',\n", 61 | " 'team_name': 'UTA',\n", 62 | " 'three_pt_and1s': 0,\n", 63 | " 'three_pt_sfd': 0,\n", 64 | " 'to_pct': 0.0982142857142857,\n", 65 | " 'two_pt_and1s': 2,\n", 66 | " 'two_pt_sfd': 13,\n", 67 | " 'ufg2m': 16,\n", 68 | " 'ufg3m': 4},\n", 69 | " {'afg2m': 8,\n", 70 | " 'afg3m': 7,\n", 71 | " 'dead_ball_tos': 5,\n", 72 | " 'efg': 0.535294117647059,\n", 73 | " 'fg2a': 51,\n", 74 | " 'fg2m': 26,\n", 75 | " 'fg2m_assist_pct': 0.307692307692308,\n", 76 | " 'fg2pct': 0.509803921568627,\n", 77 | " 'fg3a': 34,\n", 78 | " 'fg3m': 13,\n", 79 | " 'fg3m_assist_pct': 0.538461538461538,\n", 80 | " 'fg3pct': 0.382352941176471,\n", 81 | " 'ftm': 12,\n", 82 | " 'live_ball_tos': 5,\n", 83 | " 'off_poss': 87,\n", 84 | " 'oreb_opps': 46,\n", 85 | " 'oreb_pct': 0.347826086956522,\n", 86 | " 'orebs': 16,\n", 87 | " 'ortg': 1.18390804597701,\n", 88 | " 'points': 103,\n", 89 | " 'putbacks': 3,\n", 90 | " 'take_fouls_drawn': 1,\n", 91 | " 'team_id': '1610612749',\n", 92 | " 'team_name': 'MIL',\n", 93 | " 'three_pt_and1s': 0,\n", 94 | " 'three_pt_sfd': 0,\n", 95 | " 'to_pct': 0.114942528735632,\n", 96 | " 'two_pt_and1s': 0,\n", 97 | " 'two_pt_sfd': 4,\n", 98 | " 'ufg2m': 18,\n", 99 | " 'ufg3m': 6},\n", 100 | " {'afg2m': 29,\n", 101 | " 'afg3m': 7,\n", 102 | " 'dead_ball_tos': 5,\n", 103 | " 'efg': 0.683908045977011,\n", 104 | " 'fg2a': 65,\n", 105 | " 'fg2m': 46,\n", 106 | " 'fg2m_assist_pct': 0.630434782608696,\n", 107 | " 'fg2pct': 0.707692307692308,\n", 108 | " 'fg3a': 22,\n", 109 | " 'fg3m': 9,\n", 110 | " 'fg3m_assist_pct': 0.777777777777778,\n", 111 | " 'fg3pct': 0.409090909090909,\n", 112 | " 'ftm': 21,\n", 113 | " 'live_ball_tos': 5,\n", 114 | " 'off_poss': 99,\n", 115 | " 'oreb_opps': 32,\n", 116 | " 'oreb_pct': 0.25,\n", 117 | " 'orebs': 8,\n", 118 | " 'ortg': 1.41414141414141,\n", 119 | " 'points': 140,\n", 120 | " 'putbacks': 3,\n", 121 | " 'take_fouls_drawn': 0,\n", 122 | " 'team_id': '1610612756',\n", 123 | " 'team_name': 'PHX',\n", 124 | " 'three_pt_and1s': 0,\n", 125 | " 'three_pt_sfd': 1,\n", 126 | " 'to_pct': 0.101010101010101,\n", 127 | " 'two_pt_and1s': 4,\n", 128 | " 'two_pt_sfd': 10,\n", 129 | " 'ufg2m': 17,\n", 130 | " 'ufg3m': 2},\n", 131 | " {'afg2m': 8,\n", 132 | " 'afg3m': 4,\n", 133 | " 'dead_ball_tos': 9,\n", 134 | " 'efg': 0.391304347826087,\n", 135 | " 'fg2a': 45,\n", 136 | " 'fg2m': 21,\n", 137 | " 'fg2m_assist_pct': 0.380952380952381,\n", 138 | " 'fg2pct': 0.466666666666667,\n", 139 | " 'fg3a': 24,\n", 140 | " 'fg3m': 4,\n", 141 | " 'fg3m_assist_pct': 1.0,\n", 142 | " 'fg3pct': 0.166666666666667,\n", 143 | " 'ftm': 25,\n", 144 | " 'live_ball_tos': 11,\n", 145 | " 'off_poss': 90,\n", 146 | " 'oreb_opps': 44,\n", 147 | " 'oreb_pct': 0.318181818181818,\n", 148 | " 'orebs': 14,\n", 149 | " 'ortg': 0.877777777777778,\n", 150 | " 'points': 79,\n", 151 | " 'putbacks': 5,\n", 152 | " 'take_fouls_drawn': 1,\n", 153 | " 'team_id': '1610612765',\n", 154 | " 'team_name': 'DET',\n", 155 | " 'three_pt_and1s': 0,\n", 156 | " 'three_pt_sfd': 1,\n", 157 | " 'to_pct': 0.222222222222222,\n", 158 | " 'two_pt_and1s': 0,\n", 159 | " 'two_pt_sfd': 8,\n", 160 | " 'ufg2m': 13,\n", 161 | " 'ufg3m': 0},\n", 162 | " {'afg2m': 7,\n", 163 | " 'afg3m': 2,\n", 164 | " 'dead_ball_tos': 2,\n", 165 | " 'efg': 0.470588235294118,\n", 166 | " 'fg2a': 63,\n", 167 | " 'fg2m': 37,\n", 168 | " 'fg2m_assist_pct': 0.189189189189189,\n", 169 | " 'fg2pct': 0.587301587301587,\n", 170 | " 'fg3a': 22,\n", 171 | " 'fg3m': 2,\n", 172 | " 'fg3m_assist_pct': 1.0,\n", 173 | " 'fg3pct': 0.0909090909090909,\n", 174 | " 'ftm': 23,\n", 175 | " 'live_ball_tos': 4,\n", 176 | " 'off_poss': 90,\n", 177 | " 'oreb_opps': 46,\n", 178 | " 'oreb_pct': 0.260869565217391,\n", 179 | " 'orebs': 12,\n", 180 | " 'ortg': 1.14444444444444,\n", 181 | " 'points': 103,\n", 182 | " 'putbacks': 4,\n", 183 | " 'take_fouls_drawn': 0,\n", 184 | " 'team_id': '1610612741',\n", 185 | " 'team_name': 'CHI',\n", 186 | " 'three_pt_and1s': 0,\n", 187 | " 'three_pt_sfd': 0,\n", 188 | " 'to_pct': 0.0666666666666667,\n", 189 | " 'two_pt_and1s': 3,\n", 190 | " 'two_pt_sfd': 10,\n", 191 | " 'ufg2m': 30,\n", 192 | " 'ufg3m': 0},\n", 193 | " {'afg2m': 6,\n", 194 | " 'afg3m': 6,\n", 195 | " 'dead_ball_tos': 7,\n", 196 | " 'efg': 0.416666666666667,\n", 197 | " 'fg2a': 45,\n", 198 | " 'fg2m': 16,\n", 199 | " 'fg2m_assist_pct': 0.375,\n", 200 | " 'fg2pct': 0.355555555555556,\n", 201 | " 'fg3a': 33,\n", 202 | " 'fg3m': 11,\n", 203 | " 'fg3m_assist_pct': 0.545454545454545,\n", 204 | " 'fg3pct': 0.333333333333333,\n", 205 | " 'ftm': 11,\n", 206 | " 'live_ball_tos': 5,\n", 207 | " 'off_poss': 87,\n", 208 | " 'oreb_opps': 51,\n", 209 | " 'oreb_pct': 0.196078431372549,\n", 210 | " 'orebs': 10,\n", 211 | " 'ortg': 0.873563218390805,\n", 212 | " 'points': 76,\n", 213 | " 'putbacks': 0,\n", 214 | " 'take_fouls_drawn': 1,\n", 215 | " 'team_id': '1610612748',\n", 216 | " 'team_name': 'MIA',\n", 217 | " 'three_pt_and1s': 0,\n", 218 | " 'three_pt_sfd': 0,\n", 219 | " 'to_pct': 0.137931034482759,\n", 220 | " 'two_pt_and1s': 1,\n", 221 | " 'two_pt_sfd': 6,\n", 222 | " 'ufg2m': 10,\n", 223 | " 'ufg3m': 5},\n", 224 | " {'afg2m': 16,\n", 225 | " 'afg3m': 5,\n", 226 | " 'dead_ball_tos': 2,\n", 227 | " 'efg': 0.45985401459854,\n", 228 | " 'fg2a': 96,\n", 229 | " 'fg2m': 45,\n", 230 | " 'fg2m_assist_pct': 0.355555555555556,\n", 231 | " 'fg2pct': 0.46875,\n", 232 | " 'fg3a': 41,\n", 233 | " 'fg3m': 12,\n", 234 | " 'fg3m_assist_pct': 0.416666666666667,\n", 235 | " 'fg3pct': 0.292682926829268,\n", 236 | " 'ftm': 20,\n", 237 | " 'live_ball_tos': 6,\n", 238 | " 'off_poss': 123,\n", 239 | " 'oreb_opps': 80,\n", 240 | " 'oreb_pct': 0.3875,\n", 241 | " 'orebs': 31,\n", 242 | " 'ortg': 1.1869918699187,\n", 243 | " 'points': 146,\n", 244 | " 'putbacks': 11,\n", 245 | " 'take_fouls_drawn': 1,\n", 246 | " 'team_id': '1610612761',\n", 247 | " 'team_name': 'TOR',\n", 248 | " 'three_pt_and1s': 0,\n", 249 | " 'three_pt_sfd': 0,\n", 250 | " 'to_pct': 0.0650406504065041,\n", 251 | " 'two_pt_and1s': 2,\n", 252 | " 'two_pt_sfd': 12,\n", 253 | " 'ufg2m': 29,\n", 254 | " 'ufg3m': 7},\n", 255 | " {'afg2m': 16,\n", 256 | " 'afg3m': 14,\n", 257 | " 'dead_ball_tos': 5,\n", 258 | " 'efg': 0.615384615384615,\n", 259 | " 'fg2a': 74,\n", 260 | " 'fg2m': 40,\n", 261 | " 'fg2m_assist_pct': 0.4,\n", 262 | " 'fg2pct': 0.540540540540541,\n", 263 | " 'fg3a': 30,\n", 264 | " 'fg3m': 16,\n", 265 | " 'fg3m_assist_pct': 0.875,\n", 266 | " 'fg3pct': 0.533333333333333,\n", 267 | " 'ftm': 21,\n", 268 | " 'live_ball_tos': 9,\n", 269 | " 'off_poss': 116,\n", 270 | " 'oreb_opps': 48,\n", 271 | " 'oreb_pct': 0.208333333333333,\n", 272 | " 'orebs': 10,\n", 273 | " 'ortg': 1.28448275862069,\n", 274 | " 'points': 149,\n", 275 | " 'putbacks': 3,\n", 276 | " 'take_fouls_drawn': 0,\n", 277 | " 'team_id': '1610612764',\n", 278 | " 'team_name': 'WAS',\n", 279 | " 'three_pt_and1s': 0,\n", 280 | " 'three_pt_sfd': 0,\n", 281 | " 'to_pct': 0.120689655172414,\n", 282 | " 'two_pt_and1s': 6,\n", 283 | " 'two_pt_sfd': 11,\n", 284 | " 'ufg2m': 24,\n", 285 | " 'ufg3m': 2},\n", 286 | " {'afg2m': 21,\n", 287 | " 'afg3m': 11,\n", 288 | " 'dead_ball_tos': 2,\n", 289 | " 'efg': 0.465116279069767,\n", 290 | " 'fg2a': 85,\n", 291 | " 'fg2m': 42,\n", 292 | " 'fg2m_assist_pct': 0.5,\n", 293 | " 'fg2pct': 0.494117647058824,\n", 294 | " 'fg3a': 44,\n", 295 | " 'fg3m': 12,\n", 296 | " 'fg3m_assist_pct': 0.916666666666667,\n", 297 | " 'fg3pct': 0.272727272727273,\n", 298 | " 'ftm': 24,\n", 299 | " 'live_ball_tos': 8,\n", 300 | " 'off_poss': 131,\n", 301 | " 'oreb_opps': 75,\n", 302 | " 'oreb_pct': 0.306666666666667,\n", 303 | " 'orebs': 23,\n", 304 | " 'ortg': 1.09923664122137,\n", 305 | " 'points': 144,\n", 306 | " 'putbacks': 9,\n", 307 | " 'take_fouls_drawn': 0,\n", 308 | " 'team_id': '1610612743',\n", 309 | " 'team_name': 'DEN',\n", 310 | " 'three_pt_and1s': 0,\n", 311 | " 'three_pt_sfd': 0,\n", 312 | " 'to_pct': 0.0763358778625954,\n", 313 | " 'two_pt_and1s': 4,\n", 314 | " 'two_pt_sfd': 16,\n", 315 | " 'ufg2m': 21,\n", 316 | " 'ufg3m': 1},\n", 317 | " {'afg2m': 9,\n", 318 | " 'afg3m': 10,\n", 319 | " 'dead_ball_tos': 10,\n", 320 | " 'efg': 0.453703703703704,\n", 321 | " 'fg2a': 74,\n", 322 | " 'fg2m': 31,\n", 323 | " 'fg2m_assist_pct': 0.290322580645161,\n", 324 | " 'fg2pct': 0.418918918918919,\n", 325 | " 'fg3a': 34,\n", 326 | " 'fg3m': 12,\n", 327 | " 'fg3m_assist_pct': 0.833333333333333,\n", 328 | " 'fg3pct': 0.352941176470588,\n", 329 | " 'ftm': 29,\n", 330 | " 'live_ball_tos': 5,\n", 331 | " 'off_poss': 125,\n", 332 | " 'oreb_opps': 64,\n", 333 | " 'oreb_pct': 0.203125,\n", 334 | " 'orebs': 13,\n", 335 | " 'ortg': 1.016,\n", 336 | " 'points': 127,\n", 337 | " 'putbacks': 3,\n", 338 | " 'take_fouls_drawn': 0,\n", 339 | " 'team_id': '1610612738',\n", 340 | " 'team_name': 'BOS',\n", 341 | " 'three_pt_and1s': 0,\n", 342 | " 'three_pt_sfd': 0,\n", 343 | " 'to_pct': 0.12,\n", 344 | " 'two_pt_and1s': 3,\n", 345 | " 'two_pt_sfd': 13,\n", 346 | " 'ufg2m': 22,\n", 347 | " 'ufg3m': 2},\n", 348 | " {'afg2m': 21,\n", 349 | " 'afg3m': 11,\n", 350 | " 'dead_ball_tos': 7,\n", 351 | " 'efg': 0.506622516556291,\n", 352 | " 'fg2a': 91,\n", 353 | " 'fg2m': 51,\n", 354 | " 'fg2m_assist_pct': 0.411764705882353,\n", 355 | " 'fg2pct': 0.56043956043956,\n", 356 | " 'fg3a': 60,\n", 357 | " 'fg3m': 17,\n", 358 | " 'fg3m_assist_pct': 0.647058823529412,\n", 359 | " 'fg3pct': 0.283333333333333,\n", 360 | " 'ftm': 29,\n", 361 | " 'live_ball_tos': 8,\n", 362 | " 'off_poss': 160,\n", 363 | " 'oreb_opps': 81,\n", 364 | " 'oreb_pct': 0.222222222222222,\n", 365 | " 'orebs': 18,\n", 366 | " 'ortg': 1.1375,\n", 367 | " 'points': 182,\n", 368 | " 'putbacks': 7,\n", 369 | " 'take_fouls_drawn': 0,\n", 370 | " 'team_id': '1610612747',\n", 371 | " 'team_name': 'LAL',\n", 372 | " 'three_pt_and1s': 1,\n", 373 | " 'three_pt_sfd': 1,\n", 374 | " 'to_pct': 0.09375,\n", 375 | " 'two_pt_and1s': 4,\n", 376 | " 'two_pt_sfd': 16,\n", 377 | " 'ufg2m': 30,\n", 378 | " 'ufg3m': 6},\n", 379 | " {'afg2m': 11,\n", 380 | " 'afg3m': 9,\n", 381 | " 'dead_ball_tos': 6,\n", 382 | " 'efg': 0.587837837837838,\n", 383 | " 'fg2a': 47,\n", 384 | " 'fg2m': 27,\n", 385 | " 'fg2m_assist_pct': 0.407407407407407,\n", 386 | " 'fg2pct': 0.574468085106383,\n", 387 | " 'fg3a': 27,\n", 388 | " 'fg3m': 11,\n", 389 | " 'fg3m_assist_pct': 0.818181818181818,\n", 390 | " 'fg3pct': 0.407407407407407,\n", 391 | " 'ftm': 33,\n", 392 | " 'live_ball_tos': 6,\n", 393 | " 'off_poss': 93,\n", 394 | " 'oreb_opps': 35,\n", 395 | " 'oreb_pct': 0.285714285714286,\n", 396 | " 'orebs': 10,\n", 397 | " 'ortg': 1.29032258064516,\n", 398 | " 'points': 120,\n", 399 | " 'putbacks': 3,\n", 400 | " 'take_fouls_drawn': 0,\n", 401 | " 'team_id': '1610612745',\n", 402 | " 'team_name': 'HOU',\n", 403 | " 'three_pt_and1s': 0,\n", 404 | " 'three_pt_sfd': 2,\n", 405 | " 'to_pct': 0.129032258064516,\n", 406 | " 'two_pt_and1s': 2,\n", 407 | " 'two_pt_sfd': 12,\n", 408 | " 'ufg2m': 16,\n", 409 | " 'ufg3m': 2},\n", 410 | " {'afg2m': 13,\n", 411 | " 'afg3m': 6,\n", 412 | " 'dead_ball_tos': 3,\n", 413 | " 'efg': 0.479381443298969,\n", 414 | " 'fg2a': 62,\n", 415 | " 'fg2m': 33,\n", 416 | " 'fg2m_assist_pct': 0.393939393939394,\n", 417 | " 'fg2pct': 0.532258064516129,\n", 418 | " 'fg3a': 35,\n", 419 | " 'fg3m': 9,\n", 420 | " 'fg3m_assist_pct': 0.666666666666667,\n", 421 | " 'fg3pct': 0.257142857142857,\n", 422 | " 'ftm': 17,\n", 423 | " 'live_ball_tos': 5,\n", 424 | " 'off_poss': 98,\n", 425 | " 'oreb_opps': 55,\n", 426 | " 'oreb_pct': 0.309090909090909,\n", 427 | " 'orebs': 17,\n", 428 | " 'ortg': 1.12244897959184,\n", 429 | " 'points': 110,\n", 430 | " 'putbacks': 2,\n", 431 | " 'take_fouls_drawn': 1,\n", 432 | " 'team_id': '1610612737',\n", 433 | " 'team_name': 'ATL',\n", 434 | " 'three_pt_and1s': 0,\n", 435 | " 'three_pt_sfd': 0,\n", 436 | " 'to_pct': 0.0816326530612245,\n", 437 | " 'two_pt_and1s': 1,\n", 438 | " 'two_pt_sfd': 8,\n", 439 | " 'ufg2m': 20,\n", 440 | " 'ufg3m': 3},\n", 441 | " {'afg2m': 16,\n", 442 | " 'afg3m': 13,\n", 443 | " 'dead_ball_tos': 8,\n", 444 | " 'efg': 0.450413223140496,\n", 445 | " 'fg2a': 67,\n", 446 | " 'fg2m': 32,\n", 447 | " 'fg2m_assist_pct': 0.5,\n", 448 | " 'fg2pct': 0.477611940298507,\n", 449 | " 'fg3a': 54,\n", 450 | " 'fg3m': 15,\n", 451 | " 'fg3m_assist_pct': 0.866666666666667,\n", 452 | " 'fg3pct': 0.277777777777778,\n", 453 | " 'ftm': 32,\n", 454 | " 'live_ball_tos': 3,\n", 455 | " 'off_poss': 131,\n", 456 | " 'oreb_opps': 74,\n", 457 | " 'oreb_pct': 0.256756756756757,\n", 458 | " 'orebs': 19,\n", 459 | " 'ortg': 1.0763358778626,\n", 460 | " 'points': 141,\n", 461 | " 'putbacks': 4,\n", 462 | " 'take_fouls_drawn': 1,\n", 463 | " 'team_id': '1610612766',\n", 464 | " 'team_name': 'CHA',\n", 465 | " 'three_pt_and1s': 1,\n", 466 | " 'three_pt_sfd': 2,\n", 467 | " 'to_pct': 0.083969465648855,\n", 468 | " 'two_pt_and1s': 4,\n", 469 | " 'two_pt_sfd': 19,\n", 470 | " 'ufg2m': 16,\n", 471 | " 'ufg3m': 2},\n", 472 | " {'afg2m': 11,\n", 473 | " 'afg3m': 2,\n", 474 | " 'dead_ball_tos': 13,\n", 475 | " 'efg': 0.411764705882353,\n", 476 | " 'fg2a': 54,\n", 477 | " 'fg2m': 29,\n", 478 | " 'fg2m_assist_pct': 0.379310344827586,\n", 479 | " 'fg2pct': 0.537037037037037,\n", 480 | " 'fg3a': 31,\n", 481 | " 'fg3m': 4,\n", 482 | " 'fg3m_assist_pct': 0.5,\n", 483 | " 'fg3pct': 0.129032258064516,\n", 484 | " 'ftm': 19,\n", 485 | " 'live_ball_tos': 9,\n", 486 | " 'off_poss': 102,\n", 487 | " 'oreb_opps': 51,\n", 488 | " 'oreb_pct': 0.274509803921569,\n", 489 | " 'orebs': 14,\n", 490 | " 'ortg': 0.872549019607843,\n", 491 | " 'points': 89,\n", 492 | " 'putbacks': 2,\n", 493 | " 'take_fouls_drawn': 0,\n", 494 | " 'team_id': '1610612753',\n", 495 | " 'team_name': 'ORL',\n", 496 | " 'three_pt_and1s': 0,\n", 497 | " 'three_pt_sfd': 0,\n", 498 | " 'to_pct': 0.215686274509804,\n", 499 | " 'two_pt_and1s': 1,\n", 500 | " 'two_pt_sfd': 11,\n", 501 | " 'ufg2m': 18,\n", 502 | " 'ufg3m': 2},\n", 503 | " {'afg2m': 21,\n", 504 | " 'afg3m': 8,\n", 505 | " 'dead_ball_tos': 5,\n", 506 | " 'efg': 0.504032258064516,\n", 507 | " 'fg2a': 81,\n", 508 | " 'fg2m': 43,\n", 509 | " 'fg2m_assist_pct': 0.488372093023256,\n", 510 | " 'fg2pct': 0.530864197530864,\n", 511 | " 'fg3a': 43,\n", 512 | " 'fg3m': 13,\n", 513 | " 'fg3m_assist_pct': 0.615384615384615,\n", 514 | " 'fg3pct': 0.302325581395349,\n", 515 | " 'ftm': 31,\n", 516 | " 'live_ball_tos': 6,\n", 517 | " 'off_poss': 135,\n", 518 | " 'oreb_opps': 68,\n", 519 | " 'oreb_pct': 0.235294117647059,\n", 520 | " 'orebs': 16,\n", 521 | " 'ortg': 1.15555555555556,\n", 522 | " 'points': 156,\n", 523 | " 'putbacks': 3,\n", 524 | " 'take_fouls_drawn': 0,\n", 525 | " 'team_id': '1610612755',\n", 526 | " 'team_name': 'PHI',\n", 527 | " 'three_pt_and1s': 0,\n", 528 | " 'three_pt_sfd': 0,\n", 529 | " 'to_pct': 0.0814814814814815,\n", 530 | " 'two_pt_and1s': 5,\n", 531 | " 'two_pt_sfd': 19,\n", 532 | " 'ufg2m': 22,\n", 533 | " 'ufg3m': 5},\n", 534 | " {'afg2m': 16,\n", 535 | " 'afg3m': 14,\n", 536 | " 'dead_ball_tos': 7,\n", 537 | " 'efg': 0.455357142857143,\n", 538 | " 'fg2a': 69,\n", 539 | " 'fg2m': 27,\n", 540 | " 'fg2m_assist_pct': 0.592592592592593,\n", 541 | " 'fg2pct': 0.391304347826087,\n", 542 | " 'fg3a': 43,\n", 543 | " 'fg3m': 16,\n", 544 | " 'fg3m_assist_pct': 0.875,\n", 545 | " 'fg3pct': 0.372093023255814,\n", 546 | " 'ftm': 8,\n", 547 | " 'live_ball_tos': 8,\n", 548 | " 'off_poss': 115,\n", 549 | " 'oreb_opps': 69,\n", 550 | " 'oreb_pct': 0.260869565217391,\n", 551 | " 'orebs': 18,\n", 552 | " 'ortg': 0.956521739130435,\n", 553 | " 'points': 110,\n", 554 | " 'putbacks': 2,\n", 555 | " 'take_fouls_drawn': 0,\n", 556 | " 'team_id': '1610612752',\n", 557 | " 'team_name': 'NYK',\n", 558 | " 'three_pt_and1s': 0,\n", 559 | " 'three_pt_sfd': 0,\n", 560 | " 'to_pct': 0.130434782608696,\n", 561 | " 'two_pt_and1s': 3,\n", 562 | " 'two_pt_sfd': 6,\n", 563 | " 'ufg2m': 11,\n", 564 | " 'ufg3m': 2},\n", 565 | " {'afg2m': 15,\n", 566 | " 'afg3m': 6,\n", 567 | " 'dead_ball_tos': 8,\n", 568 | " 'efg': 0.431578947368421,\n", 569 | " 'fg2a': 61,\n", 570 | " 'fg2m': 29,\n", 571 | " 'fg2m_assist_pct': 0.517241379310345,\n", 572 | " 'fg2pct': 0.475409836065574,\n", 573 | " 'fg3a': 34,\n", 574 | " 'fg3m': 8,\n", 575 | " 'fg3m_assist_pct': 0.75,\n", 576 | " 'fg3pct': 0.235294117647059,\n", 577 | " 'ftm': 18,\n", 578 | " 'live_ball_tos': 8,\n", 579 | " 'off_poss': 101,\n", 580 | " 'oreb_opps': 55,\n", 581 | " 'oreb_pct': 0.327272727272727,\n", 582 | " 'orebs': 18,\n", 583 | " 'ortg': 0.99009900990099,\n", 584 | " 'points': 100,\n", 585 | " 'putbacks': 1,\n", 586 | " 'take_fouls_drawn': 1,\n", 587 | " 'team_id': '1610612739',\n", 588 | " 'team_name': 'CLE',\n", 589 | " 'three_pt_and1s': 0,\n", 590 | " 'three_pt_sfd': 1,\n", 591 | " 'to_pct': 0.158415841584158,\n", 592 | " 'two_pt_and1s': 1,\n", 593 | " 'two_pt_sfd': 10,\n", 594 | " 'ufg2m': 14,\n", 595 | " 'ufg3m': 2},\n", 596 | " {'afg2m': 15,\n", 597 | " 'afg3m': 6,\n", 598 | " 'dead_ball_tos': 11,\n", 599 | " 'efg': 0.474747474747475,\n", 600 | " 'fg2a': 59,\n", 601 | " 'fg2m': 32,\n", 602 | " 'fg2m_assist_pct': 0.46875,\n", 603 | " 'fg2pct': 0.542372881355932,\n", 604 | " 'fg3a': 40,\n", 605 | " 'fg3m': 10,\n", 606 | " 'fg3m_assist_pct': 0.6,\n", 607 | " 'fg3pct': 0.25,\n", 608 | " 'ftm': 9,\n", 609 | " 'live_ball_tos': 8,\n", 610 | " 'off_poss': 108,\n", 611 | " 'oreb_opps': 56,\n", 612 | " 'oreb_pct': 0.232142857142857,\n", 613 | " 'orebs': 13,\n", 614 | " 'ortg': 0.953703703703704,\n", 615 | " 'points': 103,\n", 616 | " 'putbacks': 4,\n", 617 | " 'take_fouls_drawn': 0,\n", 618 | " 'team_id': '1610612744',\n", 619 | " 'team_name': 'GSW',\n", 620 | " 'three_pt_and1s': 0,\n", 621 | " 'three_pt_sfd': 0,\n", 622 | " 'to_pct': 0.175925925925926,\n", 623 | " 'two_pt_and1s': 3,\n", 624 | " 'two_pt_sfd': 6,\n", 625 | " 'ufg2m': 17,\n", 626 | " 'ufg3m': 4},\n", 627 | " {'afg2m': 8,\n", 628 | " 'afg3m': 7,\n", 629 | " 'dead_ball_tos': 4,\n", 630 | " 'efg': 0.445945945945946,\n", 631 | " 'fg2a': 44,\n", 632 | " 'fg2m': 18,\n", 633 | " 'fg2m_assist_pct': 0.444444444444444,\n", 634 | " 'fg2pct': 0.409090909090909,\n", 635 | " 'fg3a': 30,\n", 636 | " 'fg3m': 10,\n", 637 | " 'fg3m_assist_pct': 0.7,\n", 638 | " 'fg3pct': 0.333333333333333,\n", 639 | " 'ftm': 14,\n", 640 | " 'live_ball_tos': 4,\n", 641 | " 'off_poss': 74,\n", 642 | " 'oreb_opps': 45,\n", 643 | " 'oreb_pct': 0.333333333333333,\n", 644 | " 'orebs': 15,\n", 645 | " 'ortg': 1.08108108108108,\n", 646 | " 'points': 80,\n", 647 | " 'putbacks': 3,\n", 648 | " 'take_fouls_drawn': 0,\n", 649 | " 'team_id': '1610612757',\n", 650 | " 'team_name': 'POR',\n", 651 | " 'three_pt_and1s': 1,\n", 652 | " 'three_pt_sfd': 1,\n", 653 | " 'to_pct': 0.108108108108108,\n", 654 | " 'two_pt_and1s': 0,\n", 655 | " 'two_pt_sfd': 4,\n", 656 | " 'ufg2m': 10,\n", 657 | " 'ufg3m': 3},\n", 658 | " {'afg2m': 14,\n", 659 | " 'afg3m': 9,\n", 660 | " 'dead_ball_tos': 7,\n", 661 | " 'efg': 0.542682926829268,\n", 662 | " 'fg2a': 60,\n", 663 | " 'fg2m': 28,\n", 664 | " 'fg2m_assist_pct': 0.5,\n", 665 | " 'fg2pct': 0.466666666666667,\n", 666 | " 'fg3a': 22,\n", 667 | " 'fg3m': 11,\n", 668 | " 'fg3m_assist_pct': 0.818181818181818,\n", 669 | " 'fg3pct': 0.5,\n", 670 | " 'ftm': 21,\n", 671 | " 'live_ball_tos': 7,\n", 672 | " 'off_poss': 89,\n", 673 | " 'oreb_opps': 43,\n", 674 | " 'oreb_pct': 0.418604651162791,\n", 675 | " 'orebs': 18,\n", 676 | " 'ortg': 1.23595505617978,\n", 677 | " 'points': 110,\n", 678 | " 'putbacks': 2,\n", 679 | " 'take_fouls_drawn': 1,\n", 680 | " 'team_id': '1610612740',\n", 681 | " 'team_name': 'NOP',\n", 682 | " 'three_pt_and1s': 0,\n", 683 | " 'three_pt_sfd': 0,\n", 684 | " 'to_pct': 0.157303370786517,\n", 685 | " 'two_pt_and1s': 1,\n", 686 | " 'two_pt_sfd': 7,\n", 687 | " 'ufg2m': 14,\n", 688 | " 'ufg3m': 2},\n", 689 | " {'afg2m': 13,\n", 690 | " 'afg3m': 5,\n", 691 | " 'dead_ball_tos': 10,\n", 692 | " 'efg': 0.3671875,\n", 693 | " 'fg2a': 79,\n", 694 | " 'fg2m': 32,\n", 695 | " 'fg2m_assist_pct': 0.40625,\n", 696 | " 'fg2pct': 0.405063291139241,\n", 697 | " 'fg3a': 49,\n", 698 | " 'fg3m': 10,\n", 699 | " 'fg3m_assist_pct': 0.5,\n", 700 | " 'fg3pct': 0.204081632653061,\n", 701 | " 'ftm': 19,\n", 702 | " 'live_ball_tos': 4,\n", 703 | " 'off_poss': 124,\n", 704 | " 'oreb_opps': 83,\n", 705 | " 'oreb_pct': 0.301204819277108,\n", 706 | " 'orebs': 25,\n", 707 | " 'ortg': 0.911290322580645,\n", 708 | " 'points': 113,\n", 709 | " 'putbacks': 5,\n", 710 | " 'take_fouls_drawn': 1,\n", 711 | " 'team_id': '1610612754',\n", 712 | " 'team_name': 'IND',\n", 713 | " 'three_pt_and1s': 0,\n", 714 | " 'three_pt_sfd': 0,\n", 715 | " 'to_pct': 0.112903225806452,\n", 716 | " 'two_pt_and1s': 2,\n", 717 | " 'two_pt_sfd': 9,\n", 718 | " 'ufg2m': 19,\n", 719 | " 'ufg3m': 5},\n", 720 | " {'afg2m': 10,\n", 721 | " 'afg3m': 5,\n", 722 | " 'dead_ball_tos': 7,\n", 723 | " 'efg': 0.482954545454545,\n", 724 | " 'fg2a': 53,\n", 725 | " 'fg2m': 32,\n", 726 | " 'fg2m_assist_pct': 0.3125,\n", 727 | " 'fg2pct': 0.60377358490566,\n", 728 | " 'fg3a': 35,\n", 729 | " 'fg3m': 7,\n", 730 | " 'fg3m_assist_pct': 0.714285714285714,\n", 731 | " 'fg3pct': 0.2,\n", 732 | " 'ftm': 13,\n", 733 | " 'live_ball_tos': 3,\n", 734 | " 'off_poss': 90,\n", 735 | " 'oreb_opps': 48,\n", 736 | " 'oreb_pct': 0.3125,\n", 737 | " 'orebs': 15,\n", 738 | " 'ortg': 1.08888888888889,\n", 739 | " 'points': 98,\n", 740 | " 'putbacks': 3,\n", 741 | " 'take_fouls_drawn': 0,\n", 742 | " 'team_id': '1610612742',\n", 743 | " 'team_name': 'DAL',\n", 744 | " 'three_pt_and1s': 0,\n", 745 | " 'three_pt_sfd': 0,\n", 746 | " 'to_pct': 0.111111111111111,\n", 747 | " 'two_pt_and1s': 3,\n", 748 | " 'two_pt_sfd': 8,\n", 749 | " 'ufg2m': 22,\n", 750 | " 'ufg3m': 2},\n", 751 | " {'afg2m': 5,\n", 752 | " 'afg3m': 4,\n", 753 | " 'dead_ball_tos': 5,\n", 754 | " 'efg': 0.487012987012987,\n", 755 | " 'fg2a': 47,\n", 756 | " 'fg2m': 24,\n", 757 | " 'fg2m_assist_pct': 0.208333333333333,\n", 758 | " 'fg2pct': 0.51063829787234,\n", 759 | " 'fg3a': 30,\n", 760 | " 'fg3m': 9,\n", 761 | " 'fg3m_assist_pct': 0.444444444444444,\n", 762 | " 'fg3pct': 0.3,\n", 763 | " 'ftm': 16,\n", 764 | " 'live_ball_tos': 4,\n", 765 | " 'off_poss': 87,\n", 766 | " 'oreb_opps': 44,\n", 767 | " 'oreb_pct': 0.204545454545455,\n", 768 | " 'orebs': 9,\n", 769 | " 'ortg': 1.04597701149425,\n", 770 | " 'points': 91,\n", 771 | " 'putbacks': 3,\n", 772 | " 'take_fouls_drawn': 1,\n", 773 | " 'team_id': '1610612750',\n", 774 | " 'team_name': 'MIN',\n", 775 | " 'three_pt_and1s': 0,\n", 776 | " 'three_pt_sfd': 0,\n", 777 | " 'to_pct': 0.103448275862069,\n", 778 | " 'two_pt_and1s': 0,\n", 779 | " 'two_pt_sfd': 5,\n", 780 | " 'ufg2m': 19,\n", 781 | " 'ufg3m': 5},\n", 782 | " {'afg2m': 17,\n", 783 | " 'afg3m': 6,\n", 784 | " 'dead_ball_tos': 5,\n", 785 | " 'efg': 0.400943396226415,\n", 786 | " 'fg2a': 70,\n", 787 | " 'fg2m': 32,\n", 788 | " 'fg2m_assist_pct': 0.53125,\n", 789 | " 'fg2pct': 0.457142857142857,\n", 790 | " 'fg3a': 36,\n", 791 | " 'fg3m': 7,\n", 792 | " 'fg3m_assist_pct': 0.857142857142857,\n", 793 | " 'fg3pct': 0.194444444444444,\n", 794 | " 'ftm': 10,\n", 795 | " 'live_ball_tos': 10,\n", 796 | " 'off_poss': 112,\n", 797 | " 'oreb_opps': 66,\n", 798 | " 'oreb_pct': 0.227272727272727,\n", 799 | " 'orebs': 15,\n", 800 | " 'ortg': 0.848214285714286,\n", 801 | " 'points': 95,\n", 802 | " 'putbacks': 2,\n", 803 | " 'take_fouls_drawn': 2,\n", 804 | " 'team_id': '1610612759',\n", 805 | " 'team_name': 'SAS',\n", 806 | " 'three_pt_and1s': 0,\n", 807 | " 'three_pt_sfd': 0,\n", 808 | " 'to_pct': 0.133928571428571,\n", 809 | " 'two_pt_and1s': 1,\n", 810 | " 'two_pt_sfd': 6,\n", 811 | " 'ufg2m': 15,\n", 812 | " 'ufg3m': 1},\n", 813 | " {'afg2m': 11,\n", 814 | " 'afg3m': 8,\n", 815 | " 'dead_ball_tos': 5,\n", 816 | " 'efg': 0.461904761904762,\n", 817 | " 'fg2a': 66,\n", 818 | " 'fg2m': 32,\n", 819 | " 'fg2m_assist_pct': 0.34375,\n", 820 | " 'fg2pct': 0.484848484848485,\n", 821 | " 'fg3a': 39,\n", 822 | " 'fg3m': 11,\n", 823 | " 'fg3m_assist_pct': 0.727272727272727,\n", 824 | " 'fg3pct': 0.282051282051282,\n", 825 | " 'ftm': 19,\n", 826 | " 'live_ball_tos': 6,\n", 827 | " 'off_poss': 108,\n", 828 | " 'oreb_opps': 62,\n", 829 | " 'oreb_pct': 0.306451612903226,\n", 830 | " 'orebs': 19,\n", 831 | " 'ortg': 1.07407407407407,\n", 832 | " 'points': 116,\n", 833 | " 'putbacks': 5,\n", 834 | " 'take_fouls_drawn': 0,\n", 835 | " 'team_id': '1610612760',\n", 836 | " 'team_name': 'OKC',\n", 837 | " 'three_pt_and1s': 0,\n", 838 | " 'three_pt_sfd': 1,\n", 839 | " 'to_pct': 0.101851851851852,\n", 840 | " 'two_pt_and1s': 1,\n", 841 | " 'two_pt_sfd': 10,\n", 842 | " 'ufg2m': 21,\n", 843 | " 'ufg3m': 3},\n", 844 | " {'afg2m': 14,\n", 845 | " 'afg3m': 10,\n", 846 | " 'dead_ball_tos': 7,\n", 847 | " 'efg': 0.477777777777778,\n", 848 | " 'fg2a': 59,\n", 849 | " 'fg2m': 25,\n", 850 | " 'fg2m_assist_pct': 0.56,\n", 851 | " 'fg2pct': 0.423728813559322,\n", 852 | " 'fg3a': 31,\n", 853 | " 'fg3m': 12,\n", 854 | " 'fg3m_assist_pct': 0.833333333333333,\n", 855 | " 'fg3pct': 0.387096774193548,\n", 856 | " 'ftm': 14,\n", 857 | " 'live_ball_tos': 4,\n", 858 | " 'off_poss': 95,\n", 859 | " 'oreb_opps': 53,\n", 860 | " 'oreb_pct': 0.264150943396226,\n", 861 | " 'orebs': 14,\n", 862 | " 'ortg': 1.05263157894737,\n", 863 | " 'points': 100,\n", 864 | " 'putbacks': 1,\n", 865 | " 'take_fouls_drawn': 1,\n", 866 | " 'team_id': '1610612746',\n", 867 | " 'team_name': 'LAC',\n", 868 | " 'three_pt_and1s': 0,\n", 869 | " 'three_pt_sfd': 0,\n", 870 | " 'to_pct': 0.115789473684211,\n", 871 | " 'two_pt_and1s': 1,\n", 872 | " 'two_pt_sfd': 8,\n", 873 | " 'ufg2m': 11,\n", 874 | " 'ufg3m': 2},\n", 875 | " {'afg2m': 14,\n", 876 | " 'afg3m': 12,\n", 877 | " 'dead_ball_tos': 8,\n", 878 | " 'efg': 0.533653846153846,\n", 879 | " 'fg2a': 68,\n", 880 | " 'fg2m': 36,\n", 881 | " 'fg2m_assist_pct': 0.388888888888889,\n", 882 | " 'fg2pct': 0.529411764705882,\n", 883 | " 'fg3a': 36,\n", 884 | " 'fg3m': 13,\n", 885 | " 'fg3m_assist_pct': 0.923076923076923,\n", 886 | " 'fg3pct': 0.361111111111111,\n", 887 | " 'ftm': 25,\n", 888 | " 'live_ball_tos': 8,\n", 889 | " 'off_poss': 115,\n", 890 | " 'oreb_opps': 54,\n", 891 | " 'oreb_pct': 0.333333333333333,\n", 892 | " 'orebs': 18,\n", 893 | " 'ortg': 1.18260869565217,\n", 894 | " 'points': 136,\n", 895 | " 'putbacks': 1,\n", 896 | " 'take_fouls_drawn': 0,\n", 897 | " 'team_id': '1610612758',\n", 898 | " 'team_name': 'SAC',\n", 899 | " 'three_pt_and1s': 0,\n", 900 | " 'three_pt_sfd': 1,\n", 901 | " 'to_pct': 0.139130434782609,\n", 902 | " 'two_pt_and1s': 3,\n", 903 | " 'two_pt_sfd': 16,\n", 904 | " 'ufg2m': 22,\n", 905 | " 'ufg3m': 1},\n", 906 | " {'afg2m': 21,\n", 907 | " 'afg3m': 10,\n", 908 | " 'dead_ball_tos': 5,\n", 909 | " 'efg': 0.460629921259843,\n", 910 | " 'fg2a': 87,\n", 911 | " 'fg2m': 39,\n", 912 | " 'fg2m_assist_pct': 0.538461538461538,\n", 913 | " 'fg2pct': 0.448275862068966,\n", 914 | " 'fg3a': 40,\n", 915 | " 'fg3m': 13,\n", 916 | " 'fg3m_assist_pct': 0.769230769230769,\n", 917 | " 'fg3pct': 0.325,\n", 918 | " 'ftm': 19,\n", 919 | " 'live_ball_tos': 9,\n", 920 | " 'off_poss': 127,\n", 921 | " 'oreb_opps': 75,\n", 922 | " 'oreb_pct': 0.346666666666667,\n", 923 | " 'orebs': 26,\n", 924 | " 'ortg': 1.07086614173228,\n", 925 | " 'points': 136,\n", 926 | " 'putbacks': 6,\n", 927 | " 'take_fouls_drawn': 1,\n", 928 | " 'team_id': '1610612751',\n", 929 | " 'team_name': 'BKN',\n", 930 | " 'three_pt_and1s': 0,\n", 931 | " 'three_pt_sfd': 1,\n", 932 | " 'to_pct': 0.110236220472441,\n", 933 | " 'two_pt_and1s': 1,\n", 934 | " 'two_pt_sfd': 7,\n", 935 | " 'ufg2m': 18,\n", 936 | " 'ufg3m': 3},\n", 937 | " {'afg2m': 7,\n", 938 | " 'afg3m': 4,\n", 939 | " 'dead_ball_tos': 11,\n", 940 | " 'efg': 0.460227272727273,\n", 941 | " 'fg2a': 61,\n", 942 | " 'fg2m': 30,\n", 943 | " 'fg2m_assist_pct': 0.233333333333333,\n", 944 | " 'fg2pct': 0.491803278688525,\n", 945 | " 'fg3a': 27,\n", 946 | " 'fg3m': 7,\n", 947 | " 'fg3m_assist_pct': 0.571428571428571,\n", 948 | " 'fg3pct': 0.259259259259259,\n", 949 | " 'ftm': 30,\n", 950 | " 'live_ball_tos': 4,\n", 951 | " 'off_poss': 95,\n", 952 | " 'oreb_opps': 49,\n", 953 | " 'oreb_pct': 0.428571428571429,\n", 954 | " 'orebs': 21,\n", 955 | " 'ortg': 1.16842105263158,\n", 956 | " 'points': 111,\n", 957 | " 'putbacks': 5,\n", 958 | " 'take_fouls_drawn': 3,\n", 959 | " 'team_id': '1610612763',\n", 960 | " 'team_name': 'MEM',\n", 961 | " 'three_pt_and1s': 0,\n", 962 | " 'three_pt_sfd': 1,\n", 963 | " 'to_pct': 0.157894736842105,\n", 964 | " 'two_pt_and1s': 4,\n", 965 | " 'two_pt_sfd': 17,\n", 966 | " 'ufg2m': 23,\n", 967 | " 'ufg3m': 3}]" 968 | ] 969 | }, 970 | "execution_count": 2, 971 | "metadata": {}, 972 | "output_type": "execute_result" 973 | } 974 | ], 975 | "source": [ 976 | "url = \"https://api.pbpstats.com/get-score-time-summary/nba\"\n", 977 | "params = {\n", 978 | " \"Season\": \"2021-22\",\n", 979 | " \"SeasonType\": \"Regular Season\",\n", 980 | " \"Type\": \"Team\", # Options: Team, Lineup, Opponent, LineupOpponent\n", 981 | " \"FromMargin\": -3,\n", 982 | " \"ToMargin\": 3,\n", 983 | " \"FromTime\": 300, # in seconds remaining in the period at the start of a possession\n", 984 | " \"ToTime\": 120, # in seconds remaining in the period at the start of a possession\n", 985 | " \"PeriodGte\": 4 # Could also use PeriodLte or period less than or equal to or PeriodEquals for period equal to\n", 986 | "}\n", 987 | "response = requests.get(url, params=params)\n", 988 | "response_json = response.json()\n", 989 | "response_json[\"results\"]" 990 | ] 991 | }, 992 | { 993 | "cell_type": "code", 994 | "execution_count": null, 995 | "id": "64e11275-6c38-429f-80b3-b5e5be0e75c0", 996 | "metadata": {}, 997 | "outputs": [], 998 | "source": [] 999 | } 1000 | ], 1001 | "metadata": { 1002 | "kernelspec": { 1003 | "display_name": "playground", 1004 | "language": "python", 1005 | "name": "playground" 1006 | }, 1007 | "language_info": { 1008 | "codemirror_mode": { 1009 | "name": "ipython", 1010 | "version": 3 1011 | }, 1012 | "file_extension": ".py", 1013 | "mimetype": "text/x-python", 1014 | "name": "python", 1015 | "nbconvert_exporter": "python", 1016 | "pygments_lexer": "ipython3", 1017 | "version": "3.8.9" 1018 | } 1019 | }, 1020 | "nbformat": 4, 1021 | "nbformat_minor": 5 1022 | } 1023 | -------------------------------------------------------------------------------- /get-team-leverage-summary.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "id": "c380f94a-1ef2-48d6-914f-9bf2e7115580", 6 | "metadata": {}, 7 | "source": [ 8 | "This endpoint can be used to get team efficiency and four factors stats based on the leverage state. These are regular season only stats" 9 | ] 10 | }, 11 | { 12 | "cell_type": "code", 13 | "execution_count": 1, 14 | "id": "633b6920-8213-4458-8131-72409abd9537", 15 | "metadata": {}, 16 | "outputs": [], 17 | "source": [ 18 | "import requests" 19 | ] 20 | }, 21 | { 22 | "cell_type": "markdown", 23 | "id": "eeab0956-393b-494d-b19d-a878e169387f", 24 | "metadata": {}, 25 | "source": [ 26 | "### NBA - High and Very High leverage" 27 | ] 28 | }, 29 | { 30 | "cell_type": "code", 31 | "execution_count": 2, 32 | "id": "967ffe17-ab8e-4fad-bc54-dd8a8dabf296", 33 | "metadata": {}, 34 | "outputs": [ 35 | { 36 | "data": { 37 | "text/plain": [ 38 | "{'team': 'LAC',\n", 39 | " 'off_poss': 249,\n", 40 | " 'def_poss': 252,\n", 41 | " 'off_rtg': 122.9,\n", 42 | " 'def_rtg': 123.0,\n", 43 | " 'net_rtg': -0.1,\n", 44 | " 'seconds_per_poss_off': 16.0,\n", 45 | " 'seconds_per_poss_def': 15.9,\n", 46 | " 'efg': 0.5684,\n", 47 | " 'opp_efg': 0.5039,\n", 48 | " 'fg2_pct': 0.5,\n", 49 | " 'opp_fg2_pct': 0.4655,\n", 50 | " 'fg3_pct': 0.4512,\n", 51 | " 'opp_fg3_pct': 0.3902,\n", 52 | " 'oreb_pct': 0.287,\n", 53 | " 'dreb_pct': 0.6119,\n", 54 | " 'to_per_100': 11.6,\n", 55 | " 'opp_to_per_100': 11.5,\n", 56 | " 'fta_per_fga': 0.396,\n", 57 | " 'opp_fta_per_fga': 0.277}" 58 | ] 59 | }, 60 | "execution_count": 2, 61 | "metadata": {}, 62 | "output_type": "execute_result" 63 | } 64 | ], 65 | "source": [ 66 | "url = \"https://api.pbpstats.com/get-team-leverage-summary/nba\"\n", 67 | "params = {\n", 68 | " \"Season\": \"2021-22\",\n", 69 | " \"Leverage\": \"High,VeryHigh\" # options are Low, Medium, High and VeryHigh. Comma separated for multiple.\n", 70 | "}\n", 71 | "response = requests.get(url, params=params)\n", 72 | "response_json = response.json()\n", 73 | "response_json['results'][0]" 74 | ] 75 | }, 76 | { 77 | "cell_type": "markdown", 78 | "id": "056232eb-2821-46d7-bbd9-1d36ccfb75c3", 79 | "metadata": {}, 80 | "source": [ 81 | "### WNBA - Medium, High and Very High leverage" 82 | ] 83 | }, 84 | { 85 | "cell_type": "code", 86 | "execution_count": 3, 87 | "id": "528a531b-9aca-4d58-b255-0a095cf3e0fd", 88 | "metadata": {}, 89 | "outputs": [ 90 | { 91 | "data": { 92 | "text/plain": [ 93 | "{'team': 'CHI',\n", 94 | " 'off_poss': 447,\n", 95 | " 'def_poss': 444,\n", 96 | " 'off_rtg': 102.7,\n", 97 | " 'def_rtg': 95.7,\n", 98 | " 'net_rtg': 7.0,\n", 99 | " 'seconds_per_poss_off': 15.2,\n", 100 | " 'seconds_per_poss_def': 15.0,\n", 101 | " 'efg': 0.5176,\n", 102 | " 'opp_efg': 0.4633,\n", 103 | " 'fg2_pct': 0.5326,\n", 104 | " 'opp_fg2_pct': 0.4419,\n", 105 | " 'fg3_pct': 0.3211,\n", 106 | " 'opp_fg3_pct': 0.3421,\n", 107 | " 'oreb_pct': 0.2487,\n", 108 | " 'dreb_pct': 0.6881,\n", 109 | " 'to_per_100': 19.5,\n", 110 | " 'opp_to_per_100': 20.7,\n", 111 | " 'fta_per_fga': 0.257,\n", 112 | " 'opp_fta_per_fga': 0.26}" 113 | ] 114 | }, 115 | "execution_count": 3, 116 | "metadata": {}, 117 | "output_type": "execute_result" 118 | } 119 | ], 120 | "source": [ 121 | "url = \"https://api.pbpstats.com/get-team-leverage-summary/wnba\"\n", 122 | "params = {\n", 123 | " \"Season\": \"2022\",\n", 124 | " \"Leverage\": \"Medium,High,VeryHigh\" # options are Low, Medium, High and VeryHigh. Comma separated for multiple.\n", 125 | "}\n", 126 | "response = requests.get(url, params=params)\n", 127 | "response_json = response.json()\n", 128 | "response_json['results'][0]" 129 | ] 130 | }, 131 | { 132 | "cell_type": "code", 133 | "execution_count": null, 134 | "id": "89b9b0ac-59c3-4f26-a83c-c91b221c191c", 135 | "metadata": {}, 136 | "outputs": [], 137 | "source": [] 138 | } 139 | ], 140 | "metadata": { 141 | "kernelspec": { 142 | "display_name": "playground", 143 | "language": "python", 144 | "name": "playground" 145 | }, 146 | "language_info": { 147 | "codemirror_mode": { 148 | "name": "ipython", 149 | "version": 3 150 | }, 151 | "file_extension": ".py", 152 | "mimetype": "text/x-python", 153 | "name": "python", 154 | "nbconvert_exporter": "python", 155 | "pygments_lexer": "ipython3", 156 | "version": "3.8.9" 157 | } 158 | }, 159 | "nbformat": 4, 160 | "nbformat_minor": 5 161 | } 162 | -------------------------------------------------------------------------------- /get-team-players-for-season.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "id": "838cd267-835d-4656-ae2e-610b33705103", 6 | "metadata": {}, 7 | "source": [ 8 | "The endpoint can be used to get all the players for a team for a season" 9 | ] 10 | }, 11 | { 12 | "cell_type": "code", 13 | "execution_count": 1, 14 | "id": "a0db7d5c-cacd-4a45-ae78-21e52ef042ce", 15 | "metadata": {}, 16 | "outputs": [], 17 | "source": [ 18 | "import requests" 19 | ] 20 | }, 21 | { 22 | "cell_type": "markdown", 23 | "id": "01932d14-b1d4-4a37-86a6-f32fc25b79da", 24 | "metadata": {}, 25 | "source": [ 26 | "### 2021-22 Atlanta Hawks" 27 | ] 28 | }, 29 | { 30 | "cell_type": "code", 31 | "execution_count": 2, 32 | "id": "4dc7a032-0cdf-40d4-a511-3c9c81c25083", 33 | "metadata": {}, 34 | "outputs": [ 35 | { 36 | "data": { 37 | "text/plain": [ 38 | "{'202362': 'Lance Stephenson',\n", 39 | " '203524': 'Solomon Hill',\n", 40 | " '1628381': 'John Collins',\n", 41 | " '1629631': \"De'Andre Hunter\",\n", 42 | " '203991': 'Clint Capela',\n", 43 | " '1628989': 'Kevin Huerter',\n", 44 | " '1629027': 'Trae Young',\n", 45 | " '203992': 'Bogdan Bogdanovic',\n", 46 | " '1626153': 'Delon Wright',\n", 47 | " '1630536': 'Sharife Cooper',\n", 48 | " '203476': 'Gorgui Dieng',\n", 49 | " '1629629': 'Cam Reddish',\n", 50 | " '1627789': 'Timothe Luwawu-Cabarrot',\n", 51 | " '1630552': 'Jalen Johnson',\n", 52 | " '1630219': 'Skylar Mays',\n", 53 | " '101150': 'Lou Williams',\n", 54 | " '201568': 'Danilo Gallinari',\n", 55 | " '1630168': 'Onyeka Okongwu',\n", 56 | " '1627760': 'Cat Barber',\n", 57 | " '1628411': 'Wes Iwundu',\n", 58 | " '1630707': 'Malik Ellison',\n", 59 | " '1630792': 'Malcolm Hill',\n", 60 | " '1630602': 'Chaundee Brown Jr.',\n", 61 | " '1628419': 'Cameron Oliver',\n", 62 | " '1629598': 'Chris Clemons',\n", 63 | " '1628995': 'Kevin Knox II'}" 64 | ] 65 | }, 66 | "execution_count": 2, 67 | "metadata": {}, 68 | "output_type": "execute_result" 69 | } 70 | ], 71 | "source": [ 72 | "players_url = \"https://api.pbpstats.com/get-team-players-for-season\"\n", 73 | "players_params = {\n", 74 | " \"Season\": \"2021-22\",\n", 75 | " \"SeasonType\": \"Regular Season\",\n", 76 | " \"TeamId\": \"1610612737\"\n", 77 | "}\n", 78 | "players_response = requests.get(players_url, params=players_params)\n", 79 | "players = players_response.json()\n", 80 | "players[\"players\"]" 81 | ] 82 | }, 83 | { 84 | "cell_type": "markdown", 85 | "id": "e9490ee2-a59c-4d3b-b6cd-87c365c2987e", 86 | "metadata": {}, 87 | "source": [ 88 | "### 2020-21 and 2021-22 Golden State Warriors" 89 | ] 90 | }, 91 | { 92 | "cell_type": "code", 93 | "execution_count": 3, 94 | "id": "bf8174d9-90ee-42c5-a1a7-5f3f58b7f9f8", 95 | "metadata": {}, 96 | "outputs": [ 97 | { 98 | "data": { 99 | "text/plain": [ 100 | "{'1629308': 'Juan Toscano-Anderson',\n", 101 | " '1628539': 'Mychal Mulder',\n", 102 | " '1629673': 'Jordan Poole',\n", 103 | " '1626162': 'Kelly Oubre Jr.',\n", 104 | " '1629672': 'Eric Paschall',\n", 105 | " '1627737': 'Marquese Chriss',\n", 106 | " '1627814': 'Damion Lee',\n", 107 | " '1630164': 'James Wiseman',\n", 108 | " '202954': 'Brad Wanamaker',\n", 109 | " '203952': 'Andrew Wiggins',\n", 110 | " '1626172': 'Kevon Looney',\n", 111 | " '203145': 'Kent Bazemore',\n", 112 | " '201939': 'Stephen Curry',\n", 113 | " '203110': 'Draymond Green',\n", 114 | " '202691': 'Klay Thompson',\n", 115 | " '1630185': 'Nico Mannion',\n", 116 | " '1629346': 'Alen Smailagic',\n", 117 | " '1627780': 'Gary Payton II',\n", 118 | " '1628395': 'Jordan Bell',\n", 119 | " '2738': 'Andre Iguodala',\n", 120 | " '202357': 'Nemanja Bjelica',\n", 121 | " '1629185': 'Chris Chiozza',\n", 122 | " '1630228': 'Jonathan Kuminga',\n", 123 | " '1630288': 'Jeff Dowtin',\n", 124 | " '1629683': 'Quinndary Weatherspoon',\n", 125 | " '1630541': 'Moses Moody',\n", 126 | " '203490': 'Otto Porter Jr.'}" 127 | ] 128 | }, 129 | "execution_count": 3, 130 | "metadata": {}, 131 | "output_type": "execute_result" 132 | } 133 | ], 134 | "source": [ 135 | "players_url = \"https://api.pbpstats.com/get-team-players-for-season\"\n", 136 | "players_params = {\n", 137 | " \"Season\": \"2020-21,2021-22\",\n", 138 | " \"SeasonType\": \"Regular Season\",\n", 139 | " \"TeamId\": \"1610612744\"\n", 140 | "}\n", 141 | "players_response = requests.get(players_url, params=players_params)\n", 142 | "players = players_response.json()\n", 143 | "players[\"players\"]" 144 | ] 145 | }, 146 | { 147 | "cell_type": "markdown", 148 | "id": "5a1d749d-3b1d-413b-9fd8-fac97ffb2f83", 149 | "metadata": {}, 150 | "source": [ 151 | "### 2022 Seattle Storm" 152 | ] 153 | }, 154 | { 155 | "cell_type": "code", 156 | "execution_count": 4, 157 | "id": "86905860-7a5b-4801-9c1c-de458046cadf", 158 | "metadata": {}, 159 | "outputs": [ 160 | { 161 | "data": { 162 | "text/plain": [ 163 | "{'1628931': 'Gabby Williams',\n", 164 | " '1629496': 'Ezi Magbegor',\n", 165 | " '203855': 'Stephanie Talbot',\n", 166 | " '1627668': 'Breanna Stewart',\n", 167 | " '202650': 'Jantel Lavender',\n", 168 | " '201896': 'Briann January',\n", 169 | " '204334': 'Reshanda Gray',\n", 170 | " '100720': 'Sue Bird',\n", 171 | " '202259': 'Epiphanny Prince',\n", 172 | " '204319': 'Jewell Loyd',\n", 173 | " '1631073': 'Raina Perez'}" 174 | ] 175 | }, 176 | "execution_count": 4, 177 | "metadata": {}, 178 | "output_type": "execute_result" 179 | } 180 | ], 181 | "source": [ 182 | "players_url = \"https://api.pbpstats.com/get-team-players-for-season\"\n", 183 | "players_params = {\n", 184 | " \"Season\": \"2022\",\n", 185 | " \"SeasonType\": \"Regular Season\",\n", 186 | " \"TeamId\": \"1611661328\"\n", 187 | "}\n", 188 | "players_response = requests.get(players_url, params=players_params)\n", 189 | "players = players_response.json()\n", 190 | "players[\"players\"]" 191 | ] 192 | }, 193 | { 194 | "cell_type": "markdown", 195 | "id": "a34dec1a-a3a4-429e-8977-e32243d1932d", 196 | "metadata": {}, 197 | "source": [ 198 | "### 2021 and 2022 Seattle Storm" 199 | ] 200 | }, 201 | { 202 | "cell_type": "code", 203 | "execution_count": 5, 204 | "id": "80d1de1e-6ff4-46a7-b6d6-57f5130ad526", 205 | "metadata": {}, 206 | "outputs": [ 207 | { 208 | "data": { 209 | "text/plain": [ 210 | "{'1627668': 'Breanna Stewart',\n", 211 | " '1629478': 'Katie Lou Samuelson',\n", 212 | " '204319': 'Jewell Loyd',\n", 213 | " '200676': 'Candice Dupree',\n", 214 | " '1630461': 'Kiana Williams',\n", 215 | " '100720': 'Sue Bird',\n", 216 | " '203855': 'Stephanie Talbot',\n", 217 | " '1628886': 'Jordin Canada',\n", 218 | " '1629496': 'Ezi Magbegor',\n", 219 | " '1630114': 'Mikiah Herbert Harrigan',\n", 220 | " '1629568': 'Kennedy Burke',\n", 221 | " '1628920': 'Mercedes Russell',\n", 222 | " '202259': 'Epiphanny Prince',\n", 223 | " '204332': 'Cierra Burdick',\n", 224 | " '1628317': 'Karlie Samuelson',\n", 225 | " '1628931': 'Gabby Williams',\n", 226 | " '202650': 'Jantel Lavender',\n", 227 | " '201896': 'Briann January',\n", 228 | " '204334': 'Reshanda Gray',\n", 229 | " '1631073': 'Raina Perez'}" 230 | ] 231 | }, 232 | "execution_count": 5, 233 | "metadata": {}, 234 | "output_type": "execute_result" 235 | } 236 | ], 237 | "source": [ 238 | "players_url = \"https://api.pbpstats.com/get-team-players-for-season\"\n", 239 | "players_params = {\n", 240 | " \"Season\": \"2021,2022\",\n", 241 | " \"SeasonType\": \"Regular Season\",\n", 242 | " \"TeamId\": \"1611661328\"\n", 243 | "}\n", 244 | "players_response = requests.get(players_url, params=players_params)\n", 245 | "players = players_response.json()\n", 246 | "players[\"players\"]" 247 | ] 248 | }, 249 | { 250 | "cell_type": "code", 251 | "execution_count": null, 252 | "id": "45d51800-c8f5-49ba-85bf-47bf80fcbcca", 253 | "metadata": {}, 254 | "outputs": [], 255 | "source": [] 256 | } 257 | ], 258 | "metadata": { 259 | "kernelspec": { 260 | "display_name": "playground", 261 | "language": "python", 262 | "name": "playground" 263 | }, 264 | "language_info": { 265 | "codemirror_mode": { 266 | "name": "ipython", 267 | "version": 3 268 | }, 269 | "file_extension": ".py", 270 | "mimetype": "text/x-python", 271 | "name": "python", 272 | "nbconvert_exporter": "python", 273 | "pygments_lexer": "ipython3", 274 | "version": "3.8.9" 275 | } 276 | }, 277 | "nbformat": 4, 278 | "nbformat_minor": 5 279 | } 280 | -------------------------------------------------------------------------------- /get-teams.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "id": "1fff86ce-d95f-4964-a05a-1ef3c24bb89b", 6 | "metadata": {}, 7 | "source": [ 8 | "The endpoint can be used to get a list of all teams for the current season for a league" 9 | ] 10 | }, 11 | { 12 | "cell_type": "code", 13 | "execution_count": 1, 14 | "id": "8bc56247-7f9a-4dc5-9640-50f947038698", 15 | "metadata": {}, 16 | "outputs": [], 17 | "source": [ 18 | "import requests" 19 | ] 20 | }, 21 | { 22 | "cell_type": "markdown", 23 | "id": "3853ad02-d474-49a3-80aa-2cf45248ee94", 24 | "metadata": {}, 25 | "source": [ 26 | "### NBA" 27 | ] 28 | }, 29 | { 30 | "cell_type": "code", 31 | "execution_count": 2, 32 | "id": "ebea3afe-2d90-4cb7-9f4e-9f2aca95c288", 33 | "metadata": {}, 34 | "outputs": [ 35 | { 36 | "data": { 37 | "text/plain": [ 38 | "[{'id': '1610612737', 'text': 'ATL'},\n", 39 | " {'id': '1610612751', 'text': 'BKN'},\n", 40 | " {'id': '1610612738', 'text': 'BOS'},\n", 41 | " {'id': '1610612766', 'text': 'CHA'},\n", 42 | " {'id': '1610612741', 'text': 'CHI'},\n", 43 | " {'id': '1610612739', 'text': 'CLE'},\n", 44 | " {'id': '1610612742', 'text': 'DAL'},\n", 45 | " {'id': '1610612743', 'text': 'DEN'},\n", 46 | " {'id': '1610612765', 'text': 'DET'},\n", 47 | " {'id': '1610612744', 'text': 'GSW'},\n", 48 | " {'id': '1610612745', 'text': 'HOU'},\n", 49 | " {'id': '1610612754', 'text': 'IND'},\n", 50 | " {'id': '1610612746', 'text': 'LAC'},\n", 51 | " {'id': '1610612747', 'text': 'LAL'},\n", 52 | " {'id': '1610612763', 'text': 'MEM'},\n", 53 | " {'id': '1610612748', 'text': 'MIA'},\n", 54 | " {'id': '1610612749', 'text': 'MIL'},\n", 55 | " {'id': '1610612750', 'text': 'MIN'},\n", 56 | " {'id': '1610612740', 'text': 'NOP'},\n", 57 | " {'id': '1610612752', 'text': 'NYK'},\n", 58 | " {'id': '1610612760', 'text': 'OKC'},\n", 59 | " {'id': '1610612753', 'text': 'ORL'},\n", 60 | " {'id': '1610612755', 'text': 'PHI'},\n", 61 | " {'id': '1610612756', 'text': 'PHX'},\n", 62 | " {'id': '1610612757', 'text': 'POR'},\n", 63 | " {'id': '1610612758', 'text': 'SAC'},\n", 64 | " {'id': '1610612759', 'text': 'SAS'},\n", 65 | " {'id': '1610612761', 'text': 'TOR'},\n", 66 | " {'id': '1610612762', 'text': 'UTA'},\n", 67 | " {'id': '1610612764', 'text': 'WAS'}]" 68 | ] 69 | }, 70 | "execution_count": 2, 71 | "metadata": {}, 72 | "output_type": "execute_result" 73 | } 74 | ], 75 | "source": [ 76 | "teams_response = requests.get(\"https://api.pbpstats.com/get-teams/nba\")\n", 77 | "teams = teams_response.json()\n", 78 | "teams[\"teams\"]" 79 | ] 80 | }, 81 | { 82 | "cell_type": "markdown", 83 | "id": "e8d68524-2286-44f5-af91-fa578488f8cc", 84 | "metadata": {}, 85 | "source": [ 86 | "### WNBA" 87 | ] 88 | }, 89 | { 90 | "cell_type": "code", 91 | "execution_count": 3, 92 | "id": "feb8c962-78a2-4c3a-b6e7-7fe08f5d4d45", 93 | "metadata": {}, 94 | "outputs": [ 95 | { 96 | "data": { 97 | "text/plain": [ 98 | "[{'id': '1611661330', 'text': 'ATL'},\n", 99 | " {'id': '1611661329', 'text': 'CHI'},\n", 100 | " {'id': '1611661323', 'text': 'CON'},\n", 101 | " {'id': '1611661321', 'text': 'DAL'},\n", 102 | " {'id': '1611661325', 'text': 'IND'},\n", 103 | " {'id': '1611661320', 'text': 'LAS'},\n", 104 | " {'id': '1611661319', 'text': 'LVA'},\n", 105 | " {'id': '1611661324', 'text': 'MIN'},\n", 106 | " {'id': '1611661313', 'text': 'NYL'},\n", 107 | " {'id': '1611661317', 'text': 'PHO'},\n", 108 | " {'id': '1611661328', 'text': 'SEA'},\n", 109 | " {'id': '1611661322', 'text': 'WAS'}]" 110 | ] 111 | }, 112 | "execution_count": 3, 113 | "metadata": {}, 114 | "output_type": "execute_result" 115 | } 116 | ], 117 | "source": [ 118 | "teams_response = requests.get(\"https://api.pbpstats.com/get-teams/wnba\")\n", 119 | "teams = teams_response.json()\n", 120 | "teams[\"teams\"]" 121 | ] 122 | }, 123 | { 124 | "cell_type": "code", 125 | "execution_count": null, 126 | "id": "92c9b73e-df1f-46d7-87cf-8369e1f0209e", 127 | "metadata": {}, 128 | "outputs": [], 129 | "source": [] 130 | } 131 | ], 132 | "metadata": { 133 | "kernelspec": { 134 | "display_name": "playground", 135 | "language": "python", 136 | "name": "playground" 137 | }, 138 | "language_info": { 139 | "codemirror_mode": { 140 | "name": "ipython", 141 | "version": 3 142 | }, 143 | "file_extension": ".py", 144 | "mimetype": "text/x-python", 145 | "name": "python", 146 | "nbconvert_exporter": "python", 147 | "pygments_lexer": "ipython3", 148 | "version": "3.8.9" 149 | } 150 | }, 151 | "nbformat": 4, 152 | "nbformat_minor": 5 153 | } 154 | -------------------------------------------------------------------------------- /get-totals.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "id": "ff2a0521-c01a-4390-968d-d1a5d2e0062c", 6 | "metadata": {}, 7 | "source": [ 8 | "This endpoint can be used to get player/team/lineup totals for various query parameters" 9 | ] 10 | }, 11 | { 12 | "cell_type": "code", 13 | "execution_count": 1, 14 | "id": "4ec9cccc-991e-4d73-a8d7-28b2982690b2", 15 | "metadata": {}, 16 | "outputs": [], 17 | "source": [ 18 | "import requests" 19 | ] 20 | }, 21 | { 22 | "cell_type": "markdown", 23 | "id": "9bb807bc-c251-4b25-b0c6-9c3659e6fca5", 24 | "metadata": {}, 25 | "source": [ 26 | "# Player" 27 | ] 28 | }, 29 | { 30 | "cell_type": "markdown", 31 | "id": "52730910-a6e9-4af7-b422-a99e2239be81", 32 | "metadata": {}, 33 | "source": [ 34 | "### All totals" 35 | ] 36 | }, 37 | { 38 | "cell_type": "code", 39 | "execution_count": 2, 40 | "id": "74f17ba2-a4b8-4730-8e8d-eb6590b107d9", 41 | "metadata": {}, 42 | "outputs": [], 43 | "source": [ 44 | "url = \"https://api.pbpstats.com/get-totals/nba\"\n", 45 | "params = {\n", 46 | " \"Season\": \"2021-22\",\n", 47 | " \"SeasonType\": \"Regular Season\",\n", 48 | " \"Type\": \"Player\"\n", 49 | "}\n", 50 | "response = requests.get(url, params=params)\n", 51 | "response_json = response.json()\n", 52 | "player_stats = response_json[\"multi_row_table_data\"]" 53 | ] 54 | }, 55 | { 56 | "cell_type": "markdown", 57 | "id": "d66701ba-a141-4baa-99f2-f7dc733b5d89", 58 | "metadata": {}, 59 | "source": [ 60 | "### Across multiple seasons" 61 | ] 62 | }, 63 | { 64 | "cell_type": "code", 65 | "execution_count": 3, 66 | "id": "75f2221c-b43e-46de-8a58-4093120806a0", 67 | "metadata": {}, 68 | "outputs": [], 69 | "source": [ 70 | "url = \"https://api.pbpstats.com/get-totals/nba\"\n", 71 | "params = {\n", 72 | " \"Season\": \"2021-22,2020-21\",\n", 73 | " \"SeasonType\": \"Regular Season\",\n", 74 | " \"Type\": \"Player\"\n", 75 | "}\n", 76 | "response = requests.get(url, params=params)\n", 77 | "response_json = response.json()\n", 78 | "player_stats = response_json[\"multi_row_table_data\"]" 79 | ] 80 | }, 81 | { 82 | "cell_type": "markdown", 83 | "id": "2b4f13b6-f848-4d9d-93dc-e899799ee4ea", 84 | "metadata": {}, 85 | "source": [ 86 | "### Only for a single team" 87 | ] 88 | }, 89 | { 90 | "cell_type": "code", 91 | "execution_count": 4, 92 | "id": "9d7c7172-e394-4aa5-8122-5ce3133a1f9d", 93 | "metadata": {}, 94 | "outputs": [], 95 | "source": [ 96 | "url = \"https://api.pbpstats.com/get-totals/nba\"\n", 97 | "params = {\n", 98 | " \"Season\": \"2021-22\",\n", 99 | " \"SeasonType\": \"Regular Season\",\n", 100 | " \"Type\": \"Player\",\n", 101 | " \"TeamId\": \"1610612738\"\n", 102 | "}\n", 103 | "response = requests.get(url, params=params)\n", 104 | "response_json = response.json()\n", 105 | "player_stats = response_json[\"multi_row_table_data\"]" 106 | ] 107 | }, 108 | { 109 | "cell_type": "markdown", 110 | "id": "a2875642-e76e-4e7b-8ee8-a2b6204b850f", 111 | "metadata": {}, 112 | "source": [ 113 | "### With low leverage minutes removed" 114 | ] 115 | }, 116 | { 117 | "cell_type": "code", 118 | "execution_count": 5, 119 | "id": "d017757c-bfdb-43a5-a7b8-45bdb52f66b3", 120 | "metadata": {}, 121 | "outputs": [], 122 | "source": [ 123 | "url = \"https://api.pbpstats.com/get-totals/nba\"\n", 124 | "params = {\n", 125 | " \"Season\": \"2021-22\",\n", 126 | " \"SeasonType\": \"Regular Season\",\n", 127 | " \"Type\": \"Player\",\n", 128 | " \"Leverage\": \"Medium,High,VeryHigh\"\n", 129 | "}\n", 130 | "response = requests.get(url, params=params)\n", 131 | "response_json = response.json()\n", 132 | "player_stats = response_json[\"multi_row_table_data\"]" 133 | ] 134 | }, 135 | { 136 | "cell_type": "markdown", 137 | "id": "59858577-8331-4bb0-8ce3-b6687a3d1a22", 138 | "metadata": {}, 139 | "source": [ 140 | "### Any number of starters on vs opponent with all 5 starters on the floor" 141 | ] 142 | }, 143 | { 144 | "cell_type": "code", 145 | "execution_count": 6, 146 | "id": "f49f0a20-d605-4ecc-9a49-63221cbfd36d", 147 | "metadata": {}, 148 | "outputs": [], 149 | "source": [ 150 | "url = \"https://api.pbpstats.com/get-totals/nba\"\n", 151 | "params = {\n", 152 | " \"Season\": \"2021-22\",\n", 153 | " \"SeasonType\": \"Regular Season\",\n", 154 | " \"Type\": \"Player\",\n", 155 | " \"StarterState\": \"5v5,4v5,3v5,2v5,1v5,0v5\"\n", 156 | "}\n", 157 | "response = requests.get(url, params=params)\n", 158 | "response_json = response.json()\n", 159 | "player_stats = response_json[\"multi_row_table_data\"]" 160 | ] 161 | }, 162 | { 163 | "cell_type": "markdown", 164 | "id": "d8cc8e42-2c7c-4a30-95a4-1957e9b8d003", 165 | "metadata": {}, 166 | "source": [ 167 | "### With a date filter" 168 | ] 169 | }, 170 | { 171 | "cell_type": "code", 172 | "execution_count": 7, 173 | "id": "4ee2aebe-6c11-429a-b2ca-02161e794c64", 174 | "metadata": {}, 175 | "outputs": [], 176 | "source": [ 177 | "url = \"https://api.pbpstats.com/get-totals/wnba\"\n", 178 | "params = {\n", 179 | " \"Season\": \"2022\",\n", 180 | " \"SeasonType\": \"Regular Season\",\n", 181 | " \"Type\": \"Player\",\n", 182 | " \"FromDate\": \"2022-05-15\",\n", 183 | " \"ToDate\": \"2022-05-27\"\n", 184 | "}\n", 185 | "response = requests.get(url, params=params)\n", 186 | "response_json = response.json()\n", 187 | "player_stats = response_json[\"multi_row_table_data\"]" 188 | ] 189 | }, 190 | { 191 | "cell_type": "markdown", 192 | "id": "eaee9efc-a6ed-462f-9a3d-d9f0eba94cfa", 193 | "metadata": {}, 194 | "source": [ 195 | "# Team" 196 | ] 197 | }, 198 | { 199 | "cell_type": "markdown", 200 | "id": "99bae27c-035b-4b1c-bb6a-1f5fc13f27ab", 201 | "metadata": {}, 202 | "source": [ 203 | "### All totals" 204 | ] 205 | }, 206 | { 207 | "cell_type": "code", 208 | "execution_count": 8, 209 | "id": "b6209eca-c1bb-4e51-bfc6-89271e3ad2d2", 210 | "metadata": {}, 211 | "outputs": [], 212 | "source": [ 213 | "url = \"https://api.pbpstats.com/get-totals/nba\"\n", 214 | "params = {\n", 215 | " \"Season\": \"2021-22\",\n", 216 | " \"SeasonType\": \"Regular Season\",\n", 217 | " \"Type\": \"Team\" # Use Opponent for opponent stats\n", 218 | "}\n", 219 | "response = requests.get(url, params=params)\n", 220 | "response_json = response.json()\n", 221 | "league_stats = response_json[\"single_row_table_data\"]\n", 222 | "team_stats = response_json[\"multi_row_table_data\"]" 223 | ] 224 | }, 225 | { 226 | "cell_type": "markdown", 227 | "id": "8f468472-78ae-4f51-84c0-72695120bf38", 228 | "metadata": {}, 229 | "source": [ 230 | "### Across multiple seasons" 231 | ] 232 | }, 233 | { 234 | "cell_type": "code", 235 | "execution_count": 9, 236 | "id": "a790ea64-a576-4603-a8c2-9fdb269d962e", 237 | "metadata": {}, 238 | "outputs": [], 239 | "source": [ 240 | "url = \"https://api.pbpstats.com/get-totals/nba\"\n", 241 | "params = {\n", 242 | " \"Season\": \"2021-22,2020-21\",\n", 243 | " \"SeasonType\": \"Regular Season\",\n", 244 | " \"Type\": \"Team\" # Use Opponent for opponent stats\n", 245 | "}\n", 246 | "response = requests.get(url, params=params)\n", 247 | "response_json = response.json()\n", 248 | "league_stats = response_json[\"single_row_table_data\"]\n", 249 | "team_stats = response_json[\"multi_row_table_data\"]" 250 | ] 251 | }, 252 | { 253 | "cell_type": "markdown", 254 | "id": "57003e69-7ab0-4570-9963-bb088db10f87", 255 | "metadata": {}, 256 | "source": [ 257 | "### Across multiple seasons - grouped by season" 258 | ] 259 | }, 260 | { 261 | "cell_type": "code", 262 | "execution_count": 10, 263 | "id": "629a6844-174a-425b-9e64-9607aa9df3c9", 264 | "metadata": {}, 265 | "outputs": [], 266 | "source": [ 267 | "url = \"https://api.pbpstats.com/get-totals/nba\"\n", 268 | "params = {\n", 269 | " \"Season\": \"2021-22,2020-21\",\n", 270 | " \"SeasonType\": \"Regular Season\",\n", 271 | " \"Type\": \"Team\", # Use Opponent for opponent stats\n", 272 | " \"GroupBy\": \"season\"\n", 273 | "}\n", 274 | "response = requests.get(url, params=params)\n", 275 | "response_json = response.json()\n", 276 | "league_stats = response_json[\"single_row_table_data\"]\n", 277 | "team_stats = response_json[\"multi_row_table_data\"]" 278 | ] 279 | }, 280 | { 281 | "cell_type": "markdown", 282 | "id": "2085cb66-8dc5-4460-8282-43e30fe546e6", 283 | "metadata": {}, 284 | "source": [ 285 | "### With low leverage minutes removed" 286 | ] 287 | }, 288 | { 289 | "cell_type": "code", 290 | "execution_count": 11, 291 | "id": "8471deff-eeeb-41e6-bacd-59db1334e9d3", 292 | "metadata": {}, 293 | "outputs": [], 294 | "source": [ 295 | "url = \"https://api.pbpstats.com/get-totals/nba\"\n", 296 | "params = {\n", 297 | " \"Season\": \"2021-22\",\n", 298 | " \"SeasonType\": \"Regular Season\",\n", 299 | " \"Type\": \"Team\", # Use Opponent for opponent stats\n", 300 | " \"Leverage\": \"Medium,High,VeryHigh\"\n", 301 | "}\n", 302 | "response = requests.get(url, params=params)\n", 303 | "response_json = response.json()\n", 304 | "league_stats = response_json[\"single_row_table_data\"]\n", 305 | "team_stats = response_json[\"multi_row_table_data\"]" 306 | ] 307 | }, 308 | { 309 | "cell_type": "markdown", 310 | "id": "08641258-ef70-431a-8609-ba2a6d393aff", 311 | "metadata": {}, 312 | "source": [ 313 | "### Any number of starters on vs opponent with all 5 starters on the floor" 314 | ] 315 | }, 316 | { 317 | "cell_type": "code", 318 | "execution_count": 12, 319 | "id": "da13980a-e036-4ecb-ab61-3cc0010feccf", 320 | "metadata": {}, 321 | "outputs": [], 322 | "source": [ 323 | "url = \"https://api.pbpstats.com/get-totals/nba\"\n", 324 | "params = {\n", 325 | " \"Season\": \"2021-22\",\n", 326 | " \"SeasonType\": \"Regular Season\",\n", 327 | " \"Type\": \"Team\", # Use Opponent for opponent stats\n", 328 | " \"StarterState\": \"5v5,4v5,3v5,2v5,1v5,0v5\"\n", 329 | "}\n", 330 | "response = requests.get(url, params=params)\n", 331 | "response_json = response.json()\n", 332 | "league_stats = response_json[\"single_row_table_data\"]\n", 333 | "team_stats = response_json[\"multi_row_table_data\"]" 334 | ] 335 | }, 336 | { 337 | "cell_type": "markdown", 338 | "id": "f44ceb34-a56e-4818-af2f-7dc572822501", 339 | "metadata": {}, 340 | "source": [ 341 | "### All possessions following a made FG by the opponent" 342 | ] 343 | }, 344 | { 345 | "cell_type": "code", 346 | "execution_count": 13, 347 | "id": "464fb2c3-5eed-49d3-822a-e8f2c4a4435b", 348 | "metadata": {}, 349 | "outputs": [], 350 | "source": [ 351 | "url = \"https://api.pbpstats.com/get-totals/nba\"\n", 352 | "params = {\n", 353 | " \"Season\": \"2021-22\",\n", 354 | " \"SeasonType\": \"Regular Season\",\n", 355 | " \"Type\": \"Team\", # Use Opponent for opponent stats\n", 356 | " \"StartType\": \"OffMadeFG\" # see below for possible values for StartType\n", 357 | "}\n", 358 | "response = requests.get(url, params=params)\n", 359 | "response_json = response.json()\n", 360 | "league_stats = response_json[\"single_row_table_data\"]\n", 361 | "team_stats = response_json[\"multi_row_table_data\"]" 362 | ] 363 | }, 364 | { 365 | "cell_type": "markdown", 366 | "id": "875f6169-5dcd-4dc7-b0ed-62f4fa763ac6", 367 | "metadata": {}, 368 | "source": [ 369 | "#### possible values for StartType" 370 | ] 371 | }, 372 | { 373 | "cell_type": "code", 374 | "execution_count": 14, 375 | "id": "46e19efc-21c1-496f-9b5d-efe486ca67d0", 376 | "metadata": {}, 377 | "outputs": [], 378 | "source": [ 379 | "start_types = [\n", 380 | " \"All\", # All\n", 381 | " \"OffMissedFG\", # Off Any Missed FG\n", 382 | " \"OffMissed2\", # Off Any Missed 2\n", 383 | " \"OffMissed3\", # Off Any Missed 3\n", 384 | " \"OffMadeFG\", # Off Any Made FG\n", 385 | " \"OffMade2\", # Off Any Made 2\n", 386 | " \"OffMade3\", # Off Any Made 3\n", 387 | " \"OffAtRimMake\", # Off At Rim Make\n", 388 | " \"OffAtRimMiss\", # Off At Rim Miss\n", 389 | " \"OffAtRimBlock\", # Off At Rim Block\n", 390 | " \"OffShortMidRangeMake\", # Off Short Mid-Range Make\n", 391 | " \"OffShortMidRangeMiss\", # Off Short Mid-Range Miss\n", 392 | " \"OffLongMidRangeMake\", # Off Long Mid-Range Make\n", 393 | " \"OffLongMidRangeMiss\", # Off Long Mid-Range Miss\n", 394 | " \"OffArc3Make\", # Off Arc 3 Make\n", 395 | " \"OffArc3Miss\", # Off Arc 3 Miss\n", 396 | " \"OffCorner3Make\", # Off Corner 3 Make\n", 397 | " \"OffCorner3Miss\", # Off Corner 3 Miss\n", 398 | " \"OffFTMake\", # Off FT Make\n", 399 | " \"OffFTMiss\", # Off FT Miss\n", 400 | " \"OffLiveBallTurnover\", # Off Steal\n", 401 | " \"OffDeadball\", # Off Dead Ball\n", 402 | " \"OffTimeout\", # Off Timeout\n", 403 | "]" 404 | ] 405 | }, 406 | { 407 | "cell_type": "markdown", 408 | "id": "ceffc53e-00f5-4ad1-a548-251969e47c56", 409 | "metadata": {}, 410 | "source": [ 411 | "### With a date filter" 412 | ] 413 | }, 414 | { 415 | "cell_type": "code", 416 | "execution_count": 15, 417 | "id": "2f3dd239-94e9-4e80-b136-9ffcfae247f1", 418 | "metadata": {}, 419 | "outputs": [], 420 | "source": [ 421 | "url = \"https://api.pbpstats.com/get-totals/wnba\"\n", 422 | "params = {\n", 423 | " \"Season\": \"2022\",\n", 424 | " \"SeasonType\": \"Regular Season\",\n", 425 | " \"Type\": \"Team\", # Use Opponent for opponent stats\n", 426 | " \"FromDate\": \"2022-05-15\",\n", 427 | " \"ToDate\": \"2022-05-27\"\n", 428 | "}\n", 429 | "response = requests.get(url, params=params)\n", 430 | "response_json = response.json()\n", 431 | "league_stats = response_json[\"single_row_table_data\"]\n", 432 | "team_stats = response_json[\"multi_row_table_data\"]" 433 | ] 434 | }, 435 | { 436 | "cell_type": "markdown", 437 | "id": "630a67b8-70b4-4665-bf01-f1d61ad7334b", 438 | "metadata": {}, 439 | "source": [ 440 | "# Lineup" 441 | ] 442 | }, 443 | { 444 | "cell_type": "markdown", 445 | "id": "b8ab9ce6-a11d-4861-ab55-4a081c1fd2c8", 446 | "metadata": {}, 447 | "source": [ 448 | "### All totals" 449 | ] 450 | }, 451 | { 452 | "cell_type": "code", 453 | "execution_count": 16, 454 | "id": "f6451ed7-ad5f-482a-af9c-28de0d60de66", 455 | "metadata": {}, 456 | "outputs": [], 457 | "source": [ 458 | "url = \"https://api.pbpstats.com/get-totals/nba\"\n", 459 | "params = {\n", 460 | " \"Season\": \"2021-22\",\n", 461 | " \"SeasonType\": \"Regular Season\",\n", 462 | " \"Type\": \"Lineup\" # Use LineupOpponent for opponent lineup stats\n", 463 | "}\n", 464 | "response = requests.get(url, params=params)\n", 465 | "response_json = response.json()\n", 466 | "lineup_stats = response_json[\"multi_row_table_data\"]" 467 | ] 468 | }, 469 | { 470 | "cell_type": "markdown", 471 | "id": "398c1ca7-02ad-4d57-bdf2-c36a37f7d0c2", 472 | "metadata": {}, 473 | "source": [ 474 | "### Across multiple seasons" 475 | ] 476 | }, 477 | { 478 | "cell_type": "code", 479 | "execution_count": 17, 480 | "id": "2f195d2b-494e-4b21-b195-9fcefa40fcc1", 481 | "metadata": {}, 482 | "outputs": [], 483 | "source": [ 484 | "url = \"https://api.pbpstats.com/get-totals/nba\"\n", 485 | "params = {\n", 486 | " \"Season\": \"2021-22,2020-21\",\n", 487 | " \"SeasonType\": \"Regular Season\",\n", 488 | " \"Type\": \"Lineup\" # Use LineupOpponent for opponent lineup stats\n", 489 | "}\n", 490 | "response = requests.get(url, params=params)\n", 491 | "response_json = response.json()\n", 492 | "lineup_stats = response_json[\"multi_row_table_data\"]" 493 | ] 494 | }, 495 | { 496 | "cell_type": "markdown", 497 | "id": "8b54f302-283e-48d8-aa2e-bbab0bc60c99", 498 | "metadata": {}, 499 | "source": [ 500 | "### Only for a single team" 501 | ] 502 | }, 503 | { 504 | "cell_type": "code", 505 | "execution_count": 18, 506 | "id": "06708092-90ce-4071-bd52-d637163ac710", 507 | "metadata": {}, 508 | "outputs": [], 509 | "source": [ 510 | "url = \"https://api.pbpstats.com/get-totals/nba\"\n", 511 | "params = {\n", 512 | " \"Season\": \"2021-22\",\n", 513 | " \"SeasonType\": \"Regular Season\",\n", 514 | " \"Type\": \"Lineup\", # Use LineupOpponent for opponent lineup stats\n", 515 | " \"TeamId\": \"1610612738\"\n", 516 | "}\n", 517 | "response = requests.get(url, params=params)\n", 518 | "response_json = response.json()\n", 519 | "lineup_stats = response_json[\"multi_row_table_data\"]" 520 | ] 521 | }, 522 | { 523 | "cell_type": "markdown", 524 | "id": "09bf8735-9aa7-4973-aa86-2d121a1a56b2", 525 | "metadata": {}, 526 | "source": [ 527 | "### With low leverage minutes removed" 528 | ] 529 | }, 530 | { 531 | "cell_type": "code", 532 | "execution_count": 19, 533 | "id": "8666a04f-95fb-4fb9-947d-f0179a5631a1", 534 | "metadata": {}, 535 | "outputs": [], 536 | "source": [ 537 | "url = \"https://api.pbpstats.com/get-totals/nba\"\n", 538 | "params = {\n", 539 | " \"Season\": \"2021-22\",\n", 540 | " \"SeasonType\": \"Regular Season\",\n", 541 | " \"Type\": \"Lineup\", # Use LineupOpponent for opponent lineup stats\n", 542 | " \"TeamId\": \"1610612738\",\n", 543 | " \"Leverage\": \"Medium,High,VeryHigh\"\n", 544 | "}\n", 545 | "response = requests.get(url, params=params)\n", 546 | "response_json = response.json()\n", 547 | "lineup_stats = response_json[\"multi_row_table_data\"]" 548 | ] 549 | }, 550 | { 551 | "cell_type": "markdown", 552 | "id": "d7b0201d-0d79-4f8a-997b-68ff04f3e401", 553 | "metadata": {}, 554 | "source": [ 555 | "### With a date filter" 556 | ] 557 | }, 558 | { 559 | "cell_type": "code", 560 | "execution_count": 20, 561 | "id": "29d62460-6e2d-4951-abd2-67210ed03552", 562 | "metadata": {}, 563 | "outputs": [], 564 | "source": [ 565 | "url = \"https://api.pbpstats.com/get-totals/wnba\"\n", 566 | "params = {\n", 567 | " \"Season\": \"2022\",\n", 568 | " \"SeasonType\": \"Regular Season\",\n", 569 | " \"Type\": \"Lineup\", # Use LineupOpponent for opponent lineup stats\n", 570 | " \"FromDate\": \"2022-05-15\",\n", 571 | " \"ToDate\": \"2022-05-27\"\n", 572 | "}\n", 573 | "response = requests.get(url, params=params)\n", 574 | "response_json = response.json()\n", 575 | "lineup_stats = response_json[\"multi_row_table_data\"]" 576 | ] 577 | }, 578 | { 579 | "cell_type": "code", 580 | "execution_count": null, 581 | "id": "b37e8cc3-f6d9-45ac-9666-60572e1d240e", 582 | "metadata": {}, 583 | "outputs": [], 584 | "source": [] 585 | } 586 | ], 587 | "metadata": { 588 | "kernelspec": { 589 | "display_name": "playground", 590 | "language": "python", 591 | "name": "playground" 592 | }, 593 | "language_info": { 594 | "codemirror_mode": { 595 | "name": "ipython", 596 | "version": 3 597 | }, 598 | "file_extension": ".py", 599 | "mimetype": "text/x-python", 600 | "name": "python", 601 | "nbconvert_exporter": "python", 602 | "pygments_lexer": "ipython3", 603 | "version": "3.8.9" 604 | } 605 | }, 606 | "nbformat": 4, 607 | "nbformat_minor": 5 608 | } 609 | -------------------------------------------------------------------------------- /get-win-probability.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "id": "7266e068-8e30-48d8-a299-6e16cd8d2c69", 6 | "metadata": {}, 7 | "source": [ 8 | "This endpoint can be used to get the win probability for a given score/time/pre game win percentage" 9 | ] 10 | }, 11 | { 12 | "cell_type": "code", 13 | "execution_count": 1, 14 | "id": "e462691f-64bb-4877-aaa0-0e6e30de9fc6", 15 | "metadata": {}, 16 | "outputs": [], 17 | "source": [ 18 | "import requests" 19 | ] 20 | }, 21 | { 22 | "cell_type": "markdown", 23 | "id": "015254de-a8e2-4fe0-936c-305fd10f5873", 24 | "metadata": {}, 25 | "source": [ 26 | "### NBA - Down 5, with the ball with 60 seconds left and a 55% pregame win probability" 27 | ] 28 | }, 29 | { 30 | "cell_type": "code", 31 | "execution_count": 2, 32 | "id": "9625ca59-d170-4dba-99c5-e2d61ac47381", 33 | "metadata": {}, 34 | "outputs": [ 35 | { 36 | "data": { 37 | "text/plain": [ 38 | "{'win_probability': 0.08770513534545898}" 39 | ] 40 | }, 41 | "execution_count": 2, 42 | "metadata": {}, 43 | "output_type": "execute_result" 44 | } 45 | ], 46 | "source": [ 47 | "league = \"nba\"\n", 48 | "margin = -5 # from the perspective of the team with the ball\n", 49 | "seconds_remaining = 60 # This is time remaining at the start of the possession\n", 50 | "pre_game_win_prob = 0.55 # 55% to win pregame\n", 51 | "\n", 52 | "url = f\"https://api.pbpstats.com/get-win-probability/{league}/{margin}/{pre_game_win_prob}/{seconds_remaining}\"\n", 53 | "\n", 54 | "response = requests.get(url)\n", 55 | "response_json = response.json()\n", 56 | "response_json" 57 | ] 58 | }, 59 | { 60 | "cell_type": "code", 61 | "execution_count": null, 62 | "id": "7378d5ab-eb91-49fb-b7ee-9139e3d46c07", 63 | "metadata": {}, 64 | "outputs": [], 65 | "source": [] 66 | } 67 | ], 68 | "metadata": { 69 | "kernelspec": { 70 | "display_name": "playground", 71 | "language": "python", 72 | "name": "playground" 73 | }, 74 | "language_info": { 75 | "codemirror_mode": { 76 | "name": "ipython", 77 | "version": 3 78 | }, 79 | "file_extension": ".py", 80 | "mimetype": "text/x-python", 81 | "name": "python", 82 | "nbconvert_exporter": "python", 83 | "pygments_lexer": "ipython3", 84 | "version": "3.8.9" 85 | } 86 | }, 87 | "nbformat": 4, 88 | "nbformat_minor": 5 89 | } 90 | -------------------------------------------------------------------------------- /get-wowy-combination-stats.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "id": "ae473661-edf2-4690-ade9-4becae4c3e37", 6 | "metadata": {}, 7 | "source": [ 8 | "This endpoint can be used to get efficiency for all on/off combinations of selected players" 9 | ] 10 | }, 11 | { 12 | "cell_type": "code", 13 | "execution_count": 1, 14 | "id": "7b6b87cd-50bc-463f-8aaa-dc982e2d76a4", 15 | "metadata": {}, 16 | "outputs": [], 17 | "source": [ 18 | "import requests" 19 | ] 20 | }, 21 | { 22 | "cell_type": "markdown", 23 | "id": "49050433-c472-4504-aee9-c04e8a974f91", 24 | "metadata": {}, 25 | "source": [ 26 | "### Sixers for James Harden and Joel Embiid in games both of them played" 27 | ] 28 | }, 29 | { 30 | "cell_type": "code", 31 | "execution_count": 2, 32 | "id": "821f8532-566f-4dd1-b506-24851bf24b2f", 33 | "metadata": {}, 34 | "outputs": [ 35 | { 36 | "data": { 37 | "text/plain": [ 38 | "[{'OffRtg': 120.625,\n", 39 | " 'DefRtg': 115.5688622754491,\n", 40 | " 'NetRtg': 5.056137724550894,\n", 41 | " 'Minutes': 78.0,\n", 42 | " 'On': '',\n", 43 | " 'Off': 'James Harden, Joel Embiid',\n", 44 | " 'TeamWowyQueryParams': {'Season': '2021-22',\n", 45 | " 'SeasonType': 'Regular Season',\n", 46 | " 'TeamId': '1610612755',\n", 47 | " 'Type': 'Team',\n", 48 | " '0Exactly2OffFloor': '201935,203954',\n", 49 | " '1Exactly2PlayedInGame': '201935,203954'},\n", 50 | " 'OpponentWowyQueryParams': {'Season': '2021-22',\n", 51 | " 'SeasonType': 'Regular Season',\n", 52 | " 'TeamId': '1610612755',\n", 53 | " 'Type': 'Opponent',\n", 54 | " '0Exactly2OffFloor': '201935,203954',\n", 55 | " '1Exactly2PlayedInGame': '201935,203954'},\n", 56 | " 'RowId': 'On:',\n", 57 | " 'Fg3Pct': 0.4,\n", 58 | " 'Fg2Pct': 0.5494505494505495,\n", 59 | " 'OppFg3Pct': 0.2857142857142857,\n", 60 | " 'OppFg2Pct': 0.6},\n", 61 | " {'OffRtg': 114.69816272965879,\n", 62 | " 'DefRtg': 125.6544502617801,\n", 63 | " 'NetRtg': -10.956287532121308,\n", 64 | " 'Minutes': 189.0,\n", 65 | " 'On': 'James Harden',\n", 66 | " 'Off': 'Joel Embiid',\n", 67 | " 'TeamWowyQueryParams': {'Season': '2021-22',\n", 68 | " 'SeasonType': 'Regular Season',\n", 69 | " 'TeamId': '1610612755',\n", 70 | " 'Type': 'Team',\n", 71 | " '0Exactly1OnFloor': '201935',\n", 72 | " '1Exactly1OffFloor': '203954',\n", 73 | " '2Exactly2PlayedInGame': '201935,203954'},\n", 74 | " 'OpponentWowyQueryParams': {'Season': '2021-22',\n", 75 | " 'SeasonType': 'Regular Season',\n", 76 | " 'TeamId': '1610612755',\n", 77 | " 'Type': 'Opponent',\n", 78 | " '0Exactly1OnFloor': '201935',\n", 79 | " '1Exactly1OffFloor': '203954',\n", 80 | " '2Exactly2PlayedInGame': '201935,203954'},\n", 81 | " 'RowId': 'On:201935',\n", 82 | " 'Fg3Pct': 0.36666666666666664,\n", 83 | " 'Fg2Pct': 0.47191011235955055,\n", 84 | " 'OppFg3Pct': 0.4142857142857143,\n", 85 | " 'OppFg2Pct': 0.6216216216216216},\n", 86 | " {'OffRtg': 107.0945945945946,\n", 87 | " 'DefRtg': 121.05263157894737,\n", 88 | " 'NetRtg': -13.958036984352773,\n", 89 | " 'Minutes': 142.0,\n", 90 | " 'On': 'Joel Embiid',\n", 91 | " 'Off': 'James Harden',\n", 92 | " 'TeamWowyQueryParams': {'Season': '2021-22',\n", 93 | " 'SeasonType': 'Regular Season',\n", 94 | " 'TeamId': '1610612755',\n", 95 | " 'Type': 'Team',\n", 96 | " '0Exactly1OnFloor': '203954',\n", 97 | " '1Exactly1OffFloor': '201935',\n", 98 | " '2Exactly2PlayedInGame': '203954,201935'},\n", 99 | " 'OpponentWowyQueryParams': {'Season': '2021-22',\n", 100 | " 'SeasonType': 'Regular Season',\n", 101 | " 'TeamId': '1610612755',\n", 102 | " 'Type': 'Opponent',\n", 103 | " '0Exactly1OnFloor': '203954',\n", 104 | " '1Exactly1OffFloor': '201935',\n", 105 | " '2Exactly2PlayedInGame': '203954,201935'},\n", 106 | " 'RowId': 'On:203954',\n", 107 | " 'Fg3Pct': 0.45,\n", 108 | " 'Fg2Pct': 0.4153846153846154,\n", 109 | " 'OppFg3Pct': 0.35106382978723405,\n", 110 | " 'OppFg2Pct': 0.573170731707317},\n", 111 | " {'OffRtg': 125.74503311258277,\n", 112 | " 'DefRtg': 109.1358024691358,\n", 113 | " 'NetRtg': 16.609230643446978,\n", 114 | " 'Minutes': 603.0,\n", 115 | " 'On': 'James Harden, Joel Embiid',\n", 116 | " 'Off': '',\n", 117 | " 'TeamWowyQueryParams': {'Season': '2021-22',\n", 118 | " 'SeasonType': 'Regular Season',\n", 119 | " 'TeamId': '1610612755',\n", 120 | " 'Type': 'Team',\n", 121 | " '0Exactly2OnFloor': '201935,203954',\n", 122 | " '1Exactly2PlayedInGame': '201935,203954'},\n", 123 | " 'OpponentWowyQueryParams': {'Season': '2021-22',\n", 124 | " 'SeasonType': 'Regular Season',\n", 125 | " 'TeamId': '1610612755',\n", 126 | " 'Type': 'Opponent',\n", 127 | " '0Exactly2OnFloor': '201935,203954',\n", 128 | " '1Exactly2PlayedInGame': '201935,203954'},\n", 129 | " 'RowId': 'On:201935,203954',\n", 130 | " 'Fg3Pct': 0.4043583535108959,\n", 131 | " 'Fg2Pct': 0.5705024311183144,\n", 132 | " 'OppFg3Pct': 0.3584905660377358,\n", 133 | " 'OppFg2Pct': 0.5084033613445378}]" 134 | ] 135 | }, 136 | "execution_count": 2, 137 | "metadata": {}, 138 | "output_type": "execute_result" 139 | } 140 | ], 141 | "source": [ 142 | "wowy_url = \"https://api.pbpstats.com/get-wowy-combination-stats/nba\"\n", 143 | "wowy_params = {\n", 144 | " \"TeamId\": \"1610612755\", # Sixers\n", 145 | " \"Season\": \"2021-22\",\n", 146 | " \"SeasonType\": \"Regular Season\",\n", 147 | " \"PlayerIds\": \"201935,203954\", # comma separated player ids - Harden and Embiid\n", 148 | " \"OnlyCommonGames\": \"true\" # Only stats for games in which both Harden and Embiid played\n", 149 | "}\n", 150 | "wowy_response = requests.get(wowy_url, params=wowy_params)\n", 151 | "wowy = wowy_response.json()\n", 152 | "wowy[\"results\"]" 153 | ] 154 | }, 155 | { 156 | "cell_type": "markdown", 157 | "id": "ce89de19-b14e-4c86-8ba4-aa5a53630678", 158 | "metadata": {}, 159 | "source": [ 160 | "### Nikola Jokic with low leverage minutes excluded" 161 | ] 162 | }, 163 | { 164 | "cell_type": "code", 165 | "execution_count": 3, 166 | "id": "ef74ea5e-6ecc-47de-8303-b8582eb43483", 167 | "metadata": {}, 168 | "outputs": [ 169 | { 170 | "data": { 171 | "text/plain": [ 172 | "[{'OffRtg': 109.00683554483314,\n", 173 | " 'DefRtg': 116.36146496815287,\n", 174 | " 'NetRtg': -7.354629423319736,\n", 175 | " 'Minutes': 1251.0,\n", 176 | " 'On': '',\n", 177 | " 'Off': 'Nikola Jokic',\n", 178 | " 'TeamWowyQueryParams': {'Season': '2021-22',\n", 179 | " 'SeasonType': 'Regular Season',\n", 180 | " 'TeamId': '1610612743',\n", 181 | " 'Type': 'Team',\n", 182 | " '0Exactly1OffFloor': '203999'},\n", 183 | " 'OpponentWowyQueryParams': {'Season': '2021-22',\n", 184 | " 'SeasonType': 'Regular Season',\n", 185 | " 'TeamId': '1610612743',\n", 186 | " 'Type': 'Opponent',\n", 187 | " '0Exactly1OffFloor': '203999'},\n", 188 | " 'RowId': 'On:',\n", 189 | " 'Fg3Pct': 0.3525390625,\n", 190 | " 'Fg2Pct': 0.5091362126245847,\n", 191 | " 'OppFg3Pct': 0.3534090909090909,\n", 192 | " 'OppFg2Pct': 0.5681639085894405},\n", 193 | " {'OffRtg': 119.63835155592935,\n", 194 | " 'DefRtg': 110.11615628299894,\n", 195 | " 'NetRtg': 9.522195272930404,\n", 196 | " 'Minutes': 2330.0,\n", 197 | " 'On': 'Nikola Jokic',\n", 198 | " 'Off': '',\n", 199 | " 'TeamWowyQueryParams': {'Season': '2021-22',\n", 200 | " 'SeasonType': 'Regular Season',\n", 201 | " 'TeamId': '1610612743',\n", 202 | " 'Type': 'Team',\n", 203 | " '0Exactly1OnFloor': '203999'},\n", 204 | " 'OpponentWowyQueryParams': {'Season': '2021-22',\n", 205 | " 'SeasonType': 'Regular Season',\n", 206 | " 'TeamId': '1610612743',\n", 207 | " 'Type': 'Opponent',\n", 208 | " '0Exactly1OnFloor': '203999'},\n", 209 | " 'RowId': 'On:203999',\n", 210 | " 'Fg3Pct': 0.360377358490566,\n", 211 | " 'Fg2Pct': 0.6059793024147183,\n", 212 | " 'OppFg3Pct': 0.33741579914268216,\n", 213 | " 'OppFg2Pct': 0.5377254324622746}]" 214 | ] 215 | }, 216 | "execution_count": 3, 217 | "metadata": {}, 218 | "output_type": "execute_result" 219 | } 220 | ], 221 | "source": [ 222 | "wowy_url = \"https://api.pbpstats.com/get-wowy-combination-stats/nba\"\n", 223 | "wowy_params = {\n", 224 | " \"TeamId\": \"1610612743\", # Nuggets\n", 225 | " \"Season\": \"2021-22\",\n", 226 | " \"SeasonType\": \"Regular Season\",\n", 227 | " \"PlayerIds\": \"203999\", # Jokic\n", 228 | " \"Leverage\": \"Medium,High,VeryHigh\" # comma separated leverages\n", 229 | "}\n", 230 | "wowy_response = requests.get(wowy_url, params=wowy_params)\n", 231 | "wowy = wowy_response.json()\n", 232 | "wowy[\"results\"]" 233 | ] 234 | }, 235 | { 236 | "cell_type": "markdown", 237 | "id": "8bccb2bf-835c-470e-814f-064a41727134", 238 | "metadata": {}, 239 | "source": [ 240 | "### 2021 Candace Parker" 241 | ] 242 | }, 243 | { 244 | "cell_type": "code", 245 | "execution_count": 4, 246 | "id": "6e8e4129-a42f-4e9d-930a-05ad919ca561", 247 | "metadata": {}, 248 | "outputs": [ 249 | { 250 | "data": { 251 | "text/plain": [ 252 | "[{'OffRtg': 101.53508771929825,\n", 253 | " 'DefRtg': 101.82348650619986,\n", 254 | " 'NetRtg': -0.2883987869016096,\n", 255 | " 'Minutes': 685.0,\n", 256 | " 'On': '',\n", 257 | " 'Off': 'Candace Parker',\n", 258 | " 'TeamWowyQueryParams': {'Season': '2021',\n", 259 | " 'SeasonType': 'Regular Season',\n", 260 | " 'TeamId': '1611661329',\n", 261 | " 'Type': 'Team',\n", 262 | " '0Exactly1OffFloor': '201496'},\n", 263 | " 'OpponentWowyQueryParams': {'Season': '2021',\n", 264 | " 'SeasonType': 'Regular Season',\n", 265 | " 'TeamId': '1611661329',\n", 266 | " 'Type': 'Opponent',\n", 267 | " '0Exactly1OffFloor': '201496'},\n", 268 | " 'RowId': 'On:',\n", 269 | " 'Fg3Pct': 0.35942028985507246,\n", 270 | " 'Fg2Pct': 0.4600484261501211,\n", 271 | " 'OppFg3Pct': 0.3639344262295082,\n", 272 | " 'OppFg2Pct': 0.46878680800942285},\n", 273 | " {'OffRtg': 103.322528363047,\n", 274 | " 'DefRtg': 99.43227899432279,\n", 275 | " 'NetRtg': 3.890249368724213,\n", 276 | " 'Minutes': 605.0,\n", 277 | " 'On': 'Candace Parker',\n", 278 | " 'Off': '',\n", 279 | " 'TeamWowyQueryParams': {'Season': '2021',\n", 280 | " 'SeasonType': 'Regular Season',\n", 281 | " 'TeamId': '1611661329',\n", 282 | " 'Type': 'Team',\n", 283 | " '0Exactly1OnFloor': '201496'},\n", 284 | " 'OpponentWowyQueryParams': {'Season': '2021',\n", 285 | " 'SeasonType': 'Regular Season',\n", 286 | " 'TeamId': '1611661329',\n", 287 | " 'Type': 'Opponent',\n", 288 | " '0Exactly1OnFloor': '201496'},\n", 289 | " 'RowId': 'On:201496',\n", 290 | " 'Fg3Pct': 0.3263473053892216,\n", 291 | " 'Fg2Pct': 0.5102599179206566,\n", 292 | " 'OppFg3Pct': 0.339041095890411,\n", 293 | " 'OppFg2Pct': 0.45580808080808083}]" 294 | ] 295 | }, 296 | "execution_count": 4, 297 | "metadata": {}, 298 | "output_type": "execute_result" 299 | } 300 | ], 301 | "source": [ 302 | "wowy_url = \"https://api.pbpstats.com/get-wowy-combination-stats/wnba\"\n", 303 | "wowy_params = {\n", 304 | " \"TeamId\": \"1611661329\", # Chicago\n", 305 | " \"Season\": \"2021\",\n", 306 | " \"SeasonType\": \"Regular Season\",\n", 307 | " \"PlayerIds\": \"201496\" # Candace Parker\n", 308 | "}\n", 309 | "wowy_response = requests.get(wowy_url, params=wowy_params)\n", 310 | "wowy = wowy_response.json()\n", 311 | "wowy[\"results\"]" 312 | ] 313 | }, 314 | { 315 | "cell_type": "code", 316 | "execution_count": null, 317 | "id": "50c41b1f-1889-47e2-ba39-a9e75876dc03", 318 | "metadata": {}, 319 | "outputs": [], 320 | "source": [] 321 | } 322 | ], 323 | "metadata": { 324 | "kernelspec": { 325 | "display_name": "playground", 326 | "language": "python", 327 | "name": "playground" 328 | }, 329 | "language_info": { 330 | "codemirror_mode": { 331 | "name": "ipython", 332 | "version": 3 333 | }, 334 | "file_extension": ".py", 335 | "mimetype": "text/x-python", 336 | "name": "python", 337 | "nbconvert_exporter": "python", 338 | "pygments_lexer": "ipython3", 339 | "version": "3.8.9" 340 | } 341 | }, 342 | "nbformat": 4, 343 | "nbformat_minor": 5 344 | } 345 | -------------------------------------------------------------------------------- /get-wowy-stats.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "id": "5136f0ef-c5dd-4f2c-80b5-c5601d4b3dc6", 6 | "metadata": {}, 7 | "source": [ 8 | "This endpoint can be used to get team, opponent, lineup or player stats for a given set of players on/off the floor as well as other query criteria" 9 | ] 10 | }, 11 | { 12 | "cell_type": "code", 13 | "execution_count": 1, 14 | "id": "fd510077-13ea-4328-808d-20345f91921d", 15 | "metadata": {}, 16 | "outputs": [], 17 | "source": [ 18 | "import requests" 19 | ] 20 | }, 21 | { 22 | "cell_type": "markdown", 23 | "id": "65abc694-7efc-458b-a1c6-96020ed4a9e5", 24 | "metadata": {}, 25 | "source": [ 26 | "### Lineups featuring Kyle Lowry and any four bench players in the 2015-16 and 2016-17 seasons" 27 | ] 28 | }, 29 | { 30 | "cell_type": "code", 31 | "execution_count": 2, 32 | "id": "7fdc2cdb-7bd8-436b-824e-a53c0230ff3d", 33 | "metadata": {}, 34 | "outputs": [], 35 | "source": [ 36 | "wowy_url = \"https://api.pbpstats.com/get-wowy-stats/nba\"\n", 37 | "wowy_params = {\n", 38 | " \"0Exactly1Started\": \"200768\", # Kyle Lowry started the game - format index(Exactly|GreaterThan|LessThan)number(OnFloor| OffFloor|PlayedInGame|DidNotPlayInGame|Started|CameOffBench)\n", 39 | " \"1Exactly1OnFloor\": \"200768\", # Kyle Lowry on the floor\n", 40 | " \"TeamId\": \"1610612761\", # Toronto Raptors\n", 41 | " \"Season\": \"2015-16,2016-17\",\n", 42 | " \"SeasonType\": \"Regular Season\",\n", 43 | " \"Type\": \"Team\", # Team stats\n", 44 | " \"StarterState\": \"1v5,1v4,1v3,1v2,1v1,1v0\" # One starter for the Raptors vs any number for the opponent\n", 45 | "}\n", 46 | "wowy_response = requests.get(wowy_url, params=wowy_params)\n", 47 | "wowy = wowy_response.json()\n", 48 | "team_stats = wowy[\"single_row_table_data\"]\n", 49 | "lineup_stats = wowy[\"multi_row_table_data\"]" 50 | ] 51 | }, 52 | { 53 | "cell_type": "code", 54 | "execution_count": 3, 55 | "id": "ad9ae7ae-1013-4e26-96f2-868104ab6ff1", 56 | "metadata": {}, 57 | "outputs": [ 58 | { 59 | "name": "stdout", 60 | "output_type": "stream", 61 | "text": [ 62 | "The Raptors outscored opponents by 208 points in 711 minutes\n" 63 | ] 64 | } 65 | ], 66 | "source": [ 67 | "print(f\"The Raptors outscored opponents by {team_stats['PlusMinus']} points in {team_stats['Minutes']} minutes\")" 68 | ] 69 | }, 70 | { 71 | "cell_type": "markdown", 72 | "id": "65a3818c-2283-431d-aceb-bf198f4ef74e", 73 | "metadata": {}, 74 | "source": [ 75 | "To get the most used lineup:" 76 | ] 77 | }, 78 | { 79 | "cell_type": "code", 80 | "execution_count": 4, 81 | "id": "0d7b68a5-0bc7-4e49-9756-46b5dc306f39", 82 | "metadata": {}, 83 | "outputs": [ 84 | { 85 | "name": "stdout", 86 | "output_type": "stream", 87 | "text": [ 88 | "The most used lineup was Kyle Lowry, Patrick Patterson, Bismack Biyombo, Cory Joseph, Terrence Ross\n", 89 | "This lineup outscored opponents by 91 points in 277 minutes\n" 90 | ] 91 | } 92 | ], 93 | "source": [ 94 | "sorted_by_seconds_played = sorted(lineup_stats, key=lambda d: d['SecondsPlayed'], reverse=True)\n", 95 | "most_used_lineup = sorted_by_seconds_played[0]\n", 96 | "print(f\"The most used lineup was {most_used_lineup['Name']}\")\n", 97 | "print(f\"This lineup outscored opponents by {most_used_lineup['PlusMinus']} points in {most_used_lineup['Minutes']} minutes\")" 98 | ] 99 | }, 100 | { 101 | "cell_type": "markdown", 102 | "id": "ec615056-4e61-42ee-8c43-2a477626459f", 103 | "metadata": {}, 104 | "source": [ 105 | "### Player stats for lineups with Stephen Curry on the floor in the 2015-16 season" 106 | ] 107 | }, 108 | { 109 | "cell_type": "code", 110 | "execution_count": 5, 111 | "id": "2814b0f9-28dd-43b6-a8c6-839475f98e41", 112 | "metadata": {}, 113 | "outputs": [], 114 | "source": [ 115 | "wowy_url = \"https://api.pbpstats.com/get-wowy-stats/nba\"\n", 116 | "wowy_params = {\n", 117 | " \"0Exactly1OnFloor\": \"201939\", # Stephen Curry on the floor\n", 118 | " \"TeamId\": \"1610612744\", # Golden State Warriors\n", 119 | " \"Season\": \"2015-16\",\n", 120 | " \"SeasonType\": \"Regular Season\",\n", 121 | " \"Type\": \"Player\" # Player stats\n", 122 | "}\n", 123 | "wowy_response = requests.get(wowy_url, params=wowy_params)\n", 124 | "wowy = wowy_response.json()\n", 125 | "player_stats = wowy[\"multi_row_table_data\"]" 126 | ] 127 | }, 128 | { 129 | "cell_type": "markdown", 130 | "id": "b0e49a9a-0445-4ff2-a194-89c1639620b6", 131 | "metadata": {}, 132 | "source": [ 133 | "To get each players 3pt% with Curry on the floor" 134 | ] 135 | }, 136 | { 137 | "cell_type": "code", 138 | "execution_count": 6, 139 | "id": "91b53a7f-4fa0-4152-a516-de8cfb570e37", 140 | "metadata": {}, 141 | "outputs": [ 142 | { 143 | "name": "stdout", 144 | "output_type": "stream", 145 | "text": [ 146 | "Andrew Bogut - 1 / 1 (1.0)\n", 147 | "Jason Thompson - 0 / 0 (0)\n", 148 | "Brandon Rush - 41 / 89 (0.461)\n", 149 | "Stephen Curry - 402 / 886 (0.454)\n", 150 | "Klay Thompson - 216 / 509 (0.424)\n", 151 | "Harrison Barnes - 58 / 154 (0.377)\n", 152 | "Andre Iguodala - 31 / 81 (0.383)\n", 153 | "Draymond Green - 81 / 213 (0.38)\n", 154 | "Shaun Livingston - 1 / 4 (0.25)\n", 155 | "Ian Clark - 8 / 21 (0.381)\n", 156 | "Leandro Barbosa - 18 / 46 (0.391)\n", 157 | "James Michael McAdoo - 0 / 0 (0)\n", 158 | "Kevon Looney - 0 / 0 (0)\n", 159 | "Marreese Speights - 5 / 14 (0.357)\n", 160 | "Anderson Varejao - 0 / 0 (0)\n", 161 | "Festus Ezeli - 0 / 0 (0)\n" 162 | ] 163 | } 164 | ], 165 | "source": [ 166 | "for player in player_stats:\n", 167 | " fg3m = player.get('FG3M', 0) # If value for stat is 0 it won't be in dict, so use the get method to set value to 0 if key is not found\n", 168 | " fg3a = player.get('FG3A', 0)\n", 169 | " fg3pct = round(fg3m/fg3a, 3) if fg3a > 0 else 0\n", 170 | " print(f\"{player['Name']} - {fg3m} / {fg3a} ({fg3pct})\")" 171 | ] 172 | }, 173 | { 174 | "cell_type": "markdown", 175 | "id": "a2e4c575-cdca-4137-b933-7b85603af7a6", 176 | "metadata": {}, 177 | "source": [ 178 | "### Dallas Mavericks team stats with Luka Doncic on the floor in 2021-22 playoffs vs the Suns" 179 | ] 180 | }, 181 | { 182 | "cell_type": "code", 183 | "execution_count": 7, 184 | "id": "723314ce-6f42-400c-94e8-927f97aa4280", 185 | "metadata": {}, 186 | "outputs": [], 187 | "source": [ 188 | "wowy_url = \"https://api.pbpstats.com/get-wowy-stats/nba\"\n", 189 | "wowy_params = {\n", 190 | " \"0Exactly1OnFloor\": \"1629029\", # Luka Doncic on the floor\n", 191 | " \"TeamId\": \"1610612742\", # Dallas\n", 192 | " \"Season\": \"2021-22\",\n", 193 | " \"SeasonType\": \"Playoffs\",\n", 194 | " \"Type\": \"Team\", # Team stats\n", 195 | " \"Opponent\": \"1610612756\"\n", 196 | "}\n", 197 | "wowy_response = requests.get(wowy_url, params=wowy_params)\n", 198 | "wowy = wowy_response.json()\n", 199 | "team_stats = wowy[\"single_row_table_data\"]\n", 200 | "lineup_stats = wowy[\"multi_row_table_data\"]" 201 | ] 202 | }, 203 | { 204 | "cell_type": "markdown", 205 | "id": "086b8c66-8271-4c09-b035-2980c1d4b0d9", 206 | "metadata": {}, 207 | "source": [ 208 | "### Golden State Warriors team stats with at least one of Stephen Curry, Draymond Green and Klay Thompson on the floor vs the other three conference finalists" 209 | ] 210 | }, 211 | { 212 | "cell_type": "code", 213 | "execution_count": 8, 214 | "id": "c5ca20b5-b22d-4100-b94f-a137ef61f4e5", 215 | "metadata": {}, 216 | "outputs": [], 217 | "source": [ 218 | "wowy_url = \"https://api.pbpstats.com/get-wowy-stats/nba\"\n", 219 | "wowy_params = {\n", 220 | " \"0GreaterThan1OnFloor\": \"202691,203110,201939\", # At least one of Stephen Curry, Draymond Green and Klay Thompson on the floor\n", 221 | " \"TeamId\": \"1610612744\", # Golden State\n", 222 | " \"Season\": \"2021-22\",\n", 223 | " \"SeasonType\": \"Regular Season\",\n", 224 | " \"Type\": \"Team\", # Team stats\n", 225 | " \"Opponent\": \"1610612742,1610612738,1610612748\" # Dallas, Boston and Miami\n", 226 | "}\n", 227 | "wowy_response = requests.get(wowy_url, params=wowy_params)\n", 228 | "wowy = wowy_response.json()\n", 229 | "team_stats = wowy[\"single_row_table_data\"]\n", 230 | "lineup_stats = wowy[\"multi_row_table_data\"]" 231 | ] 232 | }, 233 | { 234 | "cell_type": "markdown", 235 | "id": "13b418f5-1128-4a5a-a95c-d26544efe051", 236 | "metadata": {}, 237 | "source": [ 238 | "### Opponent stats with Rudy Gobert on the floor in the 4th quarter in high and very high leverage situations" 239 | ] 240 | }, 241 | { 242 | "cell_type": "code", 243 | "execution_count": 9, 244 | "id": "047dbc58-4c2f-488d-8989-110598caac68", 245 | "metadata": {}, 246 | "outputs": [], 247 | "source": [ 248 | "wowy_url = \"https://api.pbpstats.com/get-wowy-stats/nba\"\n", 249 | "wowy_params = {\n", 250 | " \"0Exactly1OffFloor\": \"203497\", # Rudy Gobert off the floor\n", 251 | " \"TeamId\": \"1610612762\", # Utah\n", 252 | " \"Season\": \"2021-22\",\n", 253 | " \"SeasonType\": \"Regular Season\",\n", 254 | " \"Type\": \"Opponent\", # Opponent stats\n", 255 | " \"Period\": \"4\",\n", 256 | " \"Leverage\": \"High,VeryHigh\" # high and very high leverage\n", 257 | "}\n", 258 | "wowy_response = requests.get(wowy_url, params=wowy_params)\n", 259 | "wowy = wowy_response.json()\n", 260 | "opponent_stats = wowy[\"single_row_table_data\"]\n", 261 | "lineup_opponent_stats = wowy[\"multi_row_table_data\"]" 262 | ] 263 | }, 264 | { 265 | "cell_type": "markdown", 266 | "id": "678070af-e7bb-4f85-80d0-f081a76531d9", 267 | "metadata": {}, 268 | "source": [ 269 | "### Boston Celtics stats vs Miami Heat in 2021-22 playoffs with both Jayson Tatum and Jimmy Butler on the floor" 270 | ] 271 | }, 272 | { 273 | "cell_type": "code", 274 | "execution_count": 10, 275 | "id": "72eeb2d2-3efa-4361-a078-21d3f93269a0", 276 | "metadata": {}, 277 | "outputs": [], 278 | "source": [ 279 | "wowy_url = \"https://api.pbpstats.com/get-wowy-stats/nba\"\n", 280 | "wowy_params = {\n", 281 | " \"0Exactly1OnFloor\": \"1628369\", # Jayson Tatum on the floor\n", 282 | " \"TeamId\": \"1610612738\", # Boston\n", 283 | " \"Season\": \"2021-22\",\n", 284 | " \"SeasonType\": \"Playoffs\",\n", 285 | " \"Type\": \"Team\", # Team stats\n", 286 | " \"Opponent\": \"1610612748\", # vs Miami\n", 287 | " \"OpponentExactly1OnFloor\": \"202710\" # Jimmy Bulter on the floor\n", 288 | "}\n", 289 | "wowy_response = requests.get(wowy_url, params=wowy_params)\n", 290 | "wowy = wowy_response.json()\n", 291 | "team_stats = wowy[\"single_row_table_data\"]\n", 292 | "lineup_stats = wowy[\"multi_row_table_data\"]" 293 | ] 294 | }, 295 | { 296 | "cell_type": "markdown", 297 | "id": "2e349bf5-2fb9-447a-aafa-cdcaf899b72d", 298 | "metadata": {}, 299 | "source": [ 300 | "### Kevin Durant on the floor in 2021-22 in the final 2 mintues of the 4th quarter and OT with the score within 3 points" 301 | ] 302 | }, 303 | { 304 | "cell_type": "code", 305 | "execution_count": 11, 306 | "id": "e622759f-f7a7-4f85-8fc9-cefd94adc873", 307 | "metadata": {}, 308 | "outputs": [], 309 | "source": [ 310 | "wowy_url = \"https://api.pbpstats.com/get-wowy-stats/nba\"\n", 311 | "wowy_params = {\n", 312 | " \"0Exactly1OnFloor\": \"201142\", # Kevin Durant on the floor\n", 313 | " \"TeamId\": \"1610612751\", # Brooklyn\n", 314 | " \"Season\": \"2021-22\",\n", 315 | " \"SeasonType\": \"Regular Season\",\n", 316 | " \"Type\": \"Team\", # Team stats\n", 317 | " \"FromMargin\": -3,\n", 318 | " \"ToMargin\": 3,\n", 319 | " \"FromTime\": 120,\n", 320 | " \"ToTime\": 0,\n", 321 | " \"Period\": \"4_OT\"\n", 322 | "}\n", 323 | "wowy_response = requests.get(wowy_url, params=wowy_params)\n", 324 | "wowy = wowy_response.json()\n", 325 | "team_stats = wowy[\"single_row_table_data\"]\n", 326 | "lineup_stats = wowy[\"multi_row_table_data\"]" 327 | ] 328 | }, 329 | { 330 | "cell_type": "markdown", 331 | "id": "7a3fcb69-722a-417e-b725-36cb980277e7", 332 | "metadata": {}, 333 | "source": [ 334 | "### Sue Bird on the floor since 2009 in the regular season" 335 | ] 336 | }, 337 | { 338 | "cell_type": "code", 339 | "execution_count": 12, 340 | "id": "e076bb28-3764-46e0-85a1-b7b550b2728a", 341 | "metadata": {}, 342 | "outputs": [], 343 | "source": [ 344 | "wowy_url = \"https://api.pbpstats.com/get-wowy-stats/wnba\"\n", 345 | "wowy_params = {\n", 346 | " \"0Exactly1OnFloor\": \"100720\", # Sue Bird on the floor\n", 347 | " \"TeamId\": \"1611661328\", # Seattle\n", 348 | " \"Season\": \"2022,2021,2020,2019,2018,2017,2016,2015,2014,2013,2012,2011,2010,2009\",\n", 349 | " \"SeasonType\": \"Regular Season\",\n", 350 | " \"Type\": \"Team\" # Team stats\n", 351 | "}\n", 352 | "wowy_response = requests.get(wowy_url, params=wowy_params)\n", 353 | "wowy = wowy_response.json()\n", 354 | "team_stats = wowy[\"single_row_table_data\"]\n", 355 | "lineup_stats = wowy[\"multi_row_table_data\"]" 356 | ] 357 | }, 358 | { 359 | "cell_type": "code", 360 | "execution_count": null, 361 | "id": "ba2d6d08-9b05-450b-a675-47ae028ec33f", 362 | "metadata": {}, 363 | "outputs": [], 364 | "source": [] 365 | } 366 | ], 367 | "metadata": { 368 | "kernelspec": { 369 | "display_name": "playground", 370 | "language": "python", 371 | "name": "playground" 372 | }, 373 | "language_info": { 374 | "codemirror_mode": { 375 | "name": "ipython", 376 | "version": 3 377 | }, 378 | "file_extension": ".py", 379 | "mimetype": "text/x-python", 380 | "name": "python", 381 | "nbconvert_exporter": "python", 382 | "pygments_lexer": "ipython3", 383 | "version": "3.8.9" 384 | } 385 | }, 386 | "nbformat": 4, 387 | "nbformat_minor": 5 388 | } 389 | -------------------------------------------------------------------------------- /live-games.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "id": "89a218aa-b68d-4372-8e37-56a58a232d46", 6 | "metadata": {}, 7 | "source": [ 8 | "This endpoint can be used to get all today's games with their current score and time remaining" 9 | ] 10 | }, 11 | { 12 | "cell_type": "code", 13 | "execution_count": 1, 14 | "id": "1c0efce7-6bb0-41b0-b912-a266c0356e7d", 15 | "metadata": {}, 16 | "outputs": [], 17 | "source": [ 18 | "import requests" 19 | ] 20 | }, 21 | { 22 | "cell_type": "markdown", 23 | "id": "7dedeaee-daab-4585-8bc9-a4bae1fc0caf", 24 | "metadata": {}, 25 | "source": [ 26 | "### WNBA" 27 | ] 28 | }, 29 | { 30 | "cell_type": "code", 31 | "execution_count": 2, 32 | "id": "6ac7756f-b898-4feb-ac58-cc5104791f79", 33 | "metadata": {}, 34 | "outputs": [ 35 | { 36 | "data": { 37 | "text/plain": [ 38 | "{'live_games': 1,\n", 39 | " 'game_data': [{'gameid': '1022200047',\n", 40 | " 'time': '2nd Qtr - 06:35',\n", 41 | " 'home': 'CHI 29',\n", 42 | " 'away': 'LVA 34'},\n", 43 | " {'gameid': '1022200048',\n", 44 | " 'time': '07:00 PM ET - 00:00.0',\n", 45 | " 'home': 'CON 0',\n", 46 | " 'away': 'WAS 0'}]}" 47 | ] 48 | }, 49 | "execution_count": 2, 50 | "metadata": {}, 51 | "output_type": "execute_result" 52 | } 53 | ], 54 | "source": [ 55 | "url = \"https://api.pbpstats.com/live/games/wnba\"\n", 56 | "response = requests.get(url)\n", 57 | "response_json = response.json()\n", 58 | "response_json" 59 | ] 60 | }, 61 | { 62 | "cell_type": "code", 63 | "execution_count": null, 64 | "id": "cddd54c9-1955-4a2d-bf36-193cd0bce688", 65 | "metadata": {}, 66 | "outputs": [], 67 | "source": [] 68 | } 69 | ], 70 | "metadata": { 71 | "kernelspec": { 72 | "display_name": "playground", 73 | "language": "python", 74 | "name": "playground" 75 | }, 76 | "language_info": { 77 | "codemirror_mode": { 78 | "name": "ipython", 79 | "version": 3 80 | }, 81 | "file_extension": ".py", 82 | "mimetype": "text/x-python", 83 | "name": "python", 84 | "nbconvert_exporter": "python", 85 | "pygments_lexer": "ipython3", 86 | "version": "3.8.9" 87 | } 88 | }, 89 | "nbformat": 4, 90 | "nbformat_minor": 5 91 | } 92 | --------------------------------------------------------------------------------