'How to access non public metrics using tweepy v2

As part of Twitter v2, there are public and non public metrics. As part of the non public metrics, there is the abiliy to check the amount of Impressions that a tweet got (The number of times it appeared on a screen), I have been able to access the public metrics, but unable to access the non public metrics so I could see the number of Impressions.

To access the public metrics I am using this bit of code:

tweet = client.get_tweet(id = tweet_id,tweet_fields=['created_at', 'public_metrics', 'lang', 'author_id'],expansions=['author_id']) tweetmetrics = tweet.data['public_metrics'] print(tweetmetrics)

How do I get the non-public_metrics?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source