全部产品
Search
文档中心

API 网关:查询 API 定义

更新时间:Aug 15, 2022

描述

查询API定义

  • 此接口面向开放API的用户

  • 用于查询指定API的定义

请求参数

名称

类型

是否必须

描述

Action

String

操作接口名,系统规定参数,取值:DescribeApi

GroupId

String

API所在的分组编号

ApiId

String

API的Id标识

返回参数

名称

类型

描述

RequestId

String

本次创建API的请求Id

RegionId

String

API所处的Region的Id

ApiId

String

API的Id标识

ApiName

String

API的名称,组内不允许重复

GroupId

String

API所在的分组编号

GroupName

String

API所在的分组名称

Visibility

String

API是否公开,目前可以取值:

  • PUBLIC:公开,如选择此类型,该API的线上环境,会在所有用户的控制台“发现API”页面展示

  • PRIVATE:不公开,如选择此类型,当该组API在云市场上架时,私有类型的API不会上架

AuthType

String

API安全认证类型,目前可以取值:

  • APP:只允许已授权的APP调用

  • ANONYMOUS:允许匿名调用,设置为允许匿名调用需要注意:

    • 任何能够获取该API服务信息的人,都将能够调用该API。网关不会对调用者做身份认证,也无法设置按用户的流量控制,若开放该API请设置好按API的流量控制。

    • “ANONYMOUS”API不建议上架云市场,网关无法对调用者区分计量,也无法限制调用次数,若所在分组要上架云市场,建议将该API转移至其他分组,或将类型设置为“私有”,或选择“阿里云APP”认证方式。

  • APPOPENID:支持第三方账号认证OpenID Connect,而且只允许已授权的APP调用;当设置此项时,参数OpenIdConnectConfig为必传。

ForceNonceCheck

Boolean

调用API时是否必须携带header : X-Ca-Nonce, 这个是请求的唯一标识,一般使用UUID来标识。API网关收到这个参数后通过校验这个参数的有效性可以有效防止API的重放攻击,同样的值,15分内只能被使用一次。 取值:

  • true: 请求API时强制检查这个字段,防止API的重放攻击

  • false: 不检查这个字段

DisableInternet

Boolean

API是否仅支持内网调用, 取值:

  • true:仅支持内网调用API

  • false:不限制调用

ResultType

String

后端服务返回应答的格式,目前可以设置为:JSON、TEXT、BINARY、XML、HTML

ResultSample

String

后端服务返回应答的示例

FailResultSample

String

后端服务失败返回应答的示例

CreateTime

String

API创建的时间

ModifyTime

String

API最后一次修改的时间

Description

String

API描述信息

ErrorCodeSamples

ErrorCodeSample

后端服务返回的错误码示例。

SystemParameters

SystemParameter

网关发送给后端服务的系统参数。

ConstantParameters

ConstantParameter

网关发送给后端服务的常量参数。

RequestParametersObject

RequestParameter

Consumer向网关发送API请求的参数描述。

ServiceParametersObject

ServiceParameters

网关向后端服务发送API请求的参数描述。

ParametersMapObject

ServiceParametersMap

Consumer向网关发送请求的参数和网关向后端服务发送的请求的参数的映射关系。

DeployedInfos

DeployedInfo

API发布状态。

RequestConfig

RequestConfig

Consumer向网关发送API请求的相关配置项。

ServiceConfig

ServiceConfig

网关向后端服务发送API请求的相关配置项。

OpenIdConnectConfig

OpenIdConnectConfig

第三方账号认证OpenID Connect相关配置项。

FunctionComputeConfig

FunctionComputeConfig

后端为函数计算时的后端配置项

示例

请求示例

https://apigateway.cn-qingdao.aliyuncs.com/?Action=DescribeApi
&ApiId=8afff6c8c4c6447abb035812e4d66b65

&<公共请求参数>

返回示例

XML格式

