LEAGUE-V4

리그 V4 관련 파이썬 코드를 작성하였습니다.

 

리그 V4관련 API는 다음과 같이 총 6개가 존재합니다.

필요 모듈과 기본 세팅은 Summoner-V4 와 같습니다.

import requests
from urllib import parse
import pprint
pp = pprint.PrettyPrinter(indent=4)
api_key = 'RGAPI-d01fa30c-f66c-49bf-a987-9c5b79b8f7e4'
request_header = {
                    "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.164 Safari/537.36",
                    "Accept-Language": "ko,en-US;q=0.9,en;q=0.8,es;q=0.7",
                    "Accept-Charset": "application/x-www-form-urlencoded; charset=UTF-8",
                    "Origin": "https://developer.riotgames.com",
                    "X-Riot-Token": api_key
                }

 

 

신의 리그 (챌린저리그 / 그랜드마스터리그/ 마스터리그) 큐별 소환사 정보

함수 :

변수 설명 :

queue : 솔로 랭크 = solo, 자유 랭크 = free

tier : 티어 선택 (CHALLENGER, GRANDMASTER, MASTER)

def league_v4_god_league(queue, tier):
    if queue == "solo" :
        queue = "RANKED_SOLO_5x5"
    elif queue == "free" :
        queue = "RANKED_FLEX_SR"
    url = f"https://kr.api.riotgames.com/lol/league/v4/{tier.lower()}leagues/by-queue/{queue}"
    return requests.get(url, headers=request_header).json()

함수 호출 :

pp.pprint(league_v4_god_league("challenger", "solo"))
pp.pprint(league_v4_god_league("challenger", "free"))

pp.pprint(league_v4_god_league("grandmaster", "solo"))
pp.pprint(league_v4_god_league("grandmaster", "free"))

pp.pprint(league_v4_god_league("master", "solo"))
pp.pprint(league_v4_god_league("master", "free"))

 

호출 결과 :

