This document describes API Keys, when to use them, how to acquire them, and how to use them with the Google APIs Client Library for Python.
When calling an API that does not access private user data, you can use a simple API key. This key is used to authenticate your application for accounting purposes. The Google APIs Console documentation also describes API keys.
Note: If you do need to access private user data, you must use OAuth 2.0.
Acquiring API keys
- Open the Credentials page in the API Console.
- Click Create credentials > API key and select the appropriate key type.
To keep your API keys secure, follow the best practices for securely using API keys.
Using API keys
To use an API key, pass it to the build() function when creating a service object. The Simple API Example on the Getting Started page provides a complete example that uses API keys. Here is the relevant line from that script:
service = build('books', 'v1', developerKey="api_key")
All calls made using that service object will include your API key.