Skip to main content

An abstraction layer for the BattleBit Public API

Project description

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 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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

battlebit-api-0.0.2.tar.gz (9.5 kB view details)

Uploaded Source

Built Distribution

battlebit_api-0.0.2-py3-none-any.whl (11.0 kB view details)

Uploaded Python 3

File details

Details for the file battlebit-api-0.0.2.tar.gz.

File metadata

  • Download URL: battlebit-api-0.0.2.tar.gz
  • Upload date:
  • Size: 9.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.12

File hashes

Hashes for battlebit-api-0.0.2.tar.gz
Algorithm Hash digest
SHA256 2f024c011ca10d1925dee64771c17136cbe1af45a3b95b74eaa412d81c856a17
MD5 07b4d2fe7dac6142ffd26139ad32c64c
BLAKE2b-256 41e6ea22d69cde5abef23cd849d5a2955e63e9d73fe160c5a8a043f9f9de76f4

See more details on using hashes here.

File details

Details for the file battlebit_api-0.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for battlebit_api-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 47fd98f853e03a920ca772f51780337dc456c05dff5e7199db31c1e2db272cec
MD5 18402f830cd6750f487a3c3f48f20f22
BLAKE2b-256 7496d48ebf0d2bc5417cc7dbc88f50b69edd85998ec97bbeb2e40d2d7054df30

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page