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 class documentation for more information.

Class documentation

BattleBitApiClient

BattleBitApiClient(root_endpoint: str)

The initializer for BattleBitApiClient takes the optional argument root_endpoint: str which already points to the BattleBut Public API by default.

If the domain of the API was to change, use this argument to adapt.

get_server_list(with_update: bool)

The method get_server_list returns an object of type ServerList. Use the optional argument with_update to force a new request to the API.

You can use the ServerLists last_updated property to implement your own update cycle. BattleBitApiClient does not provide automatic refreshes. By default it will only refresh the ServerList if it is empty or explicitly told to do so.

ServerList

get_servers_by_map(map_: Map)

Returns all Servers that run the map map_. Does not differentiate between map sizes.

get_servers_by_region(region: Region)

Returns all Servers that run in the region region.

get_servers_by_size(size: MapSize)

Returns all Servers that have a map size of size.

search_for_server_by_name(search_str: str)

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

get_servers_sorted_by_current_players(many_to_few: bool = True)

Returns all Servers, sorted by the amount of players currently on it. Use many_to_few to sort either ascending or descending.

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.1.tar.gz (6.9 kB view hashes)

Uploaded Source

Built Distribution

battlebit_api-0.0.1-py3-none-any.whl (7.8 kB view hashes)

Uploaded Python 3

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