能否在AWS API Gateway中删除API?学习创建的多API如何删除?
Absolutely! You can definitely delete APIs in AWS API Gateway—whether they're REST, HTTP, or WebSocket APIs. Below are step-by-step methods for both the AWS Management Console and AWS CLI, depending on your workflow preference.
Using the AWS Management Console
- Log into your AWS account and navigate directly to the API Gateway service dashboard.
- In the left sidebar, select the category matching the API type you want to delete (e.g., REST APIs, HTTP APIs, WebSocket APIs).
- From the list of APIs displayed, click the name of the API you wish to remove to open its details page.
- Locate the Actions dropdown menu in the top-right corner of the page.
- Select Delete API from the dropdown options.
- A confirmation dialog will appear—double-check you’ve selected the correct API (since deletion is irreversible), then click Delete to finalize the action.
Note: Before deleting, verify there are no active deployments, linked Lambda functions, or downstream dependencies that might break once the API is removed. Deleted APIs cannot be recovered.
Using the AWS CLI
If you prefer command-line operations, the AWS CLI offers straightforward commands to delete APIs. The exact command varies slightly based on the API type:
For REST APIs
Run this command, replacing your-api-id with the unique ID of your REST API:
aws apigateway delete-rest-api --rest-api-id your-api-id
For HTTP APIs
Use this command, substituting your-api-id with your HTTP API's ID:
aws apigatewayv2 delete-api --api-id your-api-id
For WebSocket APIs
WebSocket APIs use the same API Gateway V2 endpoint as HTTP APIs, so the command is identical:
aws apigatewayv2 delete-api --api-id your-api-id
Tip: To retrieve your API's ID, you can list all APIs of a specific type with commands like
aws apigateway get-rest-apis(for REST APIs) oraws apigatewayv2 get-apis(for HTTP/WebSocket APIs).
内容的提问来源于stack exchange,提问作者Ramjan Ali

