infinitode.py


Nameinfinitode.py JSON
Version 1.1.2 PyPI version JSON
download
home_pagehttps://github.com/Sprylos/infinitode.py
SummaryA python wrapper for the Infinitode 2 API.
upload_time2024-08-24 20:05:53
maintainerNone
docs_urlNone
authorSprylos
requires_pythonNone
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Infinitode.py

An asynchronous python wrapper for the Infinitode-2 API using `async`-`await` syntax.

## Installing

---

Installing via pip:

```
pip install infinitode.py
```

## Showcase

---

```python
import asyncio
import infinitode


async def main():
    # Creates a session to communicate with Rainy's API.
    # The with statement assures that the underlying session is closed.
    # Alternatively you can can simply call Session.close() once you don't need it anymore.
    async with infinitode.Session() as API:

        # The mapname parameter should be in the form presented in the game (ie 5.1).
        # The mode param (score/waves) defaults to score.
        # The difficulty param (EASY/NORMAL/ENDLESS_I) which defaults to NORMAL can also be specified,
        # however easy leaderboards/scores are always empty.
        # Sometimes a playerid can or must be specified,
        # and the result will have additional info about that players' score.

        # This returns a score of a specific player with the id U-E9BP-FSN9-H6ENMQ on the map 5.1 in normal mode.
        # The parameters mapname and playerid are required, mode and difficulty are optional.
        score_5_1 = await API.leaderboards_rank(mapname='5.1', playerid='U-E9BP-FSN9-H6ENMQ', mode='score', difficulty='NORMAL')

        # This returns a leaderboard of the top 200 wave scores on 5.1 in normal mode.
        # Only the mapname is required.
        # mapname can also be a float
        leaderboard_5_1 = await API.leaderboards(mapname=5.1, playerid=None, mode='waves')

        # The runtime leaderboard is the one displayed in the top right when playing a run.
        # It is similar to leaderboards, however it will also give the top 1-99% each.
        # Mapname and playerid are required.
        runtime_5_1 = await API.runtime_leaderboards(mapname=5.1, playerid='U-E9BP-FSN9-H6ENMQ', difficulty='ENDLESS_I')

        # Top 3 skill point owners, a playerid can be specified for the score of that player.
        sp_leaderboard = await API.skill_point_leaderboard(playerid='U-E9BP-FSN9-H6ENMQ')

        # Top 200 players of todays dailyquest or the one which date is specified.
        # The date should be a str in the YYYY-MM-DD format, or a datetime.datetime object.
        # However the server seems to only save the last 2 or 3 days.
        # Again, a playerid can be specified.
        dq_leaderboard = await API.daily_quest_leaderboards()

        # This returns the top 100 players from the season leaderboard.
        # There is no convenient api response for this call.
        # Instead the data is parsed, which is why this can take a bit.
        # This function never takes parameters.
        season_leaderboard = await API.seasonal_leaderboard()

        # This will return a Player with a lot of attributes.
        # Like the season leaderboard, the data has to be parsed.
        # This function always takes a playerid and nothing else.
        player = await API.player('U-E9BP-FSN9-H6ENMQ')

        # All Leaderboards and Scores have the method, mapname, mode, difficulty attribute:
        print(score_5_1.method, score_5_1.mapname,
              runtime_5_1.mode, runtime_5_1.difficulty)
        # All leaderboards have a total attribute:
        print(leaderboard_5_1.total)

        # They also have an optional player, date and season attribute
        print(dq_leaderboard.date)
        print(season_leaderboard.season)

        # The player attribute will return a Score
        sp_score = sp_leaderboard.player
        assert sp_score is not None  # check if the score exists.

        # Scores also always have a playerid, rank and score attribute:
        print(score_5_1.playerid, score_5_1.rank, score_5_1.score)

        # There is also a variety of optional attributes:
        # has_pfp, level, nickname, pinned_badge, position, top, total, player

        # Every Leaderboard contains a certain amount of scores, with a maxmimum of 300.
        # The best way to retrieve the scores is usually iterating through the leaderboard.
        # for score in leaderboard_5_1:
        #     print(score.nickname)  # do something with score

        # You can also index a single score:
        leaderboard_5_1[35].print_score()
        # or index with a slice to receive a shortened leaderboard:
        print(len(leaderboard_5_1[0:10]))

        # The last main object is a Player, received only be Session.player()
        # Every Player has the same attributes.
        print(
            player.playerid,
            player.nickname,
            player.level,
            player.xp,
            player.xp_max,  # xp required per level
            player.season_level,
            player.season_xp,
            player.season_xp_max,
            player.total_score,
            player.total_rank,
            player.total_top,
            player.replays,
            player.issues,
            player.created_at,  # as str
            player.avatar_link  # even when the person has no pfp
        )

        # Every player also has a .score() method. It will return the players score for the given level.
        player.score('5.1').print_score()

        # You can also get the DQ and SP scores with additional API calls:
        (await player.daily_quest(API)).rank
        (await player.skill_point(API)).rank

# In case you get a runtime error here, ignore it, that's Windows' shit.
asyncio.run(main())
```

