import json


def get_end_stream_request(stream_id: str, request_id: int, api_version: str) -> str:
    """
    Parameters
    ----------
    stream_id:
        ID of stream we want to stop
    request_id:
        ID of EndStreamRequest

    Returns
    -------
    Serialized EndStreamRequest
    """
    api_message = {
        "api_version": api_version,
        "api_request": {
            "request_id": request_id,
            "end_stream_request": {"stream_id": stream_id},
        },
    }

    return json.dumps(api_message)