From ba490db1b0f3956205eb5d90eaf326adb14f6a63 Mon Sep 17 00:00:00 2001 From: nzrymiak Date: Thu, 22 Apr 2021 20:50:34 -0700 Subject: [PATCH] feat: add Riot Games support --- README.md | 171 +++++++++++++++++- api-connectors/riot_games/_meta.json | 9 + .../riot_games/lol_tournaments.json | 44 +++++ .../riot_games/lor_leaderboards.json | 36 ++++ api-connectors/riot_games/tests/tests.py | 5 + .../riot_games/tft_challengers.json | 60 ++++++ .../riot_games/tft_grandmasters.json | 60 ++++++ api-connectors/riot_games/tft_masters.json | 60 ++++++ 8 files changed, 441 insertions(+), 4 deletions(-) create mode 100644 api-connectors/riot_games/_meta.json create mode 100644 api-connectors/riot_games/lol_tournaments.json create mode 100644 api-connectors/riot_games/lor_leaderboards.json create mode 100644 api-connectors/riot_games/tests/tests.py create mode 100644 api-connectors/riot_games/tft_challengers.json create mode 100644 api-connectors/riot_games/tft_grandmasters.json create mode 100644 api-connectors/riot_games/tft_masters.json diff --git a/README.md b/README.md index 392f0cf..3b26b2e 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,7 @@ You can contribute to this project in two ways. Please check the [contributing g * [Calendar](#calendar) * [Crime](#crime) * [Finance](#finance) +* [Games](#games) * [Geocoding](#geocoding) * [Jobs](#jobs) * [Lifestyle](#lifestyle) @@ -952,6 +953,172 @@ perpetual_df.sort_values(by=['last_traded_at'], ascending=False).head(3).reset_i | 2 | Huobi Futures | CVC-USDT | CVC | perpetual | 0.178268 | -0.336302 | 0.106314 | nan | 876960 | 2021-02-03 20:14:23 | + +### Games + + +#### [Riot Games](riot_games) -- Collect Video game data from Riot Games + +
+ How many days is the next League of Legends tournament running for in North America? + +```python +from dataprep.connector import connect + +# You can get ”riot_games_access_token“ by registering as a developer https://developer.riotgames.com/ +conn_riot_games = connect('riot_games', _auth={'access_token':riot_games_access_token}) + +df = await conn_riot_games.query('lol_tournaments', region='na1') + +days = df['name_key_secondary'] +max_day = 0 +for day in days: + day = int(day.split("day_",1)[1]) + if day > max_day: + max_day = day + +print(max_day, 'days') +``` + + 4 days + +
+ + +
+ Find cluster labels for Asian League of Rinterra players based on their league points. + +```python +from dataprep.connector import connect +from sklearn.cluster import KMeans +import pandas as pd + +# You can get ”riot_games_access_token“ by registering as a developer https://developer.riotgames.com/ +conn_riot_games = connect('riot_games', _auth={'access_token':riot_games_access_token}) + +df = await conn_riot_games.query('lor_leaderboards', region='asia') + +X = pd.DataFrame(df.league_points) +model = KMeans() +model.fit(X) +df['cluster_labels'] = model.labels_ +df +``` + +| | name | rank | league_points | cluster_labels | +|-: |-: |-: |-: |-: | +| 0 | WCS Master | 0 | 3001 | 1 | +| 1 | UCG SDARO | 1 | 2627 | 5 | +| 2 | pisukaru | 2 | 587 | 7 | +| 3 | 영처리2 | 3 | 546 | 7 | +| 4 | jake | 4 | 539 | 7 | +| ... | ... | ... | ... | ... | +| 594 | 더스티네스 | 594 | 0 | 0 | +| 595 | HamapaBack | 595 | 0 | 0 | +| 596 | 북미 판다곰 | 596 | 0 | 0 | +| 597 | Coray | 597 | 0 | 0 | +| 598 | 고양이집사 | 598 | 0 | 0 | + + +
+ +
+ List highest trending North American, Teamfight Tactics masters based on recent wins, activity and league points + +```python +from dataprep.connector import connect +import pandas as pd + +# You can get ”riot_games_access_token“ by registering as a developer https://developer.riotgames.com/ +conn_riot_games = connect('riot_games', _auth={'access_token':riot_games_access_token}) + +df = await conn_riot_games.query('tft_masters', region='na1') + +trending = pd.DataFrame() +for i, row in df.iterrows(): + if not row.inactive and row.hot_streak: + trending = trending.append(row) + +trending.sort_values(['league_points'], ascending=False) +``` + + +| | fresh_blood | hot_streak | inactive | league_points | losses | name | player_id | veteran | wins | +|-: |-: |-: |-: |-: |-: |-: |-: |-: |- | +| 10479 | 0.0 | 1.0 | 0.0 | 219.0 | 419.0 | Fried twist | qxlcIGuhYSrihdPop8h1I8nszwHd_STYMdFYZ8bjkrA6hAM | 0.0 | 78.0 | +| 6054 | 0.0 | 1.0 | 0.0 | 215.0 | 49.0 | Ge Ju 9z | vYyJ_eow2vSKAFoci2OStuBF_3mC872lFoHYRkjPxkmWI3U | 0.0 | 11.0 | +| 12517 | 0.0 | 1.0 | 0.0 | 213.0 | 30.0 | LaJi SUPPORT | lZlEx1NSVgooDSvWKabqaaJg5FHS0MxIyiDrtai1yYz0Sjin | 0.0 | 29.0 | +| 10790 | 0.0 | 1.0 | 0.0 | 202.0 | 67.0 | Dis396 | tyQiNvL66Lk29zzLS0wizD6QvAZmiMKrZCSW5QLIAH75dso | 0.0 | 15.0 | +| 1241 | 0.0 | 1.0 | 0.0 | 175.0 | 202.0 | izsakura2 | t9hu5kb4dvmiwJuqNf5hkzAeQGXZjtulwAD_fkEXf56Pd_ep | 0.0 | 33.0 | +| ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | +| 6954 | 0.0 | 1.0 | 0.0 | 0.0 | 52.0 | zddddddy | Kk9OOe92TwTQM-6ij8B_8iEND298w15OJ03ontPmhoWxJB... | 0.0 | 24.0 | +| 2554 | 0.0 | 1.0 | 0.0 | 0.0 | 62.0 | Lintrolling | 9e8lvokk5JYgq8K8PGA3GzXgi10I23UQGPjuuFun5_-noKY | 0.0 | 11.0 | +| 82 | 0.0 | 1.0 | 0.0 | 0.0 | 31.0 | RacheI Zane | q_7HyUSPdKVSNRTWIjEAd-fhpRyJPbpZ-CHEC9oMgft9l2M | 0.0 | 10.0 | +| 2769 | 0.0 | 1.0 | 0.0 | 0.0 | 56.0 | 10086 Take u Fly | PcawuEtvx4Zorkq1O4Ad3zUdLJooA01MOV_Nb_PEMxfHWGs | 0.0 | 19.0 | +| 18 | 0.0 | 1.0 | 0.0 | 0.0 | 19.0 | Toshi Roll | PPq5MIZkw2pIxsWTvyiPTSjZTvDV9FH472NPXjDcWT9Uqyo | 0.0 | 8.0 | + +
+ +
+ Who is the best Korean, Teamfight Tactics veteran challenger? + + +```python +from dataprep.connector import connect + +# You can get ”riot_games_access_token“ by registering as a developer https://developer.riotgames.com/ +conn_riot_games = connect('riot_games', _auth={'access_token':riot_games_access_token}) + +df = await conn_riot_games.query('tft_challengers', region='kr') + +for i, row in df.iterrows(): + if row.veteran == True: + print(row['name']) + break +``` + + 구깨룩3 + + +
+ +
+ List Grandmasters in order of win-loss ratio + +```python +from dataprep.connector import connect + +# You can get ”riot_games_access_token“ by registering as a developer https://developer.riotgames.com/ +conn_riot_games = connect('riot_games', _auth={'access_token':riot_games_access_token}) + +df = await conn_riot_games.query('tft_grandmasters', region='jp1') + +win_loss_ratios = [] +for i, row in df.iterrows(): + win_loss_ratio = row.wins / row.losses + win_loss_ratios.append(win_loss_ratio) + +df['win_loss_ratio'] = win_loss_ratios +df.sort_values(['win_loss_ratio'], ascending=False) +``` + +| | player_id | name | league_points | wins | losses | veteran | inactive | fresh_blood | hot_streak | win_loss_ratio | +|-: |-: |-: |-: |-: |-: |-: |-: |-: |-: |- | +| 93 | WJ4VwbbbDA-9tOs7gev_xt2gls3gG1z6ZaqyHWsnzI7gJp0 | スランプジャパン | 690 | 38 | 118 | False | False | True | False | 0.322034 | +| 61 | -5bowfubfVhL6gFU7QIPgOITWkyfjq98KaIW2Y1awT174o... | lsp32 | 707 | 83 | 270 | False | False | True | False | 0.307407 | +| 57 | Yl96DsPVNXv-MN0SK5_KSOsi6bsTMC6yPIfwUQ9Pp-mjKDg | 国日代VDafutyfs | 672 | 79 | 260 | False | False | False | False | 0.303846 | +| 1 | ioUR_fR5MeyuDaXS1kzLc0Jm5UVQQFQgoGkZYSLeNvZRY7... | Young Cái Hand | 782 | 139 | 474 | False | False | False | False | 0.293249 | +| 15 | 6yTAJK-mL-9c4SAanU6OC4X58DT_I6d7risCASftxfcWYL... | LLLXY0504 | 624 | 55 | 189 | False | False | True | False | 0.291005 | +| ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | +| 31 | Bv0RIYd2QHNvBOYtaQl8ncAJimQ-YDfFQZUvoMuMZpAalL... | dosaidon0 | 803 | 48 | 489 | False | False | False | False | 0.098160 | +| 58 | LCr2u5fYW4v-WcEG2WeiW8Im-0qO6q4MiVLY75_zECyGabE | mitsfranken | 719 | 57 | 598 | True | False | False | False | 0.095318 | +| 68 | 3hZLkddFoPTx28T3tYv4syWc-mku41vWmJLo9AFZkB4bfQ | リキえもん | 710 | 15 | 168 | False | False | False | False | 0.089286 | +| 11 | oVzNZPfY_yjFYfYAp8G9kuZ_SHMdfomPpNevVklPfUyjEqM | ちよちゃん114 | 721 | 61 | 721 | False | False | True | False | 0.084605 | +| 13 | jlO3045YJZ8B8NKgJ_7fQRSVXPH5Zghe0Ds78Zr60NWFyQ | marsh | 646 | 28 | 338 | False | False | True | False | 0.082840 | + +
+ + ### Geocoding #### [MapQuest](./mapquest) -- Collect Driving Directions, Maps, Traffic Data @@ -3880,10 +4047,6 @@ df[['title', 'description', 'channelTitle']] - - - - ### Weather diff --git a/api-connectors/riot_games/_meta.json b/api-connectors/riot_games/_meta.json new file mode 100644 index 0000000..66cc157 --- /dev/null +++ b/api-connectors/riot_games/_meta.json @@ -0,0 +1,9 @@ +{ + "tables": [ + "lol_tournaments", + "lor_leaderboards", + "tft_challengers", + "tft_grandmasters", + "tft_masters", + ] +} diff --git a/api-connectors/riot_games/lol_tournaments.json b/api-connectors/riot_games/lol_tournaments.json new file mode 100644 index 0000000..66238f5 --- /dev/null +++ b/api-connectors/riot_games/lol_tournaments.json @@ -0,0 +1,44 @@ +{ + "version": 1, + "request": { + "url": "https://{region}.api.riotgames.com/lol/clash/v1/tournaments", + "method": "GET", + "authorization": { + "type": "Header", + "keyName": "X-Riot-Token" + }, + "params": { + "region": true + } + }, + "examples": { + "region": "'na1'" + }, + "response": { + "ctype": "application/json", + "tablePath": "$.[*]", + "schema": { + "id": { + "target": "$.id", + "type": "int" + }, + "name_key": { + "target": "$.nameKey", + "type": "string" + }, + "name_key_secondary": { + "target": "$.nameKeySecondary", + "type": "string" + }, + "registration_time": { + "target": "$.schedule[*].registrationTime", + "type": "int" + }, + "start_time": { + "target": "$.schedule[*].startTime", + "type": "int" + } + }, + "orient": "records" + } +} diff --git a/api-connectors/riot_games/lor_leaderboards.json b/api-connectors/riot_games/lor_leaderboards.json new file mode 100644 index 0000000..b55fad8 --- /dev/null +++ b/api-connectors/riot_games/lor_leaderboards.json @@ -0,0 +1,36 @@ +{ + "version": 1, + "request": { + "url": "https://{region}.api.riotgames.com/lor/ranked/v1/leaderboards", + "method": "GET", + "authorization": { + "type": "Header", + "keyName": "X-Riot-Token" + }, + "params": { + "region": true + } + }, + "examples": { + "region": "'asia'" + }, + "response": { + "ctype": "application/json", + "tablePath": "$.players[*]", + "schema": { + "name": { + "target": "$.name", + "type": "string" + }, + "rank": { + "target": "$.rank", + "type": "int" + }, + "league_points": { + "target": "$.lp", + "type": "int" + } + }, + "orient": "records" + } +} diff --git a/api-connectors/riot_games/tests/tests.py b/api-connectors/riot_games/tests/tests.py new file mode 100644 index 0000000..e795ee1 --- /dev/null +++ b/api-connectors/riot_games/tests/tests.py @@ -0,0 +1,5 @@ +from dataprep.connector import Connector + + +def test_sanity(): + pass diff --git a/api-connectors/riot_games/tft_challengers.json b/api-connectors/riot_games/tft_challengers.json new file mode 100644 index 0000000..1f18f8c --- /dev/null +++ b/api-connectors/riot_games/tft_challengers.json @@ -0,0 +1,60 @@ +{ + "version": 1, + "request": { + "url": "https://{region}.api.riotgames.com/tft/league/v1/challenger", + "method": "GET", + "authorization": { + "type": "Header", + "keyName": "X-Riot-Token" + }, + "params": { + "region": true + } + }, + "examples": { + "region": "'kr'" + }, + "response": { + "ctype": "application/json", + "tablePath": "$.entries[*]", + "schema": { + "player_id": { + "target": "$.summonerId", + "type": "string" + }, + "name": { + "target": "$.summonerName", + "type": "string" + }, + "league_points": { + "target": "$.leaguePoints", + "type": "int" + }, + "wins": { + "target": "$.wins", + "type": "int" + }, + "losses": { + "target": "$.losses", + "type": "int" + }, + "veteran": { + "target": "$.veteran", + "type": "boolean" + }, + "inactive": { + "target": "$.inactive", + "type": "boolean" + }, + "fresh_blood": { + "target": "$.freshBlood", + "type": "boolean" + }, + "hot_streak": { + "target": "$.hotStreak", + "type": "boolean" + } + }, + "orient": "records" + } +} diff --git a/api-connectors/riot_games/tft_grandmasters.json b/api-connectors/riot_games/tft_grandmasters.json new file mode 100644 index 0000000..973054c --- /dev/null +++ b/api-connectors/riot_games/tft_grandmasters.json @@ -0,0 +1,60 @@ +{ + "version": 1, + "request": { + "url": "https://{region}.api.riotgames.com/tft/league/v1/grandmaster", + "method": "GET", + "authorization": { + "type": "Header", + "keyName": "X-Riot-Token" + }, + "params": { + "region": true + } + }, + "examples": { + "region": "'jp1'" + }, + "response": { + "ctype": "application/json", + "tablePath": "$.entries[*]", + "schema": { + "player_id": { + "target": "$.summonerId", + "type": "string" + }, + "name": { + "target": "$.summonerName", + "type": "string" + }, + "league_points": { + "target": "$.leaguePoints", + "type": "int" + }, + "wins": { + "target": "$.wins", + "type": "int" + }, + "losses": { + "target": "$.losses", + "type": "int" + }, + "veteran": { + "target": "$.veteran", + "type": "boolean" + }, + "inactive": { + "target": "$.inactive", + "type": "boolean" + }, + "fresh_blood": { + "target": "$.freshBlood", + "type": "boolean" + }, + "hot_streak": { + "target": "$.hotStreak", + "type": "boolean" + } + }, + "orient": "records" + } +} diff --git a/api-connectors/riot_games/tft_masters.json b/api-connectors/riot_games/tft_masters.json new file mode 100644 index 0000000..5fa58e5 --- /dev/null +++ b/api-connectors/riot_games/tft_masters.json @@ -0,0 +1,60 @@ +{ + "version": 1, + "request": { + "url": "https://{region}.api.riotgames.com/tft/league/v1/master", + "method": "GET", + "authorization": { + "type": "Header", + "keyName": "X-Riot-Token" + }, + "params": { + "region": true + } + }, + "examples": { + "region": "'na1'" + }, + "response": { + "ctype": "application/json", + "tablePath": "$.entries[*]", + "schema": { + "player_id": { + "target": "$.summonerId", + "type": "string" + }, + "name": { + "target": "$.summonerName", + "type": "string" + }, + "league_points": { + "target": "$.leaguePoints", + "type": "int" + }, + "wins": { + "target": "$.wins", + "type": "int" + }, + "losses": { + "target": "$.losses", + "type": "int" + }, + "veteran": { + "target": "$.veteran", + "type": "boolean" + }, + "inactive": { + "target": "$.inactive", + "type": "boolean" + }, + "fresh_blood": { + "target": "$.freshBlood", + "type": "boolean" + }, + "hot_streak": { + "target": "$.hotStreak", + "type": "boolean" + } + }, + "orient": "records" + } +}