Twitter v2 APIs: Accessing monthly tweet cap via API - twitter

My app invokes the Twitter v2 APIs to retrieve users tweets.
According to the Twitter Dev Portal I have a monthly tweet cap of 500,000 tweets that I can retrieve, and this UI tells me how much I've used.
However, is there any way to retrieve this data via an API?
This page seems to imply it's just via the UI, but I'm surprised there is no way to retrieve this via an API. Is there any such way even for v1?

v1.1 had no volume cap, but does have rate limits, which you can access via the HTTP headers on GET requests. POST requests are different, and managed at the user account level.
In v2, at the time of writing, there is currently no way to access the cap and volume data via the API - it is only available in the UI.

Related

Does YouTube Data API billing change if the APIs are called from GCP server or AWS server?

I'm building an Android app which embeds YouTube videos. I'm confused on how the billing works for the YouTube Data API v3. Is it dependent on whether the APIs are called from GCP server or AWS server?
The YouTube Data API, is a free API Google does not charge you for accessing this API. You are free to use it. Therefore no billing account is needed in order to access this API.
You do have a quota which limits the number of request that you can make to the API over a period of time.
Useful links
Quota cost calculator
YouTube API and cost based quota demystified

Youtube data API quota on using the same google client on different devices

The current youtube API quota is 10,000 units/day.
So what if I created an app and this app has 100 copies installed on different 100 devices and all of them use different IPs, would the quota be 10,000 units/day for every device (1M/day) or the 10,000 units would be distributed among the different copies?
Note that the requests will be executed on different devices. this is an embedded app., not a cloud one.
10,000 units/day is project based, not user based. IP address won't affect anything.
As you can see from the above image on the Queries per minute per user is user based, and detected via ip address, sending the quotauser parameter along with the request or sending an authorization header containing an access token.
In order to get around your 10k quota in this manner you would need to create 100 projects on google developer console and create credietnals for each of those projects and then each project would have 10k quota. However the drawback would be trying to get 100 projects though the google verification process.
You could just request an extension of your quota if you need more quota. 😊
Additional Clarifications
API key Used to access public data only and identifies your application to google
Client id and client secrete used to create a access token, will identify both the application and the user to google once a user is authorized and you are sending an access token authorization header with your request.
The quotaUser and userIp parameters can only be used for anonymous requests with some Google apis this has changed recently i am not sure if it still works with YouTube api private calls. userIp allows you to send any ip address with the request, and QuotaUser allows you to send any string for example your internal user id for the user making the requests. In the past this allowed for some hacking / work around for the per user quotas.
None of the above information will really help you as the quota you are trying to get around is a project based quota and not a user based quota. Its detecting the project associated with your client id / api key (depending upon what you are using) changing the IP or generating a new client under your project isnt going to help.
Really just request more quota
There are two ways an app is identified by the API:
the API key that the app uses when invoking the API endpoints (for reading only public data), or
the credentials data (i.e. access token) the app makes use of when calling in various endpoints (for reading only public data pertaining to any YouTube channel, or, otherwise, for reading/updating/deleting public and/or private data pertaining the YouTube account/channel that granted permissions of operation to the respective app).
Therefore, from the point of view of the API, it doesn't really matter if you are running N different instances of your app (i.e. programs running on concrete computers). The API accounts for the quota consumption of a given project created through Google developers console.
In this context of an app (as a concrete program) running on several machines that share API keys and/or credentials data, I recommend warmly to get familiar with the content of the DTOS specifications.

How to make calls to youtube Api with user Api key

I will be building a spring-boot app that consumes resource from the Youtube Api. However, I discovered that the youtube API has a limit of resource that can be consumed by one API key.
This will be a multi user app, So i'll like to build out the functionality in which when a user signs into the app via gmail, the user's API will automatically be used to consume resources from the youtube API , without the user having to go digging into the Youtube API documentation to get there API key.
Any ideas of how to automatically enable a new user’s api key to make the call , instead of my api key ?
Thanks in advance.
I discovered that the youtube API has a limit of resource that can be consumed by one API key.
This is called quota and its not related to the API key but rather related to the project. You have a quota limiting the number of requests that your project can make against the API. see quota calculator
This will be a multi user app, So i'll like to build out the functionality in which when a user signs into the app via gmail, the user's API will automatically be used to consume resources from the youtube API , without the user having to go digging into the Youtube API documentation to get there API key.
If you want to allow a user to login to their YouTube api account then you will be using Oauth2 client credentials and not an API key. The API key will only allow you to access public data no private data will be available.
Any ideas of how to automatically enable a new user’s api key to make the call , instead of my api key ?
API keys are not user specific you cant create a new user api key. Thats not how API keys work, api keys enable your application to access public data on YouTube it is defined by you manually though the Google developer console and identifies your application to Google.

Read data from Youtube Analytics API without Oauth2

I am currently writing a python script to pull information from YouTube Analytics API for a list of separate YouTube channels. The output would be, for example, count video views for each YouTube channel in last month.
My initial idea was to ask each of the YouTube account owners to create a YouTube Analytics app in their console.cloud.google, create a Project, enable the youTube Analytics API, generate an API key and specify that it is needed for the YouTube Analytics API.
I'm testing with one account and if I try to run the script using the API Key generated with the process described above and authenticating like this:
def get_service():
return build('youtubeAnalytics', 'v2', developerKey=API_KEY)
it fails with a HttpError 401 Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.
I am not sure if I have done something wrong in creating the API key, or if instead the YouTube Analytics API requires Oauth2 authentication. If the latter is the case, then I am surprised that google console lets you to go all the way and generate API keys and specify that they are needed for the YouTube Analytics API, only for you to find out that you can't use it.
So my question is: do I have to use Oauth2 for YouTube Analytics API or can I use the API key? I'm trying to read data from "my own" account, so why do I need to manually authorise my own app?
Ok I found out that it is not possible to use YouTube Analytics API without OAuth 2.0 authentication. The Google docs and the Google console are very confusing in my opinion as they respectively allow you to create API keys specific for YouTube Analytics API and describe API keys as a possible way to authenticate (only to tell you after that, that all methods require OAuth2.0).
I'm still unclear on how to setup YouTube Analytics API authentication for a command-line python script that does not require users to give manually consent every time the script runs.
I will open a separate question for that.
Set key parameter. You can read data with api key. It's simple.
http -v 'https://www.googleapis.com/youtube/v3/playlistItems?playlistId={playlistId}&part=id,snippet,contentDetails,status&key={api_key}&max_results=10'

Is it possible to access the live tweets of a user using tweepy?

I am trying to access live tweets of a user whenever he tweets it. So, all I want is something that continuously monitors a user account and whenever he tweets something I have to capture it. All the tweets are random so I cannot use any filters.
For any security reasons, if I cannot access other's tweets can I do it on my own account?
With tweepy you can connect to the REST API or the Streaming API.
Using the Streaming API you can use the filter endpoint to select the users you wish to follow with that streaming connection and you will receive updates as they get published.
Twitter's documentation: https://dev.twitter.com/docs/api/1.1/post/statuses/filter, tweepy's code: https://github.com/tweepy/tweepy/blob/master/tweepy/streaming.py
Tweepy's documentation doesn't give examples on the Streaming functions but you can find sample code searching at GitHub or StackOverflow for "tweepy filter follow".
Tweepy talks to the Twitter REST API, and the REST API doesn't have any way to react to someone posting a tweet.
HOWEVER...
You could certainly write an application that retrieves the tweets of a partcular user and looks for any tweets that weren't there the last time you checked.
You'd want to be cautious about how often you check so you don't run afoul of the API rate limits.

Resources