Overview

更新时间:
复制 MD 格式

API Gateway provides three ways to create an API. Before you create an API, understand the key concepts — instances and API groups — and the four-stage configuration workflow.

Methods to create an API

API Gateway provides three ways to create an API:

  • Create an API in the API Gateway console

Log on to the API Gateway console. In the top navigation bar, select a region. In the left-side navigation pane, choose Manage APIs > APIs. On the APIs page, click Create API. For more information, see Create an API.

  • Create an API using OpenAPI Explorer

OpenAPI Explorer lets you call the API Gateway API directly to create and configure APIs without using the console. For more information, see Create an API.

  • Create an API by importing a Swagger file

Swagger is a specification for describing API definitions. If you have an existing Swagger 2.0 file, you can import it to create an API in the API Gateway console. Two import methods are available:

API Gateway instance and API group

Instance

An API Gateway instance is a set of resources used to access and process your APIs, including public IP addresses, private IP addresses, public egress IP addresses, and load balancing configurations. API Gateway supports two instance types: serverless instances and dedicated instances.

  • Dedicated instances deliver high performance and strict service level agreement (SLA) compliance, making them suitable for production environments.

  • Serverless instances are suitable for development, testing, and assessment environments, as well as small-scale production environments.

For a detailed comparison, see Choose an instance type.

API group

An API group is the management unit for APIs. Before creating an API, you must create an API group. Each API group is automatically assigned a second-level domain name for testing. This testing domain name has a rate limit of 100 calls per day in regions outside the Chinese mainland and 1,000 calls per day in regions in the Chinese mainland. For production use, bind an independent domain name that is filed in Alibaba Cloud to your API group.

For more information about binding an independent domain name, see Make API calls through a custom domain name.

Steps to create an API

Creating an API involves four configuration stages:

Configure basic information

Set the identity and access control for the API. Parameters include Group, API Name, Security Authentication, AppCode Authentication, Signature Algorithm, API Option, and Description.

Define the API request

Specify how clients call the API — the protocol, path, and expected input. Parameters include Protocol, Custom Domain Name, Second-level Domain, BasePath, Request Path, HTTP Method, Request Mode, and Request Parameters.

API Gateway supports both HTTP and HTTPS for the Protocol parameter.

Define the backend service

Map the incoming request to your backend and configure how API Gateway forwards calls. Parameters include Configuration Mode, Backend Service Type, Backend Service, Backend Request Path, HTTP Method, Backend Timeout Period, Backend Service Parameters, Constant Parameters, and System Parameters.

After API Gateway receives a request, it maps the request parameters based on these configurations before routing the call to the backend service.

Supported backend service types:

Define the response

Specify what API Gateway returns to the caller. Parameters include Response ContentType, Response Example, Error Response Example, and Error Codes.

Environment management

API Gateway supports three environments for each API group: test (Test), staging (Pre), and production (Production). Each environment can have its own resource configurations, letting you test APIs under the same configuration as production.

For more information, see Manage environments.