How can I identify the usage associated with an API key for API Gateway?
Last updated: 2022-08-12
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
- Open the API Gateway console.
- In the navigation pane, choose APIs.
- Choose your API, and then choose Usage Plans.
- Choose your Usage Plan.
- Choose Actions, and then choose Export Usage Data.
- Choose the export From and To date range.
- 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.