Get an API Key

Select platform: Android iOS JavaScript Web Service

Before you begin

Before you start using the Places SDK for iOS, you need a project with a billing account and the Places SDK for iOS enabled. To learn more, see Set up in Cloud Console.

Creating API keys

The API key is a unique identifier that authenticates requests associated with your project for usage and billing purposes. You must have at least one API key associated with your project.

To create an API key:

Console

  1. Go to the Google Maps Platform > Credentials page.

    Go to the Credentials page

  2. On the Credentials page, click Create credentials > API key.
    The API key created dialog displays your newly created API key.
  3. Click Close.
    The new API key is listed on the Credentials page under API keys.
    (Remember to restrict the API key before using it in production.)

Cloud SDK

gcloud alpha services api-keys create \
    --project "PROJECT" \
    --display-name "DISPLAY_NAME"

Read more about the Google Cloud SDK , Cloud SDK installation , and the following commands:

Restricting API keys

Google strongly recommends that you restrict your API keys by limiting their usage to those only APIs needed for your application. Restricting API keys adds security to your application by protecting it from unwarranted requests. For more information, see API security best practices.

To restrict an API key:

Console

  1. Go to the Google Maps Platform > Credentials page.

    Go to the Credentials page

  2. Select the API key that you want to set a restriction on. The API key property page appears.
  3. Under Key restrictions, set the following restrictions:
    • Application restrictions:
      1. Select iOS apps.
      2. To accept requests from the iOS app with the bundle identifier that you supply, select the appropriate iOS bundle identifier from the list.
    • API restrictions:
      1. Click Restrict key.
      2. Select Places API from Select APIs dropdown. If the Places API is not listed, you need to enable it.
  4. To finalize your changes, click Save.

Cloud SDK

List existing keys.

gcloud services api-keys list --project="PROJECT"

Clear existing restrictions on existing key.

gcloud alpha services api-keys update "projects/PROJECT/keys/KEY_ID" \
    --clear-restrictions

Set new restrictions on existing key.

gcloud alpha services api-keys update "projects/PROJECT/keys/KEY_ID" \
    --api-target="places-backend.googleapis.com"
    --allowed-bundle-ids="BUNDLE_NAME"

Read more about the Google Cloud SDK , Cloud SDK installation , and the following commands:

What's next

Now that you have an API key, create and configure a project as described in Set Up an Xcode Project.