Calling an Open API
Overview
After an API is published in an environment, it can be called by other users. API calling operations vary depending on the authentication mode used by the API.
Obtaining API Request Information
Before calling an API, you need to obtain the API request information from the API provider, including the access domain name, request protocol, request method, request path, and request parameters.
Obtain the request authentication information based on the authentication mode used by an API.
- App:
- Signature authentication: Obtain the key and secret of the integration application (or client AppKey and AppSecret) authorized by the API from the API provider as well as the SDK for calling the API.
- Simple authentication: Obtain the AppCode of the client authorized by the API from the API provider.
- Other authentication modes: Obtain the key and secret of the integration application (or client AppKey and AppSecret) authorized by the API from the API provider.
- IAM: The account credential (password or AK/SK) of the cloud service platform is used for authentication. If the AK/SK is used for authentication, you also need to obtain the SDK for calling the API from the API provider.
- Custom: Obtain the custom authentication information to be carried in the request parameters from the API provider.
- None: No authentication information is required.
- If you use the default subdomain name allocated by the system to access an API, you can access the API for a maximum of 1000 times every day.
- A ROMA Site instance does not support API calling using a subdomain name. It supports API calling only using the combination of IP address and host header.
Calling an API
- Set the parameters related to the request address.
Scenario
API Request Parameter Configuration
Using a domain name to call an API
ROMA Connect allows APIs to be called using the subdomain name assigned to the API group or the domain name bound to the API group. No additional configuration is required.
Using an IP address to call an API in the DEFAULT group
ROMA Connect allows you to use IP addresses to call APIs in the DEFAULT group. No additional configuration is required.
Using an IP address to call an API in groups except DEFAULT
- The app_route parameter described in Modifying Instance Configuration Parameters has been set to on for a ROMA Connect instance, indicating that an API can be called by using an IP address.
- ROMA Connect does not allow APIs in non-DEFAULT groups to be directly called using IP addresses. The header parameter X-HW-ID must be added to the request message, and the value must be the key or client AppKey of the integration application authorized by the API.
- Set the authentication parameters.
API Authentication Mode
API Request Parameter Configuration
App authentication (signature authentication)
Use the obtained SDK to sign the API request. For details, see Using App Authentication to Call APIs.
App authentication (simple authentication)
Add the header parameter X-Apig-AppCode to the API request. The parameter value is the AppCode obtained in Obtaining API Request Information.
App authentication (app_secret authentication)
- The app_secret parameter described in Modifying Instance Configuration Parameters has been set to on (indicating that app_secret authentication is enabled) and app_api_key has been set to off (indicating that app_api_key authentication is disabled) for a ROMA Connect instance.
- Add the header parameter X-HW-ID to the API request. The parameter value is the key of the integration application authorized for the API or the client's AppKey.
- Add the header parameter X-HW-AppKey to the API request. The parameter value is the secret or AppSecret obtained in Obtaining API Request Information.
App authentication (app_basic authentication)
- The app_basic parameter described in Modifying Instance Configuration Parameters has been set to on for a ROMA Connect instance, indicating that app_basic authentication is enabled.
- Add the header parameter Authorization to the API request. The value is "Basic "+base64(appkey+":"+appsecret), in which appkey and appsecret are the key and secret (or AppKey and AppSecret) obtained in Obtaining API Request Information.
App authentication (two-factor authentication)
An API request carries authentication information of both app authentication and custom authentication.
IAM authentication (token authentication)
Obtain the token of the cloud service platform and include the token in the API request for authentication.
IAM authentication (AK/SK authentication)
When calling an API, use the obtained SDK to sign the API request. For details, see AK/SK Authentication.
IAM authentication (two-factor authentication)
An API request carries authentication information of both IAM authentication and custom authentication.
Custom
Based on the definition of custom authentication, the related authentication information is carried in the API request parameters for authentication.
None
No authentication is required, and the API can be directly called.
ROMA Site instances do not support IAM authentication.
Last Article: Calling an API
Next Article: Configuring CORS for APIs
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.