How to implement an interactive bokeh viz in FastAPI?

Spent some time googling, but couldn’t really find a definitive tutorial/example of how to implement an interactive viz (with callbacks, etc…) in FastAPI.

I’ve built bokeh visualizations in Jupyter, but not sure what/how to take that and do the same within a fastapi application. Any guidelines and resources would be much appreciated.


@wgpubs In principle you could certainly have CustomJS callbacks that make fetch calls to REST APIs (in general—I don’t think there is anything specific at all about FastAPI) and then use the response to update a Bokeh plot or whatever. Something vaguely along the lines of

// completely untested pseudocode 
  .then(response => response.json())
  .then(data => { = {
      titles: response['titles'],
      stars: response['stars'],

But I don’t have any concrete examples to offer, and I am not specifically aware of hearing about anyone doing this ether.

Ok cool … I’ll play with it.

Thanks - wg

Does bokeh.js support making everything that you can make/do in the python port? If so, that seems as if it is likely the best option for me. Lmk.


All of the actual work of Bokeh is done all done by BokehJS. So the short answer must be “yes”. But that’s a statement about the raw, low-level models layer of BokehJS, which is not necessarily convenient to use directly. There is a higher level BokehJS API, but it has not gotten as much attentions and does not yet have parity with bokeh.plotting. But you can see what there is here:

1 Like