{   'entries': [   {   'freshBlood': False,
                       'hotStreak': True,
                       'inactive': False,
                       'leaguePoints': 1138,
                       'losses': 256,
                       'rank': 'I',
                       'summonerId': 'HOSYigNzY0--ax_zS_wCcGmu9-_qb5fhNunGJswbQZ1QGFwQdkSLU2Eg4g',
                       'summonerName': 'sword god14',
                       'veteran': True,
                       'wins': 323},
                   {   'freshBlood': False,
                       'hotStreak': False,
                       'inactive': False,
                       'leaguePoints': 920,
                       'losses': 142,
                       'rank': 'I',
                       'summonerId': 'hlx4Nzj5qZS-PwH4eVqivAxqMT_FItj_0Y9Z-1HBnNXIgzg',
                       'summonerName': 'Pnpm',
                       'veteran': True,
                       'wins': 187},

(너무 길어서 생략)

 

소환사가 속해 있는 리그 정보

함수 :

def league_v4_summoner_league(summoner_id):
    url = f"https://kr.api.riotgames.com/lol/league/v4/entries/by-summoner/{summoner_id}"
    return requests.get(url, headers=request_header).json()

함수 호출 :

(페이커 선수 summoner_id)

pp.pprint(league_v4_summoner_league("ErmVzmx0cl1QCDHqkNPxqD8yntjHg1_d1VdJNr0q01iPdw"))

호출 결과 :

[   {   'freshBlood': True,
        'hotStreak': False,
        'inactive': False,
        'leagueId': 'a37af09b-ecb8-3664-9453-cf2b0138dd6e',
        'leaguePoints': 731,
        'losses': 512,
        'queueType': 'RANKED_SOLO_5x5',
        'rank': 'I',
        'summonerId': 'ErmVzmx0cl1QCDHqkNPxqD8yntjHg1_d1VdJNr0q01iPdw',
        'summonerName': 'Hide on bush',
        'tier': 'GRANDMASTER',
        'veteran': False,
        'wins': 559}]

 

 

챌린저리그 ID로 리그 정보

함수 :

def league_v4_league_id(league_id):
    url = f"https://kr.api.riotgames.com/lol/league/v4/leagues/{league_id}"
    return requests.get(url, headers=request_header).json()

함수 호출 :

(위 페이커 선수 summoner_id로 league_id 알아 내서 검색)

pp.pprint(league_v4_league_id("a37af09b-ecb8-3664-9453-cf2b0138dd6e"))

호출 결과 :

{   'entries': [   {   'freshBlood': False,
                       'hotStreak': False,
                       'inactive': False,
                       'leaguePoints': 456,
                       'losses': 190,
                       'rank': 'I',
                       'summonerId': 'sdQ875-vjnsVtDyVBOK-0zV5LUBV_TrCqfN70asTKFLO0gKtF87unNnw0Q',
                       'summonerName': '농심 DnDn',
                       'veteran': True,
                       'wins': 225},
                   {   'freshBlood': True,
                       'hotStreak': False,
                       'inactive': False,
                       'leaguePoints': 782,
                       'losses': 328,
                       'rank': 'I',
                       'summonerId': 'lY20qSDKzEwJTXS6x9XJUuK28Kjs4MUIR27msQndo43q5m4ccJLZU6gCFA',
                       'summonerName': 'bilibilinico',
                       'veteran': False,
                       'wins': 394},

 

 

큐(솔로/자유 랭크)별 티어별(다이아, 플래티넘, 브/실/골/아이언) 등급별( 1, 2, 3 등) 소환사 정보

함수 :

변수 설명 :

queue : 솔로 랭크 = solo, 자유 랭크 = free

tier : 티어 선택 (DIAMOND, PLATINUM, GOLD, SILVER, BRONZE, IRON)

division : 각 티어 몇 단계인지 (1, 2, 3, 4)

page_number : 페이지당 결과가 약 200개씩 보관되어 있음

def league_v4_queue_tier_division(queue, tier, division, page_number):
    if division == 1 :
        division = 'I'
    elif division == 2 :
        division = 'II'
    elif division == 3 :
        division = 'III'
    elif division == 4:
        division = 'IV'
    if queue == "solo" :
        queue = "RANKED_SOLO_5x5"
    elif queue == "free" :
        queue = "RANKED_FLEX_SR"
    url = f"https://kr.api.riotgames.com/lol/league/v4/entries/{queue}/{tier}/{division}?page={page_number}"
    return requests.get(url, headers=request_header).json()

함수 호출 :

(예 : 플래3 솔로랭크 3번째 목록)

pp.pprint(league_v4_queue_tier_division("solo", "PLATINUM", 3, 3))

호출 결과 :

[   {   'freshBlood': False,
        'hotStreak': True,
        'inactive': False,
        'leagueId': '4679287f-7a04-4104-bb00-d3e035b7d891',
        'leaguePoints': 9,
        'losses': 14,
        'queueType': 'RANKED_SOLO_5x5',
        'rank': 'III',
        'summonerId': 'QifHMa7KNBYReZ5xmLgmT5WUsFnq-OfbnNiJHtUTjBh_gctB',
        'summonerName': 'Sweet Magic',
        'tier': 'PLATINUM',
        'veteran': False,
        'wins': 17},
    {   'freshBlood': False,
        'hotStreak': False,
        'inactive': False,
        'leagueId': '3258f35f-94c5-471c-9af8-ae3bb57c4f5a',
        'leaguePoints': 29,
        'losses': 64,
        'queueType': 'RANKED_SOLO_5x5',
        'rank': 'III',
        'summonerId': 'qTlCZRu62E1YV7jGi1K-gAxQexyEq7l1HuuxGT7UnolQy5Ee',
        'summonerName': 'king vladi',
        'tier': 'PLATINUM',
        'veteran': False,
        'wins': 79},

(너무 길어서 생략)

 

import requests
import pprint

pp = pprint.PrettyPrinter(indent=4)
api_key = 'RGAPI-5157b8b3-55bb-462d-bdad-f1b0dfc30313'
request_header = {
                    "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.164 Safari/537.36",
                    "Accept-Language": "ko,en-US;q=0.9,en;q=0.8,es;q=0.7",
                    "Accept-Charset": "application/x-www-form-urlencoded; charset=UTF-8",
                    "Origin": "https://developer.riotgames.com",
                    "X-Riot-Token": api_key
                }

def league_v4_god_league(queue, tier):
    if queue == "solo" :
        queue = "RANKED_SOLO_5x5"
    elif queue == "free" :
        queue = "RANKED_FLEX_SR"
    url = f"https://kr.api.riotgames.com/lol/league/v4/{tier.lower()}leagues/by-queue/{queue}"
    return requests.get(url, headers=request_header).json()


def league_v4_summoner_league(summoner_id):
    url = f"https://kr.api.riotgames.com/lol/league/v4/entries/by-summoner/{summoner_id}"
    return requests.get(url, headers=request_header).json()


def league_v4_league_id(league_id):
    url = f"https://kr.api.riotgames.com/lol/league/v4/leagues/{league_id}"
    return requests.get(url, headers=request_header).json()


def league_v4_queue_tier_division(queue, tier, division, page_number):
    if division == 1 :
        division = 'I'
    elif division == 2 :
        division = 'II'
    elif division == 3 :
        division = 'III'
    elif division == 4:
        division = 'IV'
    if queue == "solo" :
        queue = "RANKED_SOLO_5x5"
    elif queue == "free" :
        queue = "RANKED_FLEX_SR"
    url = f"https://kr.api.riotgames.com/lol/league/v4/entries/{queue}/{tier}/{division}?page={page_number}"
    return requests.get(url, headers=request_header).json()
반응형

'Data Science > LOL 프로젝트' 카테고리의 다른 글

Riot API (MATCH-V5) 코드 구현  (0) 2021.07.26
Riot API (LEAGUE-EXP-V4) 코드 구현  (0) 2021.07.26
Riot API (SUMMONER-V4) 코드 구현  (0) 2021.07.25
Riot API 사용하기 (웹사이트)  (0) 2021.07.25
Riot API 살펴보기  (0) 2021.07.20

+ Recent posts