Description
For creating an API.
- The API is intended for users who need to open an API.
- Duplicate API names in the same group are not allowed.
- Duplicate paths in the same group are not allowed.
- A group can contain up to 1000 APIs.
- This API can call up to 50 QPS for a single user.
Request parameters
Name | Type | Required? | Description |
---|---|---|---|
Action | String | Yes | Operation interface, which is a required parameter; value: CreateApi. |
GroupId | String | Yes | ID of the specified group. |
ApiName | String | Yes | Name of the API, which is unique in the group. Names must be a string of 4–50 characters, which can contain Chinese characters, English letters, numbers, and underscores, and starts with an English letter or Chinese character. |
Visibility | String | Yes | Indicates whether the API is public; values:
|
Description | String | Yes | Description on the API, at most 180 characters. |
AuthType | String | Yes | API security authorization type; values:
|
AllowSignatureMethod | String | no | Configuration the algorithm of singature method, when AuthType is APP. HmacSHA256 is the default value, values:
|
RequestConfig | String | Yes | Configuration items of the API request sent by a consumer to the gateway. |
ServiceConfig | String | Yes | Configuration items of the API request sent by the gateway to a backend service. |
RequestParameters | String | Yes | Description on parameters of the API request sent by a consumer to the gateway. |
ServiceParameters | String | Yes | Description on parameters of the API request sent by the gateway to a backend service. |
ServiceParametersMap | String | Yes | The mappings between parameters of a request sent by a consumer to the gateway and parameters of a request sent by the gateway to a backend service. |
ResultType | String | Yes | Format of the reply returned by the backend service. Currently, allowed formats are JSON, TEXT, BINARY, XML, and HTML. |
ResultSample | String | Yes | Sample of the reply returned by the backend service. |
FailResultSample | String | No | Sample of the reply failure returned by the backend service. |
ErrorCodeSamples | String | No | Sample of the error code returned by the backend service. |
Return parameters
Name | Type | Description |
---|---|---|
RequestId | String | ID of the current API creation request. |
ApiId | String | ID of the currently created API. |
Examples
Request example
https://apigateway.cn-qingdao.aliyuncs.com/?Action=CreateApi
&GroupId=08ae4aa0f95e4321849ee57f4e0b3077
&ApiName=ApiName
&Visibility=PUBLIC
&Description=Api description
&AuthType=APP
&RequestConfig={"RequestProtocol":"HTTP","RequestHttpMethod":"GET","RequestPath":"/v3/getUserTest/[userId]","BodyFormat":"FORM","PostBodyDescription":""}
&ServiceConfig={"ServiceProtocol":"HTTP","ServiceHttpMethod":"GET","ServiceAddress":"http://www.customerdomain.com","ServiceTimeout":"1000","ServicePath":"/v3/getUserTest/[userId]"}
&RequestParamters=[{"ParameterType":"Number","Required":"OPTIONAL","isHide":false,"ApiParameterName":"age","DefaultValue":"20","DemoValue":"20","Description":"Age","MinValue":18,"MaxValue":100,"Location":"Head"},{"ParameterType":"String","Required":"OPTIONAL","isHide":false,"ApiParameterName":"sex","DefaultValue":"boy","DemoValue":"boy","Description":"Gender","EnumValue":"boy,girl","Location":"Query"},{"ParameterType":"Number","Required":"REQUIRED","isHide":false,"ApiParameterName":"userId","MaxLength":10,"MinValue":10000000,"MaxValue":100000000,"Location":"Path"},{"ApiParameterName":"CaClientIp","ParameterLocation":{"name":"Head","orderNumber":0},"Location":"Head","ParameterType":"String","Required":"REQUIRED","Description":"Client IP address"},{"ApiParameterName":"constance","ParameterLocation":{"name":"Head","orderNumber":0},"Location":"Head","ParameterType":"String","Required":"REQUIRED","DefaultValue":"constance","Description":"constance"}]
&ServiceParameters=[{"ServiceParameterName":"age","Location":"Head","Type":"Number","ParameterCatalog":"REQUEST"},{"ServiceParameterName":"sex","Location":"Query","Type":"String","ParameterCatalog":"REQUEST"},{"ServiceParameterName":"userId","Location":"Path","Type":"Number","ParameterCatalog":"REQUEST"},{"ServiceParameterName":"clientIp","Location":"Head","Type":"String","ParameterCatalog":"SYSTEM"},{"ServiceParameterName":"constance","Location":"Head","Type":"String","ParameterCatalog":"CONSTANT"}]
&ServiceParametersMap=[{"ServiceParameterName":"age","RequestParameterName":"age"},{"ServiceParameterName":"sex","RequestParameterName":"sex"},{"ServiceParameterName":"userId","RequestParameterName":"userId"},{"ServiceParameterName":"clientIp","RequestParameterName":"CaClientIp"},{"ServiceParameterName":"constance","RequestParameterName":"constance"}]
&ResultType=HTML
&ResultSample=200
&<Public request parameters>
Response example
XML
format
<CreateApiResponse>
<RequestId>CEF72CEB-54B6-4AE8-B225-F876FF7BA984</RequestId>
<ApiId>8afff6c8c4c6447abb035812e4d66b65</ApiId>
</CreateApiResponse>
JSON
format
{
"RequestId":"6C87A26A-6A18-4B8E-8099-705278381A2C",
"ApiId":"8afff6c8c4c6447abb035812e4d66b65"
}