All Products
Search
Document Center

API Gateway:Create a WebSocket API

Last Updated:May 21, 2025

WebSocket APIs are based on the WebSocket protocol, which allows bidirectional communication between clients and servers. They are ideal for building real-time applications such as chat applications, real-time notifications, and games. This topic describes how to create a WebSocket API in the console.

Scenarios

Cloud-native API Gateway provides two methods to create APIs: within an instance and outside an instance. These methods are applicable to the following scenarios:

Create an API within an instance

  • Dedicated resource management: The API is required only within a specific instance to manage specific resources or internal logic.

  • Security and fencing: Data or features need to be strictly isolated to ensure security and can be called only within the instance.

  • Simplified service configuration: Simplifies API configuration and management within a specific instance.

Create an API outside an instance

  • Cross-instance shared access: Multiple instances share API definition information.

  • Centralized management and monitoring: Unified access control, log recording, and stream management.

Important
  • APIs created within an instance are visible and manageable only in the corresponding instance.

  • APIs created outside an instance cannot be edited or deleted within an instance. You need to go to the API list outside the instance to perform these operations.

Procedure

  1. Cloud-native API Gateway provides two methods to create APIs: within an instance and outside an instance:

    API outside an instance

    1. Log on to the Cloud-native API Gateway console. In the left-side navigation pane, select API, and select a region in the top menu bar.

    2. Click Create API, and then click Create in the WebSocket API card.

    API within an instance

    1. Log on to the Cloud-native API Gateway console. In the left-side navigation pane, select Instances, and select a region in the top menu bar.

    2. On the Instances page, click the ID of the target gateway instance. In the left-side navigation pane, select API, and click Create API in the upper-right corner.

    3. Click Create in the WebSocket API card.

  2. On the Create WebSocket API page, enter the API Name and Description, and select the target Resource Group.

    Configuration item

    Description

    API Name

    Specify a custom name for the API that you want to create. The API name must be globally unique.

    Description

    Enter a description for the API.

    Resource Group

    Select the target resource group. You can click Create Resource Group on the right.