def METHOD_NAME(
    experiment: Experiment, status: str, algorithm: dict, best_trial: Trial = None
):
    """
    Build the response representing an experiment response object according to the API
    specification.
    Parameters
    ----------
    experiment: Experiment
        The experiment to return to the API
    status: str
        The status of the experiment
    algorithm: dict
        The dictionary containing the algorithm's configuration
    best_trial: Trial (Optional)
        The best trial to date of the experiment
    Returns
    -------
    A JSON-serializable experiment response object representing the given experiment.
    """
    data = {
        "name": experiment.name,
        "version": experiment.version,
        "status": status,
        "trialsCompleted": 0,
        "startTime": None,
        "endTime": None,
        "user": experiment.metadata["user"],
        "orionVersion": experiment.metadata["orion_version"],
        "config": {
            "maxTrials": experiment.max_trials,
            "maxBroken": experiment.max_broken,
            "algorithm": algorithm,
            "space": experiment.configuration["space"],
        },
        "bestTrial": build_trial_response(best_trial) if best_trial else {},
    }
    stats = experiment.stats
    if stats.trials_completed:
        data["trialsCompleted"] = stats.trials_completed
        data["startTime"] = str(stats.start_time)
        data["endTime"] = str(stats.finish_time)
    return data