Capping API usage

Depending on the API, you can explicitly cap requests by limiting the requests per day, requests per minute, or requests per minute per user.

You might want to limit the billable usage by setting caps. For example, to prevent getting billed for usage beyond the free courtesy usage limits, you can set requests per day caps.

Modify the limits on the number of requests

You can set limits to all requests to any billable API. Most APIs set default limits, but you can change that limit up to a maximum specified by Google. Some APIs set a low limit until you enable billing on your project.

To view or change the limits for your API, do the following:

  1. In the Cloud Console, go to the APIs & Services Dashboard page.

    Go to APIs & Services Dashboard

  2. From the projects list, select a project or create a new one.
  3. Click the name of the API you're interested in.
  4. Click Quotas. If the Quotas menu item is not present in the left nav, it means the API you've selected doesn't have quotas defined.
  5. Expand the service whose quota you want to change, and then click the edit icon for the quota you want to change.
  6. Enter your preferred Quota limit, up to the limit specified by Google, and then click Save.

Some APIs let you request a higher limit by submitting a form. Some APIs let you specify a higher quota only if billing is enabled on the project.

The Premium Plan quota sections pertain to the Google Maps Premium Plan, which is no longer offered. Unless you are a current Google Maps Premium plan customer, don't edit those sections.

Limiting requests per user

To prevent individual users from using up your API quota, some APIs include a default per user per minute limit. If such a default limit exists, you can modify that value as described in the previous section to limit the quota available to each user.

Individual users are identified by a unique string. If you're creating a server-side application (where the calling code is hosted on a server that you own) that makes requests on behalf of users, your requests must include the quotaUser parameter.

To identify a user, use the quotaUser=userID parameter. This value is for short-term quota enforcement only, so you don't need to use a real user ID. You can choose any arbitrary string under 40 characters long that uniquely identifies a user.

The quotaUser parameter is only used for capping requests per user per minute. If you don't send the quotaUser parameter, then all calls are attributed to your server machines, in which case calls can't be capped by user.

View and edit all quotas for APIs in a project

You can review, edit, and request higher quota limits for all billable APIs in a given project by viewing the Quotas page in the IAM & Admin section of Cloud Console.

To view and edit quotas for all billable APIs in your project, do the following:

  1. In the Cloud Console, go to the Quotas page.

    Go to Quotas

  2. From the projects list, select a project or create a new one. The Quotas page for the selected project displays, listing one line item for each type of quota available in each service.
  3. Use the Filter field to filter the list of quotas by Service, Limit name, Quota status, Service ID, and/or Metric.
  4. Check the box next to the quota(s) you want to edit. Billing must be enabled on the project in order to click the checkboxes.
  5. Click EDIT QUOTAS.
  6. In the Quota changes pane that displays, expand the service view, then edit the quotas in that service as needed, and then click DONE.
  7. Repeat to edit the quotas in each of the selected services.
    • The current quota limits are pre-populated in the input boxes.
    • A service with an alert icon () on submission has input errors.
    • You can add more quotas to edit by selecting them as described before.
    • You can remove a service from the Quota changes pane by hovering over the unexpanded service view, and then clicking the delete icon ().
  8. When you are done editing quotas, click NEXT.
  9. If your quota edit request needs review, the Contact details form displays. Complete the form with your contact details.
  10. Click SUBMIT REQUEST.

Test

  1. On example-db's Overview page, click Create table at the start of the list of tables.

    The Cloud Console displays the Write DDL statements page.

  2. Enter:

    google_sql_name

    CREATE TABLE Singers (
      SingerId   INT64 NOT NULL,
      FirstName  STRING(1024),
      LastName   STRING(1024),
      SingerInfo BYTES(MAX),
      BirthDate  DATE,
    ) PRIMARY KEY(SingerId);
    

    postgresql_name

    CREATE TABLE Singers ( SingerId BIGINT PRIMARY KEY, FirstName VARCHAR(100), LastName VARCHAR(100), SingerInfo BYTEA, BirthDate TIMESTAMPTZ );

  3. Click Submit.