def api_frame_checksum(data: bytes) -> bytes:
    """
    Calculates the 8-bit checksum of the given data, returned as a byte array object of length 1.
    """
    checksum: int = 0
    for c in data:
        checksum += c           # Add all bytes
    checksum &= 0xFF            # Keep only the lowest 8 bits.
    checksum = 0xFF - checksum  # Subtract quantity from 0xFF.
    return bytes([checksum])    # https://stackoverflow.com/questions/21017698/converting-int-to-bytes-in-python-3