KQL syntax with python

I have this idea of using KQL syntax through python or javascript. I have a dashboard named "main" and in that, we have a field called "topic". So, on the dashboard page when I use the KQL syntax and type in the search bar - topic: "rajamouli" the dashboard updates itself automatically. It is working nicely. But the limitation is that it only works on that particular Kibana page. What I want is to use the KQL syntax with python in order to get something automatic from my end. But I have absolutely zero knowledge of how to work KQL syntax with python. So, need some references for this and if possible some links that I could check and start working upon.

There is no public API to generate dashboards for Python or other languages but you can compare the snapshot URL generated by the Share => Embed Code interface in Kibana

And you'll see that you can add the query to the URL as an encoded parameter. Mind that this procedure may change between versions.

For example you can compare this two URLs that point to a public dashboard I have showing a saved search: