Calling APIs
Overview
- Obtain an API.
Obtain the API from the service catalog. An API can be called only after it is published.
- (Optional) Create an application and get authorized.
For an API that is accessed using application authentication, you need to create an application and authorize the application to use the API. When you call an API, DataArts DataService verifies your identity based on the key pair (AppKey and AppSecret) of the created application.
- Call the API.
After completing the preceding steps, you can call the API.
(Optional) Creating an App
Perform this operation when the API to be called uses app authentication.
- On the DataArts Studio console, locate an instance and click Access. On the displayed page, locate a workspace and click DataArts DataService.
Figure 1 DataArts DataService
- In the left navigation pane, choose an edition, for example, Exclusive Edition. The Overview page is displayed.
- Choose Table 1. . On the page displayed, click Create. The Create App dialog box is displayed. Set the parameters listed in
- Click OK.
After the application is created, its name and ID are displayed in the application list.
- Click an application name, and view the AppKey and AppSecret on the displayed application details page.
Figure 2 Application details page
(Optional) Authorizing an App to Use an API
Perform this operation when the API to be called uses app authentication.
- On the DataArts Studio console, locate an instance and click Access. On the displayed page, locate a workspace and click DataArts DataService.
Figure 3 DataArts DataService
- In the left navigation pane, choose an edition, for example, Exclusive Edition. The Overview page is displayed.
- Authorize an application to use an API in either of the following ways:
Giving API authorization:
- Choose .
- Locate the row that contains the API to be bound, and click View.
On the page displayed, click Authorize.
- (Optional) If Parameter Location was set to Static for an input parameter during API creation, you must set a static parameter value. If you do not set a value, the default value of the API input parameter is used.
- Set an expiry time, select an application, and click OK.
Applying for authorization:
- Choose API Calling > Service Catalogs to view all the published APIs.
- Click the name of the API you want to bind to an application.
- On the page displayed, click Permission Application.
- (Optional) If Parameter Location was set to Static for an input parameter during API creation, you must set a static parameter value. If you do not set a value, the default value of the API input parameter is used.
- Set an expiry time, select an application, and click OK.
- After the application is submitted, the authorization takes effect only after it is approved in the review center.
- After the authorization is complete, view the bound APIs on the application details page.
- In the API list, if you no longer access an API through the application, click Unbind in the Operation column.
- To test an API to which the application is bound, choose in the Operation column
- To extend the authorization period for the bound API, click Renew.
Calling an API
- App authentication: App authentication is used for calling an API. The AppKey & AppSecret is used for authentication. It is highly secure.
When App authentication is used, an SDK is required for access. Java, Go, Python, JavaScript, C#, PHP, C++, C, and Android SDKs are available. For details about how to call APIs in each language, see Calling APIs Through App Authentication.
- IAM authentication: IAM authenticates API requests. This mode is available only for Huawei cloud users. The security level is medium.
When using IAM authentication, you need to call the Obtaining a User Token API of IAM to obtain a token, add the X-Auth-Token parameter with the obtained token as the value to the request header, and use an API calling tool or SDK to call released APIs.
- Non-authentication: No authentication is required. This mode allows all users to access APIs, which may pose security risks. It is recommended only for testing APIs. If the caller is not a trusted user, there is a risk of data leakage, breakdowns caused by high concurrent access, SQL injection, and others.
This mode does not require any authentication information. You can use an API calling tool or SDK to directly call an API by specifying required parameters.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot