Docs
api
API Summary
Quick Start

Quick Start

Recognition API

Our API adopts an imperative style. Each API request contains an instruction (Action), instruction parameters and authentication information (PublicKey, Signature).

Public Parameters

Public parameters are parameters that must be given when operating all APIs. They are usually displayed at the top of all parameters in the API document.

Parameter NameTypeDescription InformationRequired
ActionstringCorresponding API Command Name,For example DescribeUHostInstanceYes
PublicKeystringUser public key, which can be obtained from Console (opens in a new tab)Yes
SignaturestringUser signature generated based on public key and API command, see Signature AlgorithmYes

General Parameters

General parameters are parameters that may be used by most APIs and have consistent meanings. Whether they need to be given depends on the definition of the specific API.

Parameter NameTypeDescription Information
RegionstringRegion. See Region and Availability Zone List
ZonestringAvailability zone. See Region and Availability Zone List
ProjectIdstringProject ID. If not filled in, it is the default item, and the sub-account must be filled in. See Get project ID

Public Response

The public response is a response style that all APIs follow uniformly, including an instruction response name (Action), a status code to identify whether the API is successful (RetCode), and when an error is encountered, the error message returned (Message ).

Field NameTypeDescription InformationRequired
RetCodeintReturn status code. If it is 0, it means successful return. If it is not 0, it means failure.Yes
ActionstringOperation command nameYes
MessagestringReturns an error message, providing detailed description when RetCode is non-zeroNo

Error Code Explanation

RetCodeDescription
110API response timeout(60Second)
130API gateway or authentication service is abnormal
150The service is currently unavailable, we are working hard to recover, please try again later
153API request is throttled
160Key parameter Action is missing, please provide complete parameters
161Action does not exist
170Missing signature
171Signature error
172User does not exist
174Token does not exist
292The project does not exist
293Availability zone permission error
294Access IP rejected
295Security lock verification failed
299IAM permission verification failed

Quick Start

Preparation Work

  1. Obtain API Access Address
  2. From Control Panel (opens in a new tab) Obtain API Key, Including PublicKey And PrivateKey
  3. If the resource to be operated belongs to a certain region, Get the list of regions and availability zones
  4. If the account is a sub-account, or need to operate a specific project, Fetch Project ID

Initiate Request

You can make requests to the API access address in a variety of ways, including clients such as cURL (opens in a new tab), Postman (opens in a new tab), etc.

Our API supports two methods: GET / POST, and supports two request methods: application/json and application/x-www-form-urlencoded.

This article takes cURL POST JSON as an example to describe how to construct and initiate an HTTP request.

Data Assumption

In this example it is assumed:

PublicKey  = 'someone@example.com1296235120854146120'
PrivateKey = '46f09bb9fab4f12dfc160dae12273d5332b5debe'

Assume that the user request parameters are as follows:

{
    "Action"     :  "DescribeUHostInstance",
    "Region"     :  "cn-bj2",
    "Limit"      :  10
}

Calculate Signature

Please refer to the Signature Algorithm document. The calculated Signature is cba5cf5ec4d4233d206b1b54951e3787350a642f.

Construct Request

Fill in the request parameters with PublicKey and Signature, and the constructed request will finally be:

curl -X POST \
  https://api.ucloud-global.com \
  -H 'Content-Type: application/json' \
  -d '{
      "Action"     :  "DescribeUHostInstance",
      "Limit"      :  10,
      "PublicKey"  :  "someone@example.com1296235120854146120",
      "Region"     :  "cn-bj2",
      "Signature"  :  "cba5cf5ec4d4233d206b1b54951e3787350a642f"
  }'