I recently ran across a very intersting question on Stack OverFlow. Stack Overflow is a language-independent collaboratively edited question and answer site for programmers, which I spend a lot of time on. The question was quite simple How long is the Google API key Valid? . The person who posted this is a new user to stack, but this question was simple and to the point.
Where do I get a Public API key?
You get a Public API key in the same place you get a OAuth2 key and Service account Credentials, The Google Developer console. In order to access most of the Google APIs you need to create a project on the Google Developer console, but why do we need to create a project on the Google Developer Console?
What is the Google Developer Console?
The Google Developer console is where we as developers register our intention to use the Google APIs. There are several reasons why we need to do this before attempting to access the Google APIs the first being, you don’t have a choice in most cases you cant access the API until you have registered your application with Google.
Google needs to know who is accessing there APIs. There are limits to how much information we can request from the Google APIs (Quota). Each of the Google APIs has a different quota limit associated with it.
The Google Analytics API gives you 50,000 requests per day, after this you have to request an extension. Google keeps track of the quota based upon the project you created in Google Developer console. Note: In most cases you can extend the quota, not all of the APIs charge you for extending the quota but some do please check.
Abuse detection, say someone wanted to really annoy Google they could do a DoS attack using the key to access the API. Google will know who is doing this by the project and be able to shut this person down instantly, there by protecting there servers from damage.
Whitelisted access, some of the Google APIs are on beta access you need to apply for permission to use them permission to use them is granted based upon the project id in Google Developer console
What is a Public API key?
The Public API key gives you access to Public data on Googles Servers. Public data is data that is not restricted by user access. When I post a message on Google Plus and set it to Public this is public data. When I post a video on YouTube and set it public this is also public data, anyone can access it with out being Authenticated. My emails, and events in my personal Google calendar are private data you would need my permission to access it.
In the Google Developer console APIs & auths -> credentials at the very bottom you will see this.
That is a public API key and can be used to access Public data.
Expiration of public API Key
Now back to the question from stack OverFlow. The author of the question is correct, I have not been able to find anyplace where it states how long these public API keys are good for. The fact of the matter is Public API keys don’t expire. They are valid for as long as you don’t delete them.
So feel free to request as much public data for as long as you want, with in the limitations of your quota of course. Welcome to the would of Developing with Google!