<DescribeApiResponse>
    <RequestId>D0FF585F-7966-40CF-BC60-75DB070B23D5</RequestId>
    <RegionId>cn-qingdao</RegionId>
    <Description>Api description</Description>
    <ApiName>ApiName</ApiName>
    <CreatedTime>2016-07-28T09:50:43Z</CreatedTime>
    <GroupName>ApiTest</GroupName>
    <ModifiedTime>2016-07-28T13:13:12Z</ModifiedTime>
    <ServiceParametersObject>
        <ServiceParam>
            <ServiceParameterName>age</ServiceParameterName>
            <Type>Number</Type>
            <Location>head</Location>
        </ServiceParam>
        <ServiceParam>
            <ServiceParameterName>sex</ServiceParameterName>
            <Type>String</Type>
            <Location>query</Location>
        </ServiceParam>
        <ServiceParam>
            <ServiceParameterName>userId</ServiceParameterName>
            <Type>Number</Type>
            <Location>path</Location>
        </ServiceParam>
        <ServiceParam>
            <ServiceParameterName>clientIp</ServiceParameterName>
            <Type>String</Type>
            <Location>head</Location>
        </ServiceParam>
        <ServiceParam>
            <ServiceParameterName>constance</ServiceParameterName>
            <Type>String</Type>
            <Location>head</Location>
        </ServiceParam>
    </ServiceParametersObject>
    <ConstantParameters>
        <ConstantParameter>
            <ServiceParameterName>constance</ServiceParameterName>
            <Description>constance</Description>
            <Location>HEAD</Location>
            <ConstantValue>constance</ConstantValue>
        </ConstantParameter>
    </ConstantParameters>
    <GroupId>08ae4aa0f95e4321849ee57f4e0b3077</GroupId>
    <SystemParameters>
        <SystemParameter>
            <ServiceParameterName>clientIp</ServiceParameterName>
            <Description>客户端IP</Description>
            <DemoValue>192.168.1.1</DemoValue>
            <Location>HEAD</Location>
            <ParameterName>CaClientIp</ParameterName>
        </SystemParameter>
    </SystemParameters>
    <RequestParametersObject>
        <RequestParam>
            <Required>OPTIONAL</Required>
            <MinValue>18</MinValue>
            <Description>年龄</Description>
            <DemoValue>20</DemoValue>
            <ParameterType>NUMBER</ParameterType>
            <ApiParameterName>age</ApiParameterName>
            <DocShow>PUBLIC</DocShow>
            <DefaultValue>20</DefaultValue>
            <Location>HEAD</Location>
            <MaxValue>100</MaxValue>
            <DocOrder>0</DocOrder>
        </RequestParam>
        <RequestParam>
            <Required>OPTIONAL</Required>
            <Description>性别</Description>
            <DemoValue>boy</DemoValue>
            <ParameterType>STRING</ParameterType>
            <ApiParameterName>sex</ApiParameterName>
            <DocShow>PUBLIC</DocShow>
            <DefaultValue>boy</DefaultValue>
            <Location>QUERY</Location>
            <EnumValue>boy,girl</EnumValue>
            <DocOrder>0</DocOrder>
        </RequestParam>
        <RequestParam>
            <Required>REQUIRED</Required>
            <MinValue>10000000</MinValue>
            <ParameterType>NUMBER</ParameterType>
            <ApiParameterName>userId</ApiParameterName>
            <DocShow>PUBLIC</DocShow>
            <Location>PATH</Location>
            <MaxValue>100000000</MaxValue>
            <DocOrder>0</DocOrder>
        </RequestParam>
    </RequestParametersObject>
    <DeployedInfos>
        <DeployedInfo>
            <DeployedStatus>NONDEPLOYED</DeployedStatus>
            <StageName>TEST</StageName>
        </DeployedInfo>
        <DeployedInfo>
            <DeployedStatus>NONDEPLOYED</DeployedStatus>
            <StageName>RELEASE</StageName>
        </DeployedInfo>
    </DeployedInfos>
    <ServiceConfig>
        <ServiceProtocol>HTTP</ServiceProtocol>
        <ServiceTimeout>1000</ServiceTimeout>
        <ServiceAddress>http://www.customerdomain.com</ServiceAddress>
        <ServicePath>/v3/getUserTest/[userId]</ServicePath>
        <ServiceHttpMethod>GET</ServiceHttpMethod>
        <Mock>FALSE</Mock>
    </ServiceConfig>
    <RequestId>D0FF585F-7966-40CF-BC60-75DB070B23D5</RequestId>
    <RegionId>cn-qingdao</RegionId>
    <RequestConfig>
        <RequestHttpMethod>GET</RequestHttpMethod>
        <RequestProtocol>HTTP</RequestProtocol>
        <RequestPath>/v3/getUserTest/[userId]</RequestPath>
    </RequestConfig>
    <Visibility>PUBLIC</Visibility>
    <ParametersMapObject>
        <ServiceParameterMap>
            <ServiceParameterName>sex</ServiceParameterName>
            <RequestParameterName>sex</RequestParameterName>
        </ServiceParameterMap>
        <ServiceParameterMap>
            <ServiceParameterName>age</ServiceParameterName>
            <RequestParameterName>age</RequestParameterName>
        </ServiceParameterMap>
        <ServiceParameterMap>
            <ServiceParameterName>userId</ServiceParameterName>
            <RequestParameterName>userId</RequestParameterName>
        </ServiceParameterMap>
    </ParametersMapObject>
    <ErrorCodeSamples>
        <ErrorCodeSample>
            <Code>400</Code>
            <Message>Missing the parameter UserId</Message>
            <Description>请求缺少参数 UserId</Description>
        </ErrorCodeSample>
    </ErrorCodeSamples>
    <ApiId>8afff6c8c4c6447abb035812e4d66b65</ApiId>
    <AuthType>APP</AuthType>
    <ForceNonceCheck>true</ForceNonceCheck>
    <DisableInternet>true</DisableInternet>
    <ResultType>HTML</ResultType>
    <ResultSample>200</ResultSample>
    <FailResultSample>400</FailResultSample>
    <OpenIdConnectConfig>
        <publicKey>EB1837F8693CCED0BF750B3AD48467BEB569E780A14591CF92</publicKey>
        <openIdApiType>IDTOKEN</openIdApiType>
        <publicKeyId>88483727556929326703309904351185815489</publicKeyId>
    </OpenIdConnectConfig>    
