After an API operation is published, users can call the API operation in applications by using the SDK downloaded from API Gateway. This topic describes how to call API operations in applications.
- An API operation is published. Only published API operations can be called.
- An application is available. API operations are called in applications. Therefore, you must create an application in API Gateway. The application will be assigned an identity that you can use to call API operations. For each API operation, the data service module of DMS creates a default application, with a corresponding identity that the API owner can use to call the API operation in the default application. For more information about applications, see App.
- The application is authorized to call the API operation. When an API operation is published, DMS automatically authorizes the default application of the API owner to call the API operation.
Log on to the API Gateway console. In the left-side navigation pane, choose Consume APIs > Authorized APIs SDK. The Authorized APIs SDK Auto-Generation page appears.
Find DMS_DEFAULT_APP, the default application created by DMS, and click the buttons in the Authorized APIs SDK Auto-Generation column to download SDKs and documents in various coding languages, including Java and development languages for operating systems such as iOS and Android.
- To download SDKs and documents in other coding languages, such as PHP, Node.js, Python, and .NET, see examples in the Other Language Example section.
- To download SDKs and documents of API operations that are purchased and authorized through other channels such as Alibaba Cloud API Marketplace, see Obtain API documentation.
- To access resources in API Gateway, RAM users must be authorized by the corresponding Alibaba Cloud accounts. API Gateway provides two authorization policies. The AliyunApiGatewayFullAccess policy grants management permissions, and the AliyunApiGatewayReadOnlyAccess policy grants the read-only permission. For more information about how to authorize RAM users, see ApiGateway_RAM.
Log on to the DMS console. In the top navigation bar, choose Data Factory > Data Service. On the page that appears, click API Call in the left-side navigation pane. On the API calls page, find the identity information that corresponds to the API call authentication method that you want to use.
- Simple identity authentication requires only an AppCode. This authentication method is suitable for calling API operations by using URLs instead of in programming environments. This authentication method has a low security level and is generally used in scenarios where data visualization is involved, such as calling API operations in DataV.
- Encrypted signature identity authentication requires an AppKey and an AppSecret, which are used by the system to automatically generate an encrypted signature for calling an API operation. This authentication method has a high security level. For more information about how to generate a signature for calling an API operation in an application, see API Gateway call documentation.
Obtain the permission to call the API operation.
- If you own the API operation, skip this step because DMS automatically authorizes your default application to access the API operation when the API operation is published.
- If the API operation you want to call is owned by others, you need to obtain the permission to call the API operation. For more information, see Obtain permission.
Use the SDKs to call the API operation in the application.