All Products
Search
Document Center

API Gateway:Overview

Last Updated:Jul 12, 2023

This topic describes how to create an API.

1. Methods to create an API

You can use one of the following methods 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 Open API > APIs. On the APIs page, click Create API. For more information, see Create an API.

  • Create an API by using OpenAPI Explorer

You can create an API by using OpenAPI Explorer. For more information, see Create an API.

  • Create an API by importing a Swagger file

Swagger is a specification used to describe API definitions. It is widely used to define and describe APIs for backend services. You can import a Swagger 2.0 file to create an API in the API Gateway console. You can use one of the following methods to import a Swagger file:

- Call the ImportSwagger operation. For more information, see ImportSwagger.

- Import a Swagger file in the API Gateway console. For more information, see Import Swagger files to create APIs.

2. API Gateway instance and API group

2.1 Instance

An API Gateway instance is a group of resources used to access and process your APIs. The resources include public IP addresses, private IP addresses, public egress IP addresses, and load balancing configurations. API Gateway supports shared instances and dedicated instances. These two types of instances are suitable for different scenarios.

  • Dedicated instances provide high performance and strict service level agreement (SLA) compliance. These instances are suitable for production environments.

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

For more information about the differences between the two types of instances, see Instance types.

2.2 API group

An API group is a management unit of APIs. Before you create an API, you must create an API group. When you create an API group, the system allocates a second-level domain name to the API group. This second-level domain name is used for testing. If you use this domain name to make API calls, you can make 100 calls per day in regions outside the Chinese mainland and 1,000 calls per day in regions in the Chinese mainland. We recommend that you bind an independent domain name that is filed in Alibaba Cloud to your API group. Then, you can use the domain name to call APIs in your API group.

For more information about how to bind an independent domain name to an API group, see Bind a domain name to an API group.

3. Steps to create an API

3.1 Configure basic information

Configure the basic information for the API that you want to create. The information includes Group, API Name, Security Authentication, API Option, and Description.

3.2 Define the API request

Define an API request. The detailed configurations include Request Type, Protocol, Custom Domain Name, Request Path, HTTP Method, Request Mode, and Input Parameter Definition.

API Gateway supports the HTTP, HTTPS.

3.3 Define the backend service

Define mappings between the request and response parameters and configure information of the backend service of your API. The information includes Backend Service Type, Backend Service Address, Backend Request Path, HTTP Method, Backend Timeout, Backend Service Parameter Configuration, Constant Parameter, and System Parameter. After API Gateway receives a request for the API, API Gateway maps the request parameters based on these configurations before it routes the request to the backend service.

The backend service types supported by API Gateway include HTTP/HTTPS Service, Function Compute, VPC, and Mock.

For information about the HTTP/HTTPS Service type, see Create an API with HTTP as the backend service type.

For information about the Function Compute type, see Use Function Compute as the backend service of the API.

For information about the VPC type, see Use a resource in a VPC as the backend service of an API operation.

For information about the Mock type, Use Mock as the backend service of an API operation.

3.4 Definition the response

Configure Content Type of Response, Sample of Returned Results, Sample of Returned Failure, and Error Code Definition.

4. Environment management

API Gateway allows you to configure the test (Test), staging (Pre), and production (Production) environments for an API group. This meets your requirement for API calls in different scenarios. For example, testing resources are configured for a test environment so that you can test your services by using the APIs with the same API configurations as those in the production environment.

For more information, see Configure different environments for an API operation.