Skip to content

Xiang511/CR-API

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Clash-Royale-API

GitHub last commit Github Created At GitHub Release GitHub License

Accessing the CR-API using Python

Users must obtain the corresponding API key to use. Please go to Official Document

Features

  • Search Clan information
  • Search Player information
  • Search local rankings
  • Search player achievement records

Under development

  • Implement a GUI

Example Usage

Here are some example code samples.

DEMO : https://www.youtube.com/watch?v=BKnR_kre6QI&ab_channel=XiangFang

FindClan.py

Search Clan information

import requests
import pandas as pd
import time

#Calculate starting time
start_time = time.time()

# Enter your key
# Go to https://developer.clashroyale.com/#/ 

API_KEY = ""
headers = {
    "Authorization": "Bearer {}".format(API_KEY)
}

# GET ClanTag
#ex: %23QCRY22P8

clan_tag = "%23QCRY22P8"


url = "https://api.clashroyale.com/v1/clans/{}".format(clan_tag)
response = requests.get(url, headers=headers)


try:
    if response.status_code == 200:
        clan = response.json()

        df = pd.DataFrame(clan["memberList"])
        df.to_excel("FindClan.xlsx")

        
        end_time = time.time()
        
        print(f"Time:{end_time - start_time}")
    else:
        print(response.status_code)
except Exception as e:
    print(e)