## Logging

---

```python
import infinitode
import asyncio
import logging

# setup logger
# INFO will log everytime a request is made
# DEBUG will log the server's response aswell
logging.basicConfig(level=logging.INFO)


async def main():
    async with infinitode.Session() as API:
        await API.leaderboards('6.3')  # just an example

asyncio.run(main())
```



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/Sprylos/infinitode.py",
    "name": "infinitode.py",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": null,
    "author": "Sprylos",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/a2/dd/7d6814661ba281ed5eb31580bb9d289fde8fc97ee4a3c9f1fe71406aa601/infinitode.py-1.1.2.tar.gz",
    "platform": null,
    "description": "# Infinitode.py\r\n\r\nAn asynchronous python wrapper for the Infinitode-2 API using `async`-`await` syntax.\r\n\r\n## Installing\r\n\r\n---\r\n\r\nInstalling via pip:\r\n\r\n```\r\npip install infinitode.py\r\n```\r\n\r\n## Showcase\r\n\r\n---\r\n\r\n```python\r\nimport asyncio\r\nimport infinitode\r\n\r\n\r\nasync def main():\r\n    # Creates a session to communicate with Rainy's API.\r\n    # The with statement assures that the underlying session is closed.\r\n    # Alternatively you can can simply call Session.close() once you don't need it anymore.\r\n    async with infinitode.Session() as API:\r\n\r\n        # The mapname parameter should be in the form presented in the game (ie 5.1).\r\n        # The mode param (score/waves) defaults to score.\r\n        # The difficulty param (EASY/NORMAL/ENDLESS_I) which defaults to NORMAL can also be specified,\r\n        # however easy leaderboards/scores are always empty.\r\n        # Sometimes a playerid can or must be specified,\r\n        # and the result will have additional info about that players' score.\r\n\r\n        # This returns a score of a specific player with the id U-E9BP-FSN9-H6ENMQ on the map 5.1 in normal mode.\r\n        # The parameters mapname and playerid are required, mode and difficulty are optional.\r\n        score_5_1 = await API.leaderboards_rank(mapname='5.1', playerid='U-E9BP-FSN9-H6ENMQ', mode='score', difficulty='NORMAL')\r\n\r\n        # This returns a leaderboard of the top 200 wave scores on 5.1 in normal mode.\r\n        # Only the mapname is required.\r\n        # mapname can also be a float\r\n        leaderboard_5_1 = await API.leaderboards(mapname=5.1, playerid=None, mode='waves')\r\n\r\n        # The runtime leaderboard is the one displayed in the top right when playing a run.\r\n        # It is similar to leaderboards, however it will also give the top 1-99% each.\r\n        # Mapname and playerid are required.\r\n        runtime_5_1 = await API.runtime_leaderboards(mapname=5.1, playerid='U-E9BP-FSN9-H6ENMQ', difficulty='ENDLESS_I')\r\n\r\n        # Top 3 skill point owners, a playerid can be specified for the score of that player.\r\n        sp_leaderboard = await API.skill_point_leaderboard(playerid='U-E9BP-FSN9-H6ENMQ')\r\n\r\n        # Top 200 players of todays dailyquest or the one which date is specified.\r\n        # The date should be a str in the YYYY-MM-DD format, or a datetime.datetime object.\r\n        # However the server seems to only save the last 2 or 3 days.\r\n        # Again, a playerid can be specified.\r\n        dq_leaderboard = await API.daily_quest_leaderboards()\r\n\r\n        # This returns the top 100 players from the season leaderboard.\r\n        # There is no convenient api response for this call.\r\n        # Instead the data is parsed, which is why this can take a bit.\r\n        # This function never takes parameters.\r\n        season_leaderboard = await API.seasonal_leaderboard()\r\n\r\n        # This will return a Player with a lot of attributes.\r\n        # Like the season leaderboard, the data has to be parsed.\r\n        # This function always takes a playerid and nothing else.\r\n        player = await API.player('U-E9BP-FSN9-H6ENMQ')\r\n\r\n        # All Leaderboards and Scores have the method, mapname, mode, difficulty attribute:\r\n        print(score_5_1.method, score_5_1.mapname,\r\n              runtime_5_1.mode, runtime_5_1.difficulty)\r\n        # All leaderboards have a total attribute:\r\n        print(leaderboard_5_1.total)\r\n\r\n        # They also have an optional player, date and season attribute\r\n        print(dq_leaderboard.date)\r\n        print(season_leaderboard.season)\r\n\r\n        # The player attribute will return a Score\r\n        sp_score = sp_leaderboard.player\r\n        assert sp_score is not None  # check if the score exists.\r\n\r\n        # Scores also always have a playerid, rank and score attribute:\r\n        print(score_5_1.playerid, score_5_1.rank, score_5_1.score)\r\n\r\n        # There is also a variety of optional attributes:\r\n        # has_pfp, level, nickname, pinned_badge, position, top, total, player\r\n\r\n        # Every Leaderboard contains a certain amount of scores, with a maxmimum of 300.\r\n        # The best way to retrieve the scores is usually iterating through the leaderboard.\r\n        # for score in leaderboard_5_1:\r\n        #     print(score.nickname)  # do something with score\r\n\r\n        # You can also index a single score:\r\n        leaderboard_5_1[35].print_score()\r\n        # or index with a slice to receive a shortened leaderboard:\r\n        print(len(leaderboard_5_1[0:10]))\r\n\r\n        # The last main object is a Player, received only be Session.player()\r\n        # Every Player has the same attributes.\r\n        print(\r\n            player.playerid,\r\n            player.nickname,\r\n            player.level,\r\n            player.xp,\r\n            player.xp_max,  # xp required per level\r\n            player.season_level,\r\n            player.season_xp,\r\n            player.season_xp_max,\r\n            player.total_score,\r\n            player.total_rank,\r\n            player.total_top,\r\n            player.replays,\r\n            player.issues,\r\n            player.created_at,  # as str\r\n            player.avatar_link  # even when the person has no pfp\r\n        )\r\n\r\n        # Every player also has a .score() method. It will return the players score for the given level.\r\n        player.score('5.1').print_score()\r\n\r\n        # You can also get the DQ and SP scores with additional API calls:\r\n        (await player.daily_quest(API)).rank\r\n        (await player.skill_point(API)).rank\r\n\r\n# In case you get a runtime error here, ignore it, that's Windows' shit.\r\nasyncio.run(main())\r\n```\r\n\r\n## Logging\r\n\r\n---\r\n\r\n```python\r\nimport infinitode\r\nimport asyncio\r\nimport logging\r\n\r\n# setup logger\r\n# INFO will log everytime a request is made\r\n# DEBUG will log the server's response aswell\r\nlogging.basicConfig(level=logging.INFO)\r\n\r\n\r\nasync def main():\r\n    async with infinitode.Session() as API:\r\n        await API.leaderboards('6.3')  # just an example\r\n\r\nasyncio.run(main())\r\n```\r\n\r\n\r\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A python wrapper for the Infinitode 2 API.",
    "version": "1.1.2",
    "project_urls": {
        "Homepage": "https://github.com/Sprylos/infinitode.py"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "68d8d722bf46ffdcd94055d00c252f3c6d2c8da535582986fb942ceca1ad5a52",
                "md5": "fc98857638cde3cdb9d2f22c67947f41",
                "sha256": "237795eee070ab4dc858b657acef991429b5130d2bb0a3446c83e1df1df836ad"
            },
            "downloads": -1,
            "filename": "infinitode.py-1.1.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "fc98857638cde3cdb9d2f22c67947f41",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 16568,
            "upload_time": "2024-08-24T20:05:49",
            "upload_time_iso_8601": "2024-08-24T20:05:49.598424Z",
            "url": "https://files.pythonhosted.org/packages/68/d8/d722bf46ffdcd94055d00c252f3c6d2c8da535582986fb942ceca1ad5a52/infinitode.py-1.1.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a2dd7d6814661ba281ed5eb31580bb9d289fde8fc97ee4a3c9f1fe71406aa601",
                "md5": "0f9bb1e0645b18546da74153748a14e0",
                "sha256": "afe321c567dd4129d0b7e77e59233e1428708b2b15921944e371642387c7964d"
            },
            "downloads": -1,
            "filename": "infinitode.py-1.1.2.tar.gz",
            "has_sig": false,
            "md5_digest": "0f9bb1e0645b18546da74153748a14e0",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 15464,
            "upload_time": "2024-08-24T20:05:53",
            "upload_time_iso_8601": "2024-08-24T20:05:53.154901Z",
            "url": "https://files.pythonhosted.org/packages/a2/dd/7d6814661ba281ed5eb31580bb9d289fde8fc97ee4a3c9f1fe71406aa601/infinitode.py-1.1.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-08-24 20:05:53",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Sprylos",
    "github_project": "infinitode.py",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [],
    "lcname": "infinitode.py"
}
        
Elapsed time: 0.32241s