I want to get an Amazon API Gateway REST, HTTP, or WebSocket API ID and the invoke URL to manage my APIs.
Resolution
Get the REST API , HTTP API , or WebSocket API ID and invoke URL
Complete the following steps:
- Open the API Gateway console.
- In the navigation pane, choose APIs.
- Select your REST API, HTTP API, or WebSocket API.
- On the API Gateway console page, note the API ID. The API ID is a string of characters and numbers, such as chw1a2q2xk.
- In the navigation pane, choose Stages.
- On the Stage details page, note the Invoke URL. The following URLs are examples:
REST API or HTTP invoke URL: https://0123456789.execute-api.{region}.amazonaws.com/{stage-name}
WebSocket URL: wss://{api-id}.execute-api.{region}.amazonaws.com/{stage-name}
Note: If you use the default stage ($default), then the HTTP API URLs might not include the stage name.
Use the API ID to get more information about the API
Note: If you receive errors when you run AWS Command Line Interface (AWS CLI) commands, then see Troubleshooting errors for the AWS CLI. Also, make sure that you're using the most recent AWS CLI version.
REST APIs
To get the API name and create date for your REST API, run the following get-rest-api command:
aws apigateway get-rest-api --rest-api-id your-api-id
Note: Replace your-api-id with your REST API ID.
HTTP APIs and WebSocket APIs
To get the API name and create date for your HTTP API or WebSocket API, run the following get-api command:
aws apigatewayv2 get-api --api-id your-api-id
Note: Replace your-api-id with your HTTP API ID or WebSocket API ID.
Use the URI to invoke the API
REST APIs and HTTP APIs
Note: Before you invoke a REST API, make sure that you redeploy the REST API.
Run the following curl command to invoke your REST API or HTTP API:
curl -v https://your-api-id.execute-api.your-region.amazonaws.com/your-stage-name
Note: Replace your-api-id with your REST API or HTTP API ID, your-region with your AWS Region, and your-stage-name with your stage name.
WebSocket APIs
Note: Before you invoke the WebSocket API, make sure that you redeploy the WebSocket API.
Run the following wscat command to invoke your WebSocket API:
wscat -c wss://your-api-id.execute-api.your-region.amazonaws.com/your-stage-name
Note: Replace your-api-id with your WebSocket API ID, your-region with your Region, and your-stage-name with your stage name.
Related Information
API Gateway REST APIs
API Gateway HTTP APIs
API Gateway WebSocket APIs