edit-icon download-icon

Call an API

Last Updated: Nov 10, 2017

Based on the SDKs provided by the API Gateway, you can write codes to call an API. API Gateway provides SDKs of the mainstream languages for the Web client and mobile client and continuously provides SDKs of more language types. You can also edit an HTTP request to call an API.

Through the preceding steps, you can obtain the domain name, path, and parameter description from the service provider. The created app is used as your requester identity. The AppKey and AppSecret are used for calculating the encrypted signature. The demo link for signature calculation is as follows:

After your app has been authorized, you can call the API. The API request structure is as follows:

//If the service address is a13db7999e494a90819cce500130034d.com.

//If the path is /web/cloudapi/mapping/service.

//If the query content is a=name, b=12.

//Then the URL of the request is as follows:

  1. http://a13db7999e494a90819cce500130034d.com/web/cloudapi/mapping/service£¿a=name&b=12

//Requesting method.

  1. POST HttpMethod: POST

//Headers must include signature information and certain parameters.

  1. X-Ca-Version: 1 //API version
  2. X-Ca-Signature-Headers: X-Ca-Version,X-Ca-Key,X-Ca-Stage,X-Ca-Timestamp //Headers involved in signature calculation
  3. X-Ca-Key: 60028305 //AppKey
  4. X-Ca-Stage: test //Stage
  5. X-Ca-Timestamp: 1456905123049 //Time stamp
  6. X-Ca-Signature: UAaH/qteir4G9UK4YR+NWdyq+c1rjl0PvtO/C1Qo68U= //Signature

//Standard HTTP header.

  1. Host: a13db7999e494a90819cce500130034d.com //Service address
  2. Date: Wed 02 Mar 2016 07:52:02 GMT
  3. User-Agent: Apache-HttpClient/4.1.2 (java 1.6)
  4. Content-Type: application/x-www-form-urlencoded; charset=utf-8

//Body content.

  1. Amount=11&InstanceId=ClientInstanceId&InstanceName=ClientInstanceName

When you call an API, either the HTTP or HTTPS request must include signature information. The AppKey indicates your identity. The AppSecret is the key used to encrypt the signature string and verify the signature string on the server. For more information about the methods of calculating and passing the encrypted signature, see Portal and Protocol.

For more information, see User Manual (Call an API).

Thank you! We've received your feedback.