Thank you for reaching out. I could see that you want to pull the said metrics in order to add it to your formula. Unfortunately, there is no direct way of doing this via the API. The API can fetch these impressions but then you would have to create your own implementation on how you would put the data in your formula.
Upon checking, these impressions can be pulled using Google Ads API reporting on the following resources: ad_group, campaign, keyword_view.
Here is a sample query:
SELECT metrics.top_impression_percentage, metrics.absolute_top_impression_percentage, metrics.search_absolute_top_impression_share, metrics.search_top_impression_share FROM *resource_name*