Skip to main content

Working with the Data

Whether you are getting the esports data from the LoL Esports Data Portal, or from the BEDEX, you will most probably want to process it in some way. Here are some tips on how to get started with the game data processing.

The esports game data, that you are receiving from Bayes, follows the unified Data Format. It's best that you understand its structure before reading this article.

Java Implementation Tips

If you already have access to the live-data-message-model repository (if not, please ask at support@bayesesports.com), you can take a look at an example deserializer there. It is available via live-data-message-model-simple, which does not include handling of the wrappers at the moment, but it can give you an idea of how to implement it:

final String messagePayloadString = recv(); // receive the message from somewhere

// create the handler
final LiveDataMessageHandlerSimple handler = LiveDataMessageHandlerSimple
.<BayesMessageEnvelope>builder()
.objectMapper(objectMapper)
.lolHandler(matchId -> new MyLolHandler(matchId))
.csgoHandler(matchId -> new MyCsgoHandler(matchId))
.envelopeClass(BayesMessageEnvelope.class)
.build();

// then use it to process events contained in received messages:
handler.handleMessage(messagePayloadString);

Python Implementation Tips

As in the Java example, we are leaving the actual implementation to you, but the high level workflow may look like this.

At the beginning of the processing, we need to parse the outmost data structure of the message, the DataProviderMessage. It contains some useful information about the message, which may help us determine early on if we should start processing this message, skip it, or leave it for later. If all checks pass, we can unpack the payload from the DataProviderMessage and pass it to the next processing function.

# ...
message = get_message() # receive the message from somewhere

def process_data_provider_message(message: dict) -> None:
version = float(message['version'])
check_message_version(version)

seq_idx = message['seqIdx']
check_seq_idx(seq_idx)
payload = message['payload']
return process_bayes_message_envelope(payload)

The next processing function, process_bayes_message_envelope deals with BayesMessageEnvelope structure. The envelope contains game-specific properties. It allows us to do additional checks or update our processing classes with fresh game info before passing the data to the next processing function.

def process_bayes_message_envelope(message: dict) -> None:
game_urn = message['urn']
check_game_urn(game_urn)

add_props = message['additionalProperties']
Processor.update_additional_properties(add_props)

payload = message['payload']
process_live_data_message(payload)

While processing the main data structure, the LiveDataMessage, we have access to the type-subject-action triad. In the example above, we are using the imaginary get_proc_func function to determine the function that should process this Live Data Message payload. This function will do the actual work with the game data. For the GAME_EVENT-PLAYER-KILL message above from the example above, it may increase the kill counter of one player and the death counter of the other. Or it may do anything else with the data, you paid for it, it's yours now!

def process_live_data_message(message: dict) -> None:
type_ = message['type']
subject = message['subject']
action = message['action']
# determine how we should process this message based on the triad:
proc_func = get_proc_func(type_, subject, action)

payload = message['payload']
proc_func(payload)