Package: pychasing
A full-functionality wrapper for thehttps://ballchasing.comAPI.Install$ pip install pychasingThe pychasing ClientThepychasing.Clientclass is the main object used to interact with the Ballchasing API.importpychasingpychasing_client=pychasing.Client(token="your_token",auto_rate_limit=True,patreon_tier=pychasing.PatreonTier.none# same as "regular")Before we get into the methods ofClient, there are a few things to note about rate limit handling. Ifauto_rate_limitis set toFalse, any request you make will be immediately sent to the ballchasing API. Ifauto_rate_limitis set toTrue, the client will automatically limit the rate of your requests, taking into account both hourly quota and burst limit. This is done throughtime.sleep, so how long it takes to get a response from a given method will depend on how often you are using the API, as well as your Ballchasing Patreon tier. Additionally, there is arate_limit_safe_startoption; if this option is set toTrue, the rate limiting will start off as already maxed out on API calls. This prevents any issues from arising if you are reinstantiating the client often (e.g. if you are testing by running a script multiple times). If this option is set toFalse, the rate limiter will assume that you haven't made any API calls in the past hour, and will rate limit accordingly. For long-running programs and use a single client instance, this option isn't necessarily needed, but I would always recommend it be enabled.Thepychasing.Clientobject has the below methods:ping- pings the ballchasing servers.upload_replay- uploads a replay to the token-holder's account.NOTE: this takes aBinaryIOobject. For example:withopen("my_replay.replay","rb")asreplay_file:...upload_replay(replay_file,...)list_replays- list replays (basic information only) filtered on various criteria.get_replay- get the in-depth information of a specific replay.delete_replay- delete a specific replay, so long as it is owned by the token-holder.NOTE: this operation ispermenantand cannot be undone.patch_replay- edit thetitle,visibilityor parentgroupof a specific replay.download_replay- download the raw bytes of a specific replay, so long as it is not private (unless it is owned by the token-holder).NOTE: since replays are relatively large, they should be downloaded in chunks. For example:with...download_replay(...)asdata_stream:withopen("my_replay.replay","wb")asreplay_file:forchunkindata_stream.iter_content(chunk_size=4096):replay_file.write(chunk)create_group- create a replay group.list_groups- list groups (basic information only) filtered on various criteria.get_group- get in-depth information of a specific replay group.delete_group- delete a specific group, so long as it is owned by the token-holder.NOTE: this operation ispermenantand cannot be undone.patch_group- edit theplayer-identification,team-identification,parent, orsharedstatus of a specific replay group, so long as it owned by the token-holder.maps- list all the maps in the game.get_threejs- get basic locational data (among other data) of a specific replay. This does not requireNOTE: this functionality is highly experimental. It accesses a back-end API used for populating site data (that notably does not require authorization headers). At any time, this API could become restricted or its functionality could change.get_timeline- get basic timeline data of a specific replay.NOTE: this functionality is highly experimental. It accesses a back-end API used for populating site data (that notably does not require authorization headers). At any time, this API could become restricted or its functionality could change.export_csv- get group statistics formatted as semi-colon-separated values.Enums and other typesMany of the methods inClientcan use custom enumerations for ease of use. For example, when setting the visibility of a replay throughClient.patch_replay, you could setvisibilityto"unlisted"orVisibility.unlisted. These Enums are listed below:pychasing.Rank- used formin_rankandmax_rankinlist_replayspychasing.Playlist- used forplaylistsinlist_replayspychasing.Platform- used forplatforminlist_replayspychasing.Map- used formapinlist_replayspychasing.Visibility- used forvisibilityinpatch_replayandpatch_grouppychasing.PlayerIdentifiercation- used forplayer_identificationincreate_groupandpatch_grouppychasing.TeamIdentification- used forteam_identificationincreate_groupandpatch_grouppychasing.MatchResult- used formatch_resultinlist_replayspychasing.ReplaySortBy- used forsort_byinlist_replayspychasing.GroupSortBy- used forsort_byinlist_groupspychasing.SortDirection- used forsort_dirinlist_replaysandlist_groupspychasing.GroupStats- used forstatinexport_csvpychasing.PatreonTier- used in the initialization ofClient. This is the only exception to the aforementioned "str or enum" rule above; the proper initialization ofClientrequiresthePatreonTierenum.Additionally, all date parameters (which require an RFC3339 formatted datetime) also accept apychasing.Date. For example:...list_replays(created_before="2022-11-22T05:00:30Z")...list_replays(created_before=pychasing.Date(2022,11,22,5,0,30))