How can I identify the usage associated with an API key for API Gateway?

2 minute read
0

How can I get the usage associated with an API key for Amazon API Gateway?

Resolution

Follow these instructions to get the API key usage using either the AWS Management Console or the AWS Command Line Interface (AWS CLI).

Note: If you receive errors when running AWS CLI commands, make sure that you’re using the most recent version of the AWS CLI.

Use the AWS Management Console

  1. Open the API Gateway console.
  2. In the navigation pane, choose APIs.
  3. Choose your API, and then choose Usage Plans.
  4. Choose your Usage Plan.
  5. Choose Actions, and then choose Export Usage Data.
  6. Choose the export From and To date range.
  7. For Export as, choose JSON or CSV, and then choose Export.

For more information, see Create, configure, and test usage plans with the API Gateway console.

Use the AWS CLI

You can use the AWS CLI command get-usage to get the usage data of a usage plan in a date range similar to the following:

aws apigateway get-usage --usage-plan-id <usage-plan-id> --start-date "20xx-xx-xx" --end-date "20xx-xx-xx" --key-id <api-key-id>

Note: The usage date range can't exceed 90 days.

For more information, see Create, configure, and test usage plans using the API Gateway CLI and REST API.


Related information

Best practices for API keys and usage plans

AWS OFFICIAL
AWS OFFICIALUpdated 2 years ago