How to convert kibana query to elastic search json programmatically

I have KQL looking like these:

  1. f6:v6 or (f1:v1 or f2:v2 or (f3:v3 and f4:v4)) and not f5:v5
  2. field1:(value1 or value2) and field2:value3 and not field3:value4

I would like to convert to elastic searching json using programming languages like python.(I know how to convert it manually by looking at the inspect->request). However, i could not find any resources/libraries doing this. Did I somehow miss the package/Lib?

Thanks in advance