battlebit-api 0.0.2

Last updated:

0 purchases

battlebit-api 0.0.2 Image
battlebit-api 0.0.2 Images
Add to Cart

Description:

battlebitapi 0.0.2

BattleBit API
An abstraction layer for the BattleBit Public API that delivers a convenient data model
>>> from battlebit_api.BattleBitApiClient import BattleBitApiClient
>>> battle_bit_api_client = BattleBitApiClient()
>>> battle_bit_api_client.get_server_list().servers
[
Server(
name='172-Z-00',
map=Map(name='Isle', size='Medium'),
game_mode=<GameMode.DOMINATION: 1>,
region=<Region.JAPAN_CENTRAL: 4>,
current_players=64,
max_players=64,
players_in_queue=0,
hz=60,
is_day_mode=True,
is_official=True,
has_password=False,
anti_cheat=<AntiCheatProvider.EAC: 1>,
server_version='Production 2.0.2'
), ...
]

Quick Guide
At the top level of each interaction with the BattleBit Public API is the BattleBitApiClient. After creating an instance of this class, all available API methods can be called from there.
See documentation for in depth information.
Documentation
As the BattleBit API grows, so will this documentation. In the future it will be found in the repository.

BattleBitApiClient

BattleBitApiClientException
BattleBitApiRateLimitExceeded
BattleBitApiClient

__init__
get_server_list




ServerList

ServerList

update
search_for_server_by_name
filter_servers
get_servers_sorted_by_current_players






BattleBitApiClient

BattleBitApiClientException Objects
class BattleBitApiClientException(Exception)

Thrown for unexpected exceptions.
Note: If you encounter this, please send an error report to this packages' maintainer.

BattleBitApiRateLimitExceeded Objects
class BattleBitApiRateLimitExceeded(Exception)

Thrown if the rate limit for the BattleBit API is reached

BattleBitApiClient Objects
class BattleBitApiClient()

Entrypoint class for the package. Obtain an instance of this class to make API calls.

__init__
def __init__(root_endpoint: str = "https://publicapi.battlebit.cloud") -> None

Arguments:

root_endpoint: Endpoint URL to the BattleBit API, should point to the correct one by default.


get_server_list
def get_server_list(with_update: bool = True) -> ServerList

Returns a ServerList object. This does only pull from the BattleBit API if the server list has never
been polled, or if forced to by the with_update switch.
Arguments:

with_update: If True, this method will get data from the API, if not it will return the cached ServerList.

Returns:
A ServerList object

ServerList

ServerList Objects
class ServerList()


update
def update(servers: list[Server]) -> None

Updates the ServerList with a new set of Servers. Updates the last_updated property to the current timestamp.
Arguments:

servers: List of Server objects.

Returns:
None

search_for_server_by_name
def search_for_server_by_name(search_str: str) -> list[Server]

Returns all Servers in which the string search_str appears as a substring in the Servers name.
This is case sensitive.
Arguments:

search_str: Substring to search for in Server names

Returns:
All Servers in which the string search_str appears as a substring in the Servers name.

filter_servers
def filter_servers(server_filter: ServerFilter) -> Self

Returns a new ServerList that only contains Servers that match the ServerFilter.
ServerFilter properties that are set to None are ignored.
Arguments:

server_filter: ServerFilter object

Returns:
ServerList that only contains Servers that match the ServerFilter

get_servers_sorted_by_current_players
def get_servers_sorted_by_current_players(
many_to_few: bool = True) -> list[Server]

Returns a list of all Servers in the ServerList, sorted by the amount of current players on it.
Arguments:

many_to_few: Used to control if the list is ascending (False) or descending (True)

Returns:
List of all Servers in the ServerList, sorted by the amount of current players on it.
Examples
See examples in the project repository.
Data Classes
For information about the classes that hold the server data and provide no other functionality, refer to the source code or use your IDE features.
Regarding completeness
As of the time of this writing, the BattleBit Public API is still heavily under development. This package aims at being resilient towards changes, but can not guarantee that it will always be up to date with the API.

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Customer Reviews

There are no reviews.