- Go to the Google Cloud Console: Open your web browser and go to the Google Cloud Console.
- Select or Create a Project: In the top right corner, use the project selector to select an existing project or create a new one. If you’re creating a new project, follow the prompts to set it up.
- Navigate to the API & Services Dashboard: From the Google Cloud Console, navigate to the “APIs & Services” dashboard. You can find this by clicking on the hamburger menu in the top left corner, then selecting “APIs & Services” and finally “Dashboard.”
- Enable the API: If you haven’t already, enable the API for which you want to create an API key. You can do this by clicking on the “+ ENABLE APIS AND SERVICES” button. Search for and enable the specific API you need.
- Create Credentials: After enabling the API, navigate to the “Credentials” page. Click on the “Create Credentials” button, and choose “API key” from the dropdown menu.
- Configure API Key: Google Cloud Console will create an API key for you. You can restrict the usage of this key to specific APIs, IP addresses, or websites if needed. Make sure to configure the API key settings according to your requirements.
- Copy API Key: Once configured, your API key will be generated. Copy the API key and store it securely. Do not share your API key publicly.
- Restrict API Key (Optional): For security reasons, you may want to restrict the usage of your API key. You can do this by setting up restrictions such as restricting the key to specific APIs, IP addresses, or HTTP referrers. This can be configured in the “API restrictions” section of the API key settings.