def build_binder(repo, ref, *, binder_url="https://mybinder.org", build_only):
    """Launch a binder

    Yields Binder's event-stream events (dicts)
    """
    print(f"Building binder for {repo}@{ref}")
    url = binder_url + f"/build/gh/{repo}/{ref}"
    params = {}
    if build_only:
        params = {"build_only": "true"}

    r = requests.get(url, stream=True, params=params)
    r.raise_for_status()
    for line in r.iter_lines():
        line = line.decode("utf8", "replace")
        if line.startswith("data:"):
            yield json.loads(line.split(":", 1)[1])
Launch a binder

    Yields Binder's event-stream events (dicts)
    
examples/binder-api.py