May 20, 2021 WeChat Mini Program Development Document
This interface should be called on the server side, as detailed in the Service Side API.
This interface supports cloud calls. Developer tool version required . . . 1.02.1904090 (latest stable download)
wx-server-sdk >= 0.4.0
The small program internal search API provides the ability to query for pages, and when the small program developer enters the search term, he or she returns the page related to the small program and the search term. Therefore, the interface allows developers to view the content of the specified content of the page by WeChat platform inges, at the same time, the interface can also be used by developers in small programs, to provide small program users with search capabilities.
How to call:
POST https://api.weixin.qq.com/wxa/sitesearch?access_token=TOKEN
Property | Type | The default | Required | Description |
---|---|---|---|---|
access_token | string | Is | The interface calls the credentials | |
keyword | string | Is | Keywords | |
next_page_info | string | Is | Request the parameters for the next page, which the developer does not need to understand. The empty-time query is the first page of content, if you need to query the next page, the return parameters of the next_page_info fill here |
The returned JSON packet
Property | Type | Description |
---|---|---|
errcode | string | Error code |
errmsg | string | The error message |
items | Array.<Object> | A list of search results |
has_next_page | boolean | Whether there is a next page |
next_page_info | string | Request the parameters of the next page, the developer does not need to understand, if you need to query the next page results, the parameters are populated into the next page request next_page_info parameters |
hit_count | number | Estimate the number of index files |
Errcode's legitimate value
value | illustrate | Minimum version |
---|---|---|
-1 | The system is busy, please developers will try again later. | |
47101 | The total number of search results exceeded 1,000 | |
47102 | Next_page_info parameter error |
Items structure
Attributes | type | illustrate |
---|---|---|
title | string | Small program page title |
description | string | Small program page summary |
image | string | A small program page representative |
path | string | Small program page path |
curl -d '
{
"query": "微信",
"next_page_info": ""
}' https://api.weixin.qq.com/wxa/sitesearch?access_token=TOKEN
{
"errcode":0,
"errmsg":"ok",
"items": [
{
"title": "<em class="highlight">微信</em>版本更新!",
"description": "...今日,<em class="highlight">微信</em>官方发布<em class="highlight">微信</em>X.Y.Z版本...",
"image": "http://image.weixin.qq.com/1.jpeg",
"path": "pages/normal/index?id=20191210A0C29X00"
},
{
"title": "<em class="highlight">微信</em>小程序发布新功能!",
"description": "<em class="highlight">微信</em>小程序发布了XXX功能...",
"image": "http://image.weixin.qq.com/2.jpeg",
"path": "pages/normal/index?id=20191210A0C29X11"
},
],
"has_next_page": 1,
"hit_count": 100,
"next_page_info":"eyJwYWdlX3BhcmFtIjpbeyJzdWJzeXNfdHlwZSI6MTAsInNlcnZlcl9vZmZzZXQiOjAsInNlcnZlcl9saW1pdCI6MTIwLCJpbmRleF9zdGVwIjoyMCwiaW5kZXhfb2Zmc2V0IjoyMH1dLCJjbGllbnRfb2Zmc2V0IjowLCJjbGllbnRfbGltaXQiOjEwfQ=="
}
Cloud call is the ability provided by the small program Cloud Development to call WeChat open interfaces in cloud functions and need to be used in cloud functions via wx-server-sdk.
openapi.search.siteSearch
The permissions for the search.siteSearch API need to be configured in config.json, details
Property | Type | The default | Required | Description |
---|---|---|---|---|
keyword | string | Is | Keywords | |
nextPageInfo | string | Is | Request the parameters for the next page, which the developer does not need to understand. The empty-time query is the first page of content, if you need to query the next page, the return parameters of the next_page_info fill here |
The returned JSON packet
Property | Type | Description |
---|---|---|
errCode | string | Error code |
errMsg | string | The error message |
items | Array.<Object> | A list of search results |
hasNextPage | boolean | Whether there is a next page |
nextPageInfo | string | Request the parameters of the next page, the developer does not need to understand, if you need to query the next page results, the parameters are populated into the next page request next_page_info parameters |
hitCount | number | Estimate the number of indexed documents |
The legal value of errCode
Value | Description | The lowest version |
---|---|---|
0 | Success |
The structure of the items
Property | Type | Description |
---|---|---|
title | string | The title of the small program page |
description | string | Summary of the small program page |
image | string | The small program page represents the diagram |
path | string | The path to the small program page |
The exception thrown
Property | Type | Description |
---|---|---|
errCode | string | Error code |
errMsg | string | The error message |
The legal value of errCode
Value | Description | The lowest version |
---|---|---|
-1 | The system is busy, so please try again later | |
47101 | The total number of search results exceeds 1000 | |
47102 | next_page_info parameters are incorrect |