This API is used to search for a web page on the Internet by keyword entered. A list of web pages related to the keyword will be returned.
Protocol | HTTPS GET |
|---|---|
Direction | Developer server -> Huawei search server |
URL | https://{rootUrl}/apis/search/v1.0.0/web/search NOTE: {rootUrl}: For details, please refer to Site Information. |
Data Format | Request: Content-Type: application/json Response: Content-Type: application/json |
Parameter | Mandatory/Optional | Type | Description |
|---|---|---|---|
q | Mandatory | String | Search keyword. |
lang | Optional | String | Supported search languages. For details, please refer to Language Codes. The default value is en. |
sregion | Optional | String | Supported search regions. For details, please refer to Region Codes. The default value is ww. |
pn | Optional | Integer | Number of a search result page. The value ranges from 1 to 100, and the default value is 1. |
ps | Optional | Integer | Number of search results on a page. The value ranges from 1 to 100, and the default value is 10. |
Request Header
Parameter | Mandatory/Optional | Type | Description |
|---|---|---|---|
Accept | Mandatory | String | The value is application/json. |
Content-Type | Mandatory | String | The value is application/json. |
Authorization | Mandatory | String | Access token that you dynamically obtain. NOTE: A space character must be added between Bearer and the value of access_token. |
X-Kit-AppID | Mandatory | String | App ID and token returned in the credential that you obtain from HUAWEI Developers. |
X-Kit-ClientIP | Optional | String | IP address of a user device. You are advised to pass it for localization when connecting to the Search Kit server. |
X-Kit-RequestID | Optional | String | Unique ID of a request. (You can specify this ID. If no ID is specified, the default value is used.) |
Request Body
None.
GET https://{rootUrl}/apis/search/v1.0.0/web/search?q=<query>
Content-Type:application/json
Accept:application/json
Authorization:Bearer {access_token}
X-Kit-AppID:{appid} If the value of query is test, and the app ID appidforexample, domain name (rootUrl) search-forexample.cloud.huawei.com, and access token Access1Token/For2Example are used as examples, the request is as follows:
GET https://search-forexample.cloud.huawei.com/apis/search/v1.0.0/web/search?q=test Content-Type:application/json Accept:application/json Authorization:Bearer Access1Token/For2Example X-Kit-AppID:appidforexample
When the status code is 200:
Response Header
None.
Response Body
Parameter | Mandatory/Optional | Type | Description |
|---|---|---|---|
request_id | Mandatory | String | Request ID, which is the same as the value of X-Kit-RequestID in the request header. If the request does not carry X-Kit-RequestID, an ID will be generated on the server. |
data | Mandatory | Array[WebItem] | Web page search result. |
query_lang | Mandatory | String | Language determined based on query. |
When the status code is not 200:
Response Header
None.
Response Body
Parameter | Mandatory/Optional | Type | Description |
|---|---|---|---|
code | Mandatory | String | Error code. For details, please refer to Error Codes. |
msg | Mandatory | String | Error information. For details, please refer to Description. |
request_id | Mandatory | String | Request ID, which is the same as the value of X-Kit-RequestID in the request header. If the request does not carry X-Kit-RequestID, an ID will be generated on the server. |
HTTP/1.1 200 OK
Content-type: application/json
{
"data": {search result},
"request_id": {X-Kit-RequestID}
} curl -X GET -H 'Content-Type:application/json' -H 'X-Kit-AppID:{{app id}}' -H 'Authorization:Bearer {{Access_Token}}' -H 'Accept:application/json' {{domain name}}/apis/search/v1.0.0/web/search?q={{query}} Assume that the app ID in the request is 123456, the access token obtained for this request is Access1Token/For2Example, the obtained domain name is https://search-dre.cloud.huawei.com, and the value of {query} is test. The call request is as follows:
curl -X GET -H 'Content-Type:application/json' -H 'X-Kit-AppID:123456' -H 'Authorization:Bearer Access1Token/For2Example' -H 'Accept:application/json' https://search-dre.cloud.huawei.com/apis/search/v1.0.0/web/search?q=test