</DescribeApiResponse>

JSON格式

{
    "RequestId":D0FF585F-7966-40CF-BC60-75DB070B23D5,
    "RegionId":cn-qingdao,
    "Description": "billingTest001",
    "ApiName": "billingTest001",
    "CreatedTime": "2016-07-01T09:18:20Z",
    "GroupName": "billingTest",
    "ModifiedTime": "2016-07-21T03:52:12Z",
    "ServiceParametersObject": {
        "ServiceParam": [
            {
                "ServiceParameterName": "headerParam",
                "Type": "String",
                "Location": "head"
            },
            {
                "ServiceParameterName": "queryparam",
                "Type": "String",
                "Location": "query"
            },
            {
                "ServiceParameterName": "NumberParam",
                "Type": "Number",
                "Location": "query"
            },
            {
                "ServiceParameterName": "type",
                "Type": "String",
                "Location": "path"
            },
            {
                "ServiceParameterName": "clientIp",
                "Type": "String",
                "Location": "head"
            },
            {
                "ServiceParameterName": "constantParam",
                "Type": "String",
                "Location": "query"
            }
        ]
    },
    "ConstantParameters": {
        "ConstantParameter": [
            {
                "ServiceParameterName": "constantParam",
                "Description": "constant",
                "Location": "QUERY",
                "ConstantValue": "constant"
            }
        ]
    },
    "GroupId": "4a3f3050b9c5469bb685bdd29e571be1",
    "SystemParameters": {
        "SystemParameter": [
            {
                "ServiceParameterName": "clientIp",
                "Description": "客户端IP",
                "DemoValue": "192.168.1.1",
                "Location": "HEAD",
                "ParameterName": "CaClientIp"
            }
        ]
    },
    "RequestParametersObject": {
        "RequestParam": [
            {
                "Required": "OPTIONAL",
                "Description": "head param",
                "DemoValue": "headparm",
                "ParameterType": "STRING",
                "ApiParameterName": "headerParam",
                "DocShow": "PUBLIC",
                "DefaultValue": "",
                "Location": "HEAD",
                "EnumValue": "head",
                "DocOrder": 0
            },
            {
                "Required": "REQUIRED",
                "ParameterType": "STRING",
                "ApiParameterName": "queryparam",
                "DocShow": "PUBLIC",
                "DefaultValue": "",
                "Location": "QUERY",
                "DocOrder": 0
            },
            {
                "Required": "OPTIONAL",
                "MinValue": 1,
                "Description": "number param",
                "DemoValue": "10",
                "ParameterType": "NUMBER",
                "ApiParameterName": "NumberParam",
                "DocShow": "PUBLIC",
                "DefaultValue": "10",
                "Location": "QUERY",
                "MaxValue": 100,
                "DocOrder": 0
            },
            {
                "Required": "REQUIRED",
                "ParameterType": "STRING",
                "ApiParameterName": "type",
                "DocShow": "PUBLIC",
                "Location": "PATH",
                "DocOrder": 0
            }
        ]
    },
    "DeployedInfos": {
        "DeployedInfo": [
            {
                "DeployedStatus": "NONDEPLOYED",
                "StageName": "TEST"
            },
            {
                "DeployedStatus": "DEPLOYED",
                "StageName": "RELEASE",
                "EffectiveVersion": "20160721115223375"
            }
        ]
    },
    "ServiceConfig": {
        "ServiceProtocol": "HTTP",
        "ServiceTimeout": 10000,
        "ServiceAddress": "http://120.55.XX.XX:8080",
        "ServicePath": "/web/cloudapi/[type]",
        "ServiceHttpMethod": "POST",
        "Mock": "CLOSED"
    },
    "RequestId": "415F037A-94C2-4100-B17A-F3C514CA1391",
    "RegionId": "cn-qingdao",
    "RequestConfig": {
        "RequestHttpMethod": "POST",
        "RequestProtocol": "HTTP",
        "PostBodyDescription": "fwefwef",
        "BodyFormat": "STREAM",
        "RequestPath": "/api/billing/test/[type]"
    },
    "Visibility": "PUBLIC",
    "ParametersMapObject": {
        "ServiceParameterMap": [
            {
                "ServiceParameterName": "headerParam",
                "RequestParameterName": "headerParam"
            },
            {
                "ServiceParameterName": "queryparam",
                "RequestParameterName": "queryparam"
            },
            {
                "ServiceParameterName": "NumberParam",
                "RequestParameterName": "NumberParam"
            },
            {
                "ServiceParameterName": "type",
                "RequestParameterName": "type"
            }
        ]
    },
    "ErrorCodeSamples": {
        "ErrorCodeSample": [
            {
                "Code": "400",
                "Message": "Missing the parameter UserId",
                "Description": "请求缺少参数 UserId"
            }
        ]
    },
    "ApiId": "e77fd9257b1d436a806fe23c649300a0",
    "AuthType": "APP",
    "ForceNonceCheck": true,
    "DisableInternet": true,
    "ResultType": "JSON",
    "ResultSample": "fwef",
    "FailResultSample": "400",
    "OpenIdConnectConfig": {
        "publicKey": "EB1837F8693CCED0BF750B3AD48467BEB569E780A14591CF92",
        "openIdApiType": "IDTOKEN",
        "publicKeyId": "88483727556929326703309904351185815489"
    }
}