An all-inclusive Python framework for the Riot Games League of Legends API. We focus on making the data easy and fun to work with, while providing all the tools necessary to create a website or do data analysis.

Overview

MIT Licensed Documentation Status DOI

Cassiopeia

A Python adaptation of the Riot Games League of Legends API (https://developer.riotgames.com/).

Cassiopeia is the sister library to Orianna (Java). It's been designed with usability in mind - making sure all the bookkeeping is done right so you can focus on getting the data you need and building your application.

Installation

pip install cassiopeia or see here for more information.

Match-V5 Update

On Monday, September 13th, 2021 Riot deprecated the match-v4 endpoints in favor of match-v5. The codebase was migrated to use the new endpoints, but it's likely that some bugs exist due to all the complex functionality between data types in Cass. Please submit PRs (preferably) or issues if you find bugs, and feel free to message the developers by creating an issue if you would like to contribute but don't know how to go about fixing a bug.

Why use Cass?

  • An excellent user interface that makes working with data from the Riot API easy and fun.

  • "Perfect" rate limiting.

  • Guaranteed optimal usage of your API key.

  • Built in caching and (coming) the ability to easily hook into a database for offline storage of data.

  • Extendability to non-Riot data. Because Cass is a framework and not just an API wrapper, you can integrate your own data sources into your project. Cass already supports Data Dragon and the champion.gg API in addition to the Riot API.

  • Dynamic settings so you can configure Cass for your specific use case.

Documentation and Examples

Cassiopeia's documentation and examples may be a little out of date, but should be quite helpful when getting started. Please submit a PR for any changes.

Example

Here's an example of a basic use of the API. The full documentation can be found at http://cassiopeia.readthedocs.org/en/latest/.

import random

import cassiopeia as cass

cass.set_riot_api_key("YOUR_KEY")  # This overrides the value set in your configuration/settings.

summoner = cass.get_summoner(name="Perkz", region="NA")
print("{name} is a level {level} summoner on the {region} server.".format(name=summoner.name,
                                                                          level=summoner.level,
                                                                          region=summoner.region))

champions = cass.get_champions(region="NA")
random_champion = random.choice(champions)
print("He enjoys playing champions such as {name}.".format(name=random_champion.name))

challenger_league = cass.get_challenger_league(queue=cass.Queue.ranked_solo_fives)
best_na = challenger_league[0].summoner
print("He's not as good as {name} at League, but probably a better python programmer!".format(name=best_na.name))

Django web Framework

There is an integration of cassiopeia to the popular python web framework Django made by Mori(Paaksing), this integration is aimed to fix most issues/conflicts related to co-ocurrence of cassiopeia and Django. In this integration will give you better tools for building your Django/DRF based app, you will have the ability to use any production tested cache backends that Django's cache framework supports.

A datastore called Omnistone is introduced in response to issue #1 of this repo, this is a refined version of Cache that automatically deletes expired objects when MAX_ENTRIES is hit, then culls the datastore according to the CULL_FRECUENCY given. The culling strategy used is the same as Django Cache Framework, which is LRU culling (Least Recently Used).

  • Link to django-cassiopeia repository (If you love using it, make sure to star!).
  • Link to django-cassiopeia documentations (Production Release v2.0).
  • If you have any issues or feature requests with django-cassiopeia, tag Mori in our discord server, or fire an issue in the repository.

Unfortunately, we currently don't have an integration to Flask and any contribution is welcome.

Questions/Contributions

Feel free to send pull requests or to contact us via github or discord. More information can be found in our documentation.

Bugs

If you find bugs please let us know via an issue or pull request. If you would like to help maintain Cassiopeia, let us know and we will invite you to our discord server.

Citing Cassiopeia

If you used Cassiopeia for your research, please cite the project.

Support Us

If you've loved using Cassiopeia, consider supporting us through PayPal or Patreon.

Disclaimer

Cassiopeia isn't endorsed by Riot Games and doesn't reflect the views or opinions of Riot Games or anyone officially involved in producing or managing League of Legends. League of Legends and Riot Games are trademarks or registered trademarks of Riot Games, Inc. League of Legends © Riot Games, Inc.

Comments
  • Fixes more issues with python 27

    Fixes more issues with python 27

    Resolves issue #25

    TODO

    • [x] Write a few tests
    • [x] Get passing on CircleCI
    • [x] Get passing using Python 3
    • [x] Conditional imports (Python 3 wont have future)
    • [x] TRIED!! Add super() overrides to some __init__ more simply
    • [x] Fix str/unicode problem
    opened by ckcollab 24
  • Rate limiters

    Rate limiters "leaks" calls

    Testing a (single-threaded) script of mine I got blacklisted( 2 times!!) overflow of limit

    Did not make any call from the web interface. Just run the program and went to sleep. (No API calls in the previous hours either). All the requests went through the baseriotapi.

    I don't think the problem is related to https://github.com/robrua/cassiopeia/pull/14 , as my program is not multi thread and thus there can not happen the race condition.

    At a first glance I can not spot the problem, but I'm not really an export in python threading.

    opened by MakersF 23
  • Summoner Match History Limited to 20

    Summoner Match History Limited to 20

    Hello,

    I am coming back to work with Cass since the Cass 3.0/Riot v5 update.

    Previously I was able to make a call in the following fashion to get every match for a particular summoner

    summoner = cass.get_summoner(name=summoner_name, region="NA")
    total_games = len(summoner.match_history)
    

    For some reason now I only get 20 matches back regardless of settings. Documentation seems to still support that it should return all matches and not just the latest 20, but maybe I'm missing something?

    opened by WeldFire 18
  • Bug : Some statistics on champions are not accessible

    Bug : Some statistics on champions are not accessible

    Good morning,

    I tried to use your library to get some information on base stats champions and I had trouble accessing these informations :+1:

    • 'StatsData' object has no attribute 'criticalStrikeChance'
    • 'StatsData' object has no attribute 'attackSpeedOffset'
    • 'StatsData' object has no attribute 'attackDamage'

    The code I used was like this :

    champions = cass.get_champions() champions[0].stats.attack_damage champions[0].stats.critical_strike_chance champions[0].stats.attack_speed

    I didn't try for the per_level of each but I guess the same issue can exist too.

    Thanks for your help !

    opened by Simire 12
  • Getting summoner names with non-ASCII characters fails

    Getting summoner names with non-ASCII characters fails

    import os
    
    import cassiopeia as cass
    
    cass.set_riot_api_key(os.getenv("RIOT_API_KEY"))
    
    s = cass.get_summoner(name="é", region="EUW")
    s.exists
    

    Outputs Making call: https://euw1.api.riotgames.com/lol/summoner/v4/summoners/by-name/\xc3\xa9

    Then fails with UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 65: ordinal not in range(128)

    I believe that the problem is this line: url = "https://{platform}.api.riotgames.com/lol/summoner/v4/summoners/by-name/{name}".format(platform=query["platform"].value.lower(), name=query["name"].replace(" ", "")).encode("utf-8").

    Removing the final .encode("utf-8") fixes the problem for me. I was surprised by the encode since the other urls aren't encoded at this stage and I would expect requests or urllib to handle the encoding.

    opened by blimmo 11
  • Add the ability to track the number of requests issued

    Add the ability to track the number of requests issued

    This PR adds the ability (disabled by default) of tracking the requests which are made.

    This allows users of the library to track of the usage of their limit, allowing to better investigate performances and efficiency of their code.

    I find this fundamental as I try a different architectural approach for my library, to be able to compare if I'm effectively improving the performances or not.

    This would make debugging issues like #16 a lot easier as well.

    Accept one PR, get one fix for free: fixed a typo in the documentation

    opened by MakersF 11
  • Minor

    Minor "bugs"

    #Participantstats item list position not respected

    #Match.py

    @lazy_property
        @load_match_on_attributeerror
        def items(self) -> List[Item]:
            ids = [self._data[ParticipantStatsData].item0,
                   self._data[ParticipantStatsData].item1,
                   self._data[ParticipantStatsData].item2,
                   self._data[ParticipantStatsData].item3,
                   self._data[ParticipantStatsData].item4,
                   self._data[ParticipantStatsData].item5,
                   self._data[ParticipantStatsData].item6
            ]
            version = _choose_staticdata_version(self.__match)
            return SearchableList([Item(id=id, version=version, region=self.__match.region) for id in ids if id])
    

    Currently the list will only contain items that exist. It would be useful to have the position of each item preserved as well (eg. to see a relationship between active items and key binds).

    I can think of 2 ways of solving this:

    1. Add properties for item0-6 to the stats object
    2. Add empty items to the list to let it contain everything (or at least an option to with a param).
    opened by tyuo9980 10
  • So many service 429s

    So many service 429s

    Hello!

    Background: Kinda-ish new to Python, and really new to rate limits/calls.

    I'm running a code where I'm pulling all Master tier matches from 4 October. I'm using the code you've kindly provided "pull_masters_tier.py" as a base. To make sure things are running smoothly, I have the line "print("Got {0}".format(match))" to show me that it is gathering matches correctly. However, I'm getting a lot of "SERVICE 429." It looks something like this as the script is running: Got Match #2310443223 SERVICE 429 SERVICE 429 Got Match #2310385404 Got Match #2310326909 Got Match #2310279651 Got Match #2310264967 Got Match #2310198579 Got Match #2310203223 Got Match #2309999296 SERVICE 429 SERVICE 429 Got Match #2309988823 Got Match #2309994894 Got Match #2309974510 SERVICE 429 SERVICE 429 SERVICE 429 SERVICE 429

    Is this related to my rate limit? I don't want to get blacklisted and need to know if things are going alright. The data is getting saved to a file nicely, so that is alright. But I'm working on a very large project with this data and will need to gather data a LOT in the near future.

    Sorry for the noob question and thank you in advance!

    opened by alyssa-adams 10
  • Ghost match

    Ghost match

    Hey guys,

    I spent half an hour to understand an error happened when I used Cass. Firstly you can try this query, and will find a match_id '2405929288':

    https://na.api.pvp.net/api/lol/na/v2.2/matchlist/by-summoner/73099728?rankedQueues=RANKED_SOLO_5x5&seasons=PRESEASON2016&api_key=XXX

    Then you try to get the details of this match, and it will return 404, which means even if we can find a match_id in one match list, we are not 100% sure it has record from the match method:

    https://na.api.pvp.net/api/lol/na/v2.2/match/2405929288?includeTimeline=0&api_key=XXX

    {
        "status": {
            "message": "Not Found",
            "status_code": 404
        }
    }
    

    Because of this, we may get an None when we use match = riotapi.get_match(mf) in Cass. Right now I choose to use if match is None to avoid this (can not use '==' because Match.eq use Match.id).

    Update: And then I found the region of this match is 'EUW', which means the region setting is useless?

    Update 2: I reconsidered this problem, and found that if Cass. returned 404 correctly, there should not be this problem. So I think the exception part of Cass. should be checked.

    opened by simoncos 10
  • participantstats

    participantstats

    So, I'm trying to work through this, form your example match.py code you have a list of p = match.participants[summoner]. So if I wanted the stats of these participants wouldn't it just be p = match.participantstats[summoner]? That doesn't run and I'm unsure of why.

    Also thanks for your work so far!

    opened by aluckyhit 9
  • begin_time seems to be ignored during API calls in get_match_history

    begin_time seems to be ignored during API calls in get_match_history

    I set begin_time, but cass makes a bunch of calls like: Making call: https://na1.api.riotgames.com/lol/match/v3/matchlists/by-account/#########?beginIndex=0&endIndex=100 Making call: https://na1.api.riotgames.com/lol/match/v3/matchlists/by-account/#########?beginIndex=100&endIndex=200 Making call: https://na1.api.riotgames.com/lol/match/v3/matchlists/by-account/#########?beginIndex=200&endIndex=300

    And only then it filters needed matches. So there are lots of unnecessary API calls.

    opened by InvalidPointer 9
  • Adding match_statistics.py example, solved type hinting issue in participants method

    Adding match_statistics.py example, solved type hinting issue in participants method

    A new example was created to showcase match statistics, please see examples/match_statistics.py

    Adjusted participants method in Match class to properly hint a SearchableList, see issue:

    https://github.com/meraki-analytics/cassiopeia/issues/431#issue-1474219230

    opened by alexf-git 0
  • CumulativeTimeline object doesn't have all the info available by the API

    CumulativeTimeline object doesn't have all the info available by the API

    Accessing a ParticipantState in a CumulativeTimeline object (i.e. at a particular timestamp) doesn't fetch all the info available by the API.

    For example, there is no attribute champion stats with ability haste, ability power, etc ...

    This is however available on Riot's API: image

    help wanted 
    opened by JasonMendoza2008 2
  • Type-hinting of Match.participants is wrong?

    Type-hinting of Match.participants is wrong?

    In the example file: https://github.com/meraki-analytics/cassiopeia/blob/master/examples/timeline.py, we do:

        summoner = Summoner(name=name, region=region)
    
        match_history = summoner.match_history
        match = match_history[0]
        p = match.participants[summoner]
    

    match.participants is supposed to be a List[Participant] (or a SearchableListmore precisely), but the type-checker detects an unexpected type when feeding a Summoner to it: image

    help wanted 
    opened by JasonMendoza2008 1
  • item undo bug

    item undo bug

    In match.py:

    The undo function is defined by the following script.

    def undo(self, event: Event): assert event.after_id == 0 or event.before_id == 0 item_id = event.before_id or event.after_id prev = None while prev is None or prev.item_id != item_id: prev = self._events.pop() if prev.type == "ITEM_PURCHASED": self.destroy(prev.item_id) elif prev.type == "ITEM_DESTROYED": self.add(prev.item_id) elif prev.type == "ITEM_SOLD": self.add(prev.item_id) else: raise TypeError(f"Unexpected event type {prev.type}")

    The event of synthetic an item is down by destroying the previous item first and then purchasing a new item. If an undo event happens to this item, the item will be destroyed directly. However, the correct undo of synthetic is disassembled this item.

    help wanted 
    opened by RogerLiu-Yuxuan 0
  • Pypi releases not reflected with git tags on the repo

    Pypi releases not reflected with git tags on the repo

    There is currently no new release on this repo since v4.0.5

    This doesn't really matter so to speak, but it's a bit confusing when looking at the releases on pypi where currently the latest release is 5.0.1

    Can it be possible to add the tags also in the repo, this way I can easily determine if a bug was fixed between latest release and master.

    help wanted 
    opened by UmBsublime 3
  • SimpleKVDiskStore causes match.load() to throw an exception

    SimpleKVDiskStore causes match.load() to throw an exception

    First I get the match history for a summoner. Then on the first match I get an exception when I call match.load():

    Traceback (most recent call last):
      File "C:\Users\Patrick\code\LeagueStats\lol.py", line 28, in <module>
        main(sys.argv)
      File "C:\Users\Patrick\code\LeagueStats\lol.py", line 24, in main
        command.run(argv[2:])
      File "C:\Users\Patrick\code\LeagueStats\lol\command.py", line 93, in run
        self._run_impl(argv)
      File "C:\Users\Patrick\code\LeagueStats\lol\commands\update_matches.py", line 43, in _run_impl
        match_data = match.load().to_dict()
      File "C:\Users\Patrick\AppData\Roaming\Python\Python39\site-packages\cassiopeia\core\common.py", line 226, in load
        self.__load__()
      File "C:\Users\Patrick\AppData\Roaming\Python\Python39\site-packages\cassiopeia\core\common.py", line 239, in __load__
        self.__load__(group)
      File "C:\Users\Patrick\AppData\Roaming\Python\Python39\site-packages\cassiopeia\core\common.py", line 246, in __load__
        data = configuration.settings.pipeline.get(type=self._load_types[load_group], query=query)
      File "C:\Users\Patrick\AppData\Roaming\Python\Python39\site-packages\datapipelines\pipelines.py", line 459, in get
        return handler.get(query, context)
      File "C:\Users\Patrick\AppData\Roaming\Python\Python39\site-packages\datapipelines\pipelines.py", line 185, in get
        result = self._source.get(self._source_type, deepcopy(query), context)
      File "C:\Users\Patrick\AppData\Roaming\Python\Python39\site-packages\datapipelines\sources.py", line 120, in get
        return source.get(type, deepcopy(query), context)
      File "C:\Users\Patrick\AppData\Roaming\Python\Python39\site-packages\datapipelines\sources.py", line 69, in wrapper
        return call(self, query, context=context)
      File "C:\Users\Patrick\AppData\Roaming\Python\Python39\site-packages\datapipelines\queries.py", line 325, in wrapped
        validator(query)
      File "C:\Users\Patrick\AppData\Roaming\Python\Python39\site-packages\datapipelines\queries.py", line 209, in __call__
        return self._root.evaluate(query, context)
      File "C:\Users\Patrick\AppData\Roaming\Python\Python39\site-packages\datapipelines\queries.py", line 60, in evaluate
        child.evaluate(query, context)
      File "C:\Users\Patrick\AppData\Roaming\Python\Python39\site-packages\datapipelines\queries.py", line 198, in evaluate
        self.child.evaluate(query, context)
      File "C:\Users\Patrick\AppData\Roaming\Python\Python39\site-packages\datapipelines\queries.py", line 173, in evaluate
        raise WrongValueTypeError("{key} must be of type {type} in query! Got {badtype}.".format(key=self.key, type=self, badtype=type(value)))
    ValueError: invalid literal for int() with base 10: 'NA1_4055198406'
    

    When I remove

        "SimpleKVDiskStore": {
          "package": "cassiopeia_diskstore",
          "path": "D:/Data/lol_cache"
        },
    

    from my settings. the call succeeds. I tried clearing my lol cache folder with no success.

    opened by PeteyPii 1
Releases(v5.0.3)
Owner
Meraki Analytics
Meraki Analytics
N-Queens game made using pygame library

N-Queens N-Queens game using pygame for AIML201 Testing: 1. git clone https://github.com/python-game-dev/N-Queens.git 2. cd N-Queens 3. python main.py

1 Sep 24, 2021
This is a python bot to automate BombCrypto game

This is a python bot to automate BombCrypto game. Logs in to the game, reconnects when needed, closes error warnings, sends heroes to work or home automatically, has Telegram integration and lets you

AFKAPP 39 Sep 28, 2022
Game-of-life - A simple python program to simulate and visualise the Conway's Game of life

Conway's game of life A simple python program to simulate and visualise the Conw

Dhravya Shah 3 Feb 20, 2022
🌍🍓 A better MCPi Launcher

Planet Launcher A better, maintained launcher for the Minecraft: Pi Edition Reborn mod. Report Bug | Request Feature Planet is a maintained, feature-r

15 Oct 19, 2022
Game using Python

🎡 Rock-Paper_Scissor Game Using Python Beginner Friendly Easy to use ♟ Want to Play this? Clone this repository Open in any IDE(for eg. VS Code, PyCh

Akash Kumar 1 Oct 17, 2021
Launch any Heroic-Games-Launcher game using bash scripts without having to open Heroic.

HeroicBashLauncher Ever wanted to launch your EGS games installed through Heroic Games Launcher directly from the terminal, Lutris or any other fronte

288 Dec 27, 2022
PyUnity is a Python implementation of the Unity Engine, written in C++

PyUnity is a Python implementation of the Unity Engine, written in C++. This is just a fun project and many features have been taken out to make it as easy as possible to create a scene and run it.

PyUnity 206 Jan 03, 2023
Solo CLF project about the creation of the FlickColor game in Python with very precise instructions.

Solo CLF project about the creation of the FlickColor game in Python with very precise instructions.

COZAX 1 Dec 09, 2022
Krieg is a Python package for a general game framework.

Krieg Krieg is a Python package for a general game framework. It provides base classes for implementing simple games. Some example games are already i

Juho Kim 2 Jan 06, 2022
Automates cubemap generation for Source Engine games.

AutoCube Automates cubemap generation for Source Engine games during compile-time. Download: see the release page Installation Using with CompilePal A

5 Feb 18, 2022
Snake - Code for "Deep Snake for Real-Time Instance Segmentation" CVPR 2020 oral

Good news! Snake algorithms exhibit state-of-the-art performances on COCO dataset: DANCE Deep Snake for Real-Time Instance Segmentation Deep Snake for

ZJU3DV 1.1k Dec 26, 2022
Minecraft clone using Python Ursina game engine!

Minecraft clone using Python Ursina game engine!

Taehee Lee 35 Jan 03, 2023
a simple keyboard game

Maxwell-Demon-Game Powered by Taichi. a simple keyboard game This is hw2 of Taichi course, as a basic exercise of class. Rigid 2d bodies and resolve c

8 Feb 01, 2022
A popular children's game developed in Python.

Pedra Papel e Tesoura Um dos jogos mais populares da infância... 🪨 📜 ✂️ 💻 Situação do projeto: Projeto finalizado ✔️ 🛠 Tecnologias: Python Tkinter

Arthur V.B.S. 2 Dec 05, 2022
BUG OUTBREAK is a game of adventure and shooting.

BUG OUTBREAK BUG OUTBREAK is a game of adventure and shooting. I am building the game for Github Game Off 2021. This game has 5 levels. You have to co

Shreejan Dolai 3 Nov 11, 2022
Brawl Stars private server for version 30.242

Brawl Stars v30 Brawl Stars v30.242 server emulator written in Python. Requirements: Python 3.7 or higher pymongo dnspython colorama Running the serve

15 Oct 17, 2021
A use of the python MCPI to enhance the multiplayer and singleplayer gameplay.

Morpheus 2.0 A use of the python MCPI to enhance the multiplayer and singleplayer gameplay. To Use: You will need to install the keyboard, pysimplegui

11 Oct 11, 2022
Games: Create interesting games by pure python.

Create interesting games by pure python.

4.2k Jan 06, 2023
2DMC is an abrrieviation for 2 Dimensional Minecraft.

2DMC 2DMC is an abrrieviation for 2 Dimensional Minecraft. This idea is originally created and implemented by Griffpatch on Scratch. This is a persona

DaNub 5 Nov 06, 2022
Simple car game written in PyGame

Welcome to CarGame 👋 Car Game written in PyGame! NOTE: This is still new and there may be stuff broken... 🏠 Homepage Install install pygame by typin

John 1 Oct 29, 2021