pantheon


Namepantheon JSON
Version 2.0.0 PyPI version JSON
download
home_pagehttps://github.com/Canisback/pantheon
SummaryRiot API library for Python and asyncio
upload_time2022-02-24 15:30:17
maintainer
docs_urlNone
authorCanisback
requires_python
license
keywords riot api python
VCS
bugtrack_url
requirements aiohttp certifi
Travis-CI
coveralls test coverage No coveralls.
            # Pantheon

[![PyPi](https://img.shields.io/pypi/v/pantheon)](https://pypi.org/project/pantheon/)
[![Build Status](https://travis-ci.com/Canisback/pantheon.svg?branch=master)](https://travis-ci.com/Canisback/pantheon)
[![codecov](https://codecov.io/gh/Canisback/pantheon/branch/master/graph/badge.svg)](https://codecov.io/gh/Canisback/pantheon)
[![Language grade: Python](https://img.shields.io/lgtm/grade/python/g/Canisback/pantheon.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/Canisback/pantheon/context:python)
[![Downloads](https://pepy.tech/badge/pantheon)](https://pepy.tech/project/pantheon)

Simple library to use the Riot API with Python Asyncio.

Supports all endpoints.

It has an efficient rate limiting system as well as an error handler that automatically resend request when needed.

**There is no cache implemented**

**The rate limit count is only kept while the script is alive**

Currently supported requests : 
 * champion masteries by summonerId -> getChampionMasteries(summonerId)
 * champion masteries by summonerId and championId -> getChampionMasteriesByChampionId(summonerId,championId)
 * champion masteries score by summonerId -> getChampionMasteriesScore(summonerId)
 * champion rotations -> getChampionRotations()
 * league by leagueId -> getLeagueById(leagueId)
 * league pages by queue, rank and tier -> getLeaguePage(queue, tier, division, page=1)
 * league position by summonerId -> getLeaguePosition(summonerId)
 * challenger league by queue (optional) -> getChallengerLeague(queue)
 * lol status -> getStatus()
 * master league by queue (optional) -> getMasterLeague(queue)
 * match by matchId -> getMatch(matchId)
 * match timeline by matchId -> getTimeline(matchId)
 * matchlist by accountId (with parameters) -> getMatchlist(self, accountId, params) / params={"queue":420,"season":11}
 * current game by summonerId -> getCurrentGame(summonerId)
 * summoner by summonerId -> getSummoner(summonerId)
 * summoner by accountId -> getSummonerByAccountId(accountId)
 * summoner by name -> getSummonerByName(name)
 * third party code by summonerId -> getThirdPartyCode(summonerId)
 * register provider -> registerProvider(region, callback_url, stub=False)
 * register tournament -> registerTournament(providerId, name, stub=False)
 * create tournament code -> createTournamentCode(tournamentId, data, nb_codes=1, stub=False)
 * get lobby events by tournament code -> getLobbyEvents(tournamentCode, stub=False)

Further requests supported and documentation (hopefully) incoming

To install, run
```
pip install pantheon
or
pip3 install pantheon
```

or you can download it and run 

```
python setup.py install
or
python3 setup.py install
```

An example of usage to get details on the last 10 games : 

```python
from pantheon import pantheon
import asyncio

server = "euw1"
api_key = "RGAPI-XXXX"

def requestsLog(url, status, headers):
    print(url)
    print(status)
    print(headers)

panth = pantheon.Pantheon(server, api_key, errorHandling=True, requestsLoggingFunction=requestsLog, debug=True)

async def getSummonerId(name):
    try:
        data = await panth.getSummonerByName(name)
        return (data['id'],data['accountId'])
    except Exception as e:
        print(e)


async def getRecentMatchlist(accountId):
    try:
        data = await panth.getMatchlist(accountId, params={"endIndex":10})
        return data
    except Exception as e:
        print(e)

async def getRecentMatches(accountId):
    try:
        matchlist = await getRecentMatchlist(accountId)
        tasks = [panth.getMatch(match['gameId']) for match in matchlist['matches']]
        return await asyncio.gather(*tasks)
    except Exception as e:
        print(e)


name = "Canisback"

loop = asyncio.get_event_loop()  

(summonerId, accountId) = loop.run_until_complete(getSummonerId(name))
print(summonerId)
print(accountId)
print(loop.run_until_complete(getRecentMatches(accountId)))
```


**Changelog :**

 * 1.3.1 : 
     * Add a locked function to check if at least one limiter is locked

 * 1.3.0 : 
     * Add custom str function for pantheon that returns the rate limits details
     * Fixed a rate limit bug not counting a request when creating a new limit

 * 1.2.1 : 
     * Add Tournament matches endpoints

 * 1.2.0 : 
     * Add LoR match and matchlist
     * Update deprecated lock handling

 * 1.1.0 : 
     * Add support for LoR and Valorant
     * Deleting auto-handling server to region for TFT matches and LoL tournaments endpoints, will break apps using these endpoint without creating another instance of Pantheon with the correct server
     
 * 1.0.12 : 
     * Add support for Clash API

 * 1.0.9 : 
     * Clean up some code
     
 * 1.0.8 : 
     * Clean up some code and upgrading for CI

 * 1.0.7 : 
     * Added TFT API endpoints
     * Added unit tests covering almost all endpoints, rate limiter not unit tested yet

 * 1.0.6 : 
     * Fixed 415 errors

 * 1.0.5 : 
     * Updated League endpoints to match with current version
     * Added tournament endpoints (stub ones)
     
 * 1.0.4 : 
     * Added 408 error code
     
 * 1.0.3 : 
     * Updated for v4 endpoints

 * 1.0.2 : 
     * Added new getChampionRotations endpoint support
     * Deleted getChampions and getChampionsById due to deprecation of corresponding endpoints
     * Fixed the getTimestamp function for the case when the Date header is missing

 * 1.0.1 : 
     * Added a debug flag, while set at True, some messages will be printed, when the rate limiter make a request waiting because limit is reached, or when retrying after an error.
     * Added callback function for logging purpose.
     * Changed error 429 handling (rate limit) so it retries after the value sent in header
     * Added support for list in matchlist params (you can pass {"queue":[420,440]}



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/Canisback/pantheon",
    "name": "pantheon",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "Riot API,python",
    "author": "Canisback",
    "author_email": "canisback@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/1d/bb/846a1b636ac45d5b5a6a94f810e89a169b8559ec79deed12c12d02396671/pantheon-2.0.0.tar.gz",
    "platform": "",
    "description": "# Pantheon\n\n[![PyPi](https://img.shields.io/pypi/v/pantheon)](https://pypi.org/project/pantheon/)\n[![Build Status](https://travis-ci.com/Canisback/pantheon.svg?branch=master)](https://travis-ci.com/Canisback/pantheon)\n[![codecov](https://codecov.io/gh/Canisback/pantheon/branch/master/graph/badge.svg)](https://codecov.io/gh/Canisback/pantheon)\n[![Language grade: Python](https://img.shields.io/lgtm/grade/python/g/Canisback/pantheon.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/Canisback/pantheon/context:python)\n[![Downloads](https://pepy.tech/badge/pantheon)](https://pepy.tech/project/pantheon)\n\nSimple library to use the Riot API with Python Asyncio.\n\nSupports all endpoints.\n\nIt has an efficient rate limiting system as well as an error handler that automatically resend request when needed.\n\n**There is no cache implemented**\n\n**The rate limit count is only kept while the script is alive**\n\nCurrently supported requests : \n * champion masteries by summonerId -> getChampionMasteries(summonerId)\n * champion masteries by summonerId and championId -> getChampionMasteriesByChampionId(summonerId,championId)\n * champion masteries score by summonerId -> getChampionMasteriesScore(summonerId)\n * champion rotations -> getChampionRotations()\n * league by leagueId -> getLeagueById(leagueId)\n * league pages by queue, rank and tier -> getLeaguePage(queue, tier, division, page=1)\n * league position by summonerId -> getLeaguePosition(summonerId)\n * challenger league by queue (optional) -> getChallengerLeague(queue)\n * lol status -> getStatus()\n * master league by queue (optional) -> getMasterLeague(queue)\n * match by matchId -> getMatch(matchId)\n * match timeline by matchId -> getTimeline(matchId)\n * matchlist by accountId (with parameters) -> getMatchlist(self, accountId, params) / params={\"queue\":420,\"season\":11}\n * current game by summonerId -> getCurrentGame(summonerId)\n * summoner by summonerId -> getSummoner(summonerId)\n * summoner by accountId -> getSummonerByAccountId(accountId)\n * summoner by name -> getSummonerByName(name)\n * third party code by summonerId -> getThirdPartyCode(summonerId)\n * register provider -> registerProvider(region, callback_url, stub=False)\n * register tournament -> registerTournament(providerId, name, stub=False)\n * create tournament code -> createTournamentCode(tournamentId, data, nb_codes=1, stub=False)\n * get lobby events by tournament code -> getLobbyEvents(tournamentCode, stub=False)\n\nFurther requests supported and documentation (hopefully) incoming\n\nTo install, run\n```\npip install pantheon\nor\npip3 install pantheon\n```\n\nor you can download it and run \n\n```\npython setup.py install\nor\npython3 setup.py install\n```\n\nAn example of usage to get details on the last 10 games : \n\n```python\nfrom pantheon import pantheon\nimport asyncio\n\nserver = \"euw1\"\napi_key = \"RGAPI-XXXX\"\n\ndef requestsLog(url, status, headers):\n    print(url)\n    print(status)\n    print(headers)\n\npanth = pantheon.Pantheon(server, api_key, errorHandling=True, requestsLoggingFunction=requestsLog, debug=True)\n\nasync def getSummonerId(name):\n    try:\n        data = await panth.getSummonerByName(name)\n        return (data['id'],data['accountId'])\n    except Exception as e:\n        print(e)\n\n\nasync def getRecentMatchlist(accountId):\n    try:\n        data = await panth.getMatchlist(accountId, params={\"endIndex\":10})\n        return data\n    except Exception as e:\n        print(e)\n\nasync def getRecentMatches(accountId):\n    try:\n        matchlist = await getRecentMatchlist(accountId)\n        tasks = [panth.getMatch(match['gameId']) for match in matchlist['matches']]\n        return await asyncio.gather(*tasks)\n    except Exception as e:\n        print(e)\n\n\nname = \"Canisback\"\n\nloop = asyncio.get_event_loop()  \n\n(summonerId, accountId) = loop.run_until_complete(getSummonerId(name))\nprint(summonerId)\nprint(accountId)\nprint(loop.run_until_complete(getRecentMatches(accountId)))\n```\n\n\n**Changelog :**\n\n * 1.3.1 : \n     * Add a locked function to check if at least one limiter is locked\n\n * 1.3.0 : \n     * Add custom str function for pantheon that returns the rate limits details\n     * Fixed a rate limit bug not counting a request when creating a new limit\n\n * 1.2.1 : \n     * Add Tournament matches endpoints\n\n * 1.2.0 : \n     * Add LoR match and matchlist\n     * Update deprecated lock handling\n\n * 1.1.0 : \n     * Add support for LoR and Valorant\n     * Deleting auto-handling server to region for TFT matches and LoL tournaments endpoints, will break apps using these endpoint without creating another instance of Pantheon with the correct server\n     \n * 1.0.12 : \n     * Add support for Clash API\n\n * 1.0.9 : \n     * Clean up some code\n     \n * 1.0.8 : \n     * Clean up some code and upgrading for CI\n\n * 1.0.7 : \n     * Added TFT API endpoints\n     * Added unit tests covering almost all endpoints, rate limiter not unit tested yet\n\n * 1.0.6 : \n     * Fixed 415 errors\n\n * 1.0.5 : \n     * Updated League endpoints to match with current version\n     * Added tournament endpoints (stub ones)\n     \n * 1.0.4 : \n     * Added 408 error code\n     \n * 1.0.3 : \n     * Updated for v4 endpoints\n\n * 1.0.2 : \n     * Added new getChampionRotations endpoint support\n     * Deleted getChampions and getChampionsById due to deprecation of corresponding endpoints\n     * Fixed the getTimestamp function for the case when the Date header is missing\n\n * 1.0.1 : \n     * Added a debug flag, while set at True, some messages will be printed, when the rate limiter make a request waiting because limit is reached, or when retrying after an error.\n     * Added callback function for logging purpose.\n     * Changed error 429 handling (rate limit) so it retries after the value sent in header\n     * Added support for list in matchlist params (you can pass {\"queue\":[420,440]}\n\n\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Riot API library for Python and asyncio",
    "version": "2.0.0",
    "split_keywords": [
        "riot api",
        "python"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "de3f3b0c648504de83d86d581f636fa7",
                "sha256": "173bed8431c705879845825d406872d5162bb825f31af1042a403a25660e91ed"
            },
            "downloads": -1,
            "filename": "pantheon-2.0.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "de3f3b0c648504de83d86d581f636fa7",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 22792,
            "upload_time": "2022-02-24T15:30:15",
            "upload_time_iso_8601": "2022-02-24T15:30:15.689714Z",
            "url": "https://files.pythonhosted.org/packages/2e/5e/67b60a57a7ad223e3970f88cc0cab31fc9f00ce531884b76a125a68812b4/pantheon-2.0.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "md5": "b545f6061a5061fc89a815f1128a9157",
                "sha256": "09e2ccb3cc54d968685a871f3ce5bb78e8b0d10e740238f3aaafa1e39c431715"
            },
            "downloads": -1,
            "filename": "pantheon-2.0.0.tar.gz",
            "has_sig": false,
            "md5_digest": "b545f6061a5061fc89a815f1128a9157",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 18347,
            "upload_time": "2022-02-24T15:30:17",
            "upload_time_iso_8601": "2022-02-24T15:30:17.350880Z",
            "url": "https://files.pythonhosted.org/packages/1d/bb/846a1b636ac45d5b5a6a94f810e89a169b8559ec79deed12c12d02396671/pantheon-2.0.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2022-02-24 15:30:17",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "Canisback",
    "github_project": "pantheon",
    "travis_ci": true,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "aiohttp",
            "specs": []
        },
        {
            "name": "certifi",
            "specs": []
        }
    ],
    "tox": true,
    "lcname": "pantheon"
}
        
Elapsed time: 0.05516s