KA Search
Authentication Instructions
1.1 X-TOKEN Calculation
Input Parameters:
1. Data Body: data = {"xxxx": "xxxx"} or {}
2. External Secret: secret = "iamsecret"
3. API Path: api_path = "/xxx/xxx?xx=xxx" (excluding host)
Calculation Steps:
1. Convert the api_path to lowercase: lower_api_path.
2. Convert the request method to lowercase: lower_method (e.g., "get", "post").
3. Convert the data into a sorted JSON string without spaces: sort_json_str. (Example in Python: json.dumps(dict(data), sort_keys=True).replace(' ', '')).
4. Concatenate the strings in the following order: lower_api_path + lower_method + sort_json_str + secret + X-TIMESTAMP.
A. X-TIMESTAMP: Unix timestamp in seconds. It is valid for 60 seconds.
B. Sign Result: /xxx/xxx?xx=xxxpost{"xxxx":"xxxx"}iamsecret1489133053
5. Encode the sign string in UTF-8 and calculate the MD5 hash to obtain the X-TOKEN: ddc6457fd0b373475ac65912b797ef05.
1.2 API Call Headers
When calling the interface, the following headers must be included:
X-APP-ID: Application AK (appId)
X-TIMESTAMP: Unix timestamp in seconds
X-TOKEN: Calculated signature result
1.3 Authentication Demo Code (Python)
import time
import json
import hashlib
import requests
from urllib.parse import urljoin
def encode_with_md5(s):
m = hashlib.md5()
m.update(s.encode('utf-8'))
return m.hexdigest()
def headers_need_sign(ak, secret, method, url, data):
headers = {}
t = int(time.time())
# Format data into a compact, sorted JSON string
data_str = json.dumps(dict(data), sort_keys=True).replace(' ', '')
# Concatenate: path + method + data + secret + timestamp
ori_sign = '{0}{1}{2}{3}{4}'.format(url.lower(), method.lower(), data_str, secret, t)
sign = encode_with_md5(ori_sign)
headers["X-APP-ID"] = ak
headers["X-TOKEN"] = sign
headers["X-TIMESTAMP"] = str(t)
return headers
if __name__ == '__main__':
ak = 'your_app_id'
secret = 'your_app_secret'
method = 'POST'
host = 'https://nebula-agent.xingyun3d.com'
url = '/xxx/xxx?x=xx&z=zz'
req_data = {
"data1": "value1",
"data2": "value2",
}
# Calculate headers
req_headers = headers_need_sign(ak, secret, method, url, req_data)
# Execute request
req_url = urljoin(host, url)
resp = requests.request(method, req_url, json=req_data, headers=req_headers)
KA Action Query API Call
2.1 Query Interface
Host: https://nebula-agent.xingyun3d.com
Request Path: GET: /user/v1/external/lite_ka_summary
Request Parameters: None
Response Parameters:
Level 1 Param | Level 2 Param | Type | Name | Remarks |
|---|---|---|---|---|
error_code | int | Error Code | 0: Success; Others: Error | |
error_reason | string | Error Reason | ||
data | dict | Data | ||
name | string | Action Name | Example: M_CN03_show03__PointingSelf. When used in the speak method, only the last part is needed. Example: | |
cn_name | string | Action Chinese Name | ||
ka_type | string | Action Type | ||
render_image_oss | string | Action Image Path | ||
render_movie_oss | string | Action Animation Path |
Full API Code Example
# -- coding: utf-8 --
import time
import json
import hashlib
import requests
from urllib.parse import urljoin
def encode_with_md5(s):
m = hashlib.md5()
m.update(s.encode('utf-8'))
return m.hexdigest()
def headers_need_sign(ak, secret, method, url, data):
headers = {}
t = int(time.time())
# Sort and compress JSON data
data_str = json.dumps(dict(data), sort_keys=True).replace(' ', '')
# Signature concatenation
ori_sign = '{0}{1}{2}{3}{4}'.format(url.lower(), method.lower(), data_str, secret, t)
sign = encode_with_md5(ori_sign)
headers["X-APP-ID"] = ak
headers["X-TOKEN"] = sign
headers["X-TIMESTAMP"] = str(t)
return headers
if __name__ == '__main__':
# Enter your digital human appId and appSecret here
ak = '64b544633a474b4d9a5abec1e0df7a49'
secret = '9d69026e57c34e05a454706d110ea338'
method = 'GET'
host = 'https://nebula-agent.xingyun3d.com'
url = '/user/v1/external/lite_ka_summary'
req_data = {}
# Generate authentication headers
req_headers = headers_need_sign(ak, secret, method, url, req_data)
# Call the KA query interface
req_url = urljoin(host, url)
resp = requests.request(method, req_url, json=req_data, headers=req_headers)
# Print the returned KA list content
print(resp.content)