# templateMessage.getTemplateLibraryById
Call this API at the server side. For more information, see Server API.
This API supports Cloud Calls. The WeChat DevTools version must be
1.02.1904090
or later (download the latest stable version here), and thewx-server-sdk
version must be0.4.0
or later.
Obtains the keyword library under a template title from the template library.
Calling methods:
# HTTPS Call
# Request Address
POST https://api.weixin.qq.com/cgi-bin/wxopen/template/library/get?access_token=ACCESS_TOKEN
# Request Parameters
Attribute | Type | Default | Required | Description |
---|---|---|---|---|
access_token | string | Yes | Credentials to call API | |
id | string | Yes | The ID of the template title. It can be obtained via the API or the Mini Program backend. |
# Return Value
# Object
JSON data package that is returned
Attribute | Type | Description |
---|---|---|
errcode | number | Error code |
errmsg | string | Error message |
id | string | The ID of the template title |
title | string | The title of the template. |
keyword_list | Array.<Object> | The list of keywords |
keyword_list is composed as follows
Property | Type | Description |
---|---|---|
keyword_id | string | The ID of the keyword. It is required when a template is added. |
name | string | The content of the keyword. |
example | string | An example of the keyword's content. |
# Request Data Example
{
"id": "AT0002"
}
# Return Data Example
{
"errcode": 0,
"errmsg": "ok",
"id": "AT0002",
"title": "Purchase success notification",
"keyword_list": [
{
"keyword_id": 3,
"name": "Purchase location",
"example": "TITShipbuilding factory"
},
{
"keyword_id": 4,
"name": "Purchase time",
"example": "2016-6-6, "
},
{
"keyword_id": 5,
"name": "Item name",
"example": "Coffee"
}
]
}
# Cloud Call
Cloud call is a capability provided by Mini Program·Cloud Base that allows you to call WeChat APIs in a cloud function. It must be used via
wx-server-sdk
in the cloud function.
# API Calling Method
openapi.templateMessage.getTemplateLibraryById
You need to configure the permissions for the
templateMessage.getTemplateLibraryById
API viaconfig.json
. Details
# Request Parameters
Attribute | Type | Default | Required | Description |
---|---|---|---|---|
id | string | Yes | The ID of the template title. It can be obtained via the API or the Mini Program backend. |
# Return Value
# Object
JSON data package that is returned
Attribute | Type | Description |
---|---|---|
errCode | number | Error code |
errMsg | string | Error message |
id | string | The ID of the template title |
title | string | The title of the template. |
keywordList | Array.<Object> | The list of keywords |
keywordList is composed as follows
Property | Type | Description |
---|---|---|
keywordId | string | The ID of the keyword. It is required when a template is added. |
name | string | The content of the keyword. |
example | string | An example of the keyword's content. |
# Exceptions
# Object
Thrown Exceptions
Property | Type | Description |
---|---|---|
errCode | number | Error code |
errMsg | string | Error message |
Valid values of errCode
Value | Description | Minimum Version |
---|
# Request Data Example
const cloud = require('wx-server-sdk')
cloud.init()
exports.main = async (event, context) => {
try {
const result = await cloud.openapi.templateMessage.getTemplateLibraryById({
id: 'AT0002'
})
console.log(result)
return result
} catch (err) {
console.log(err)
return err
}
}
# Return Data Example
{
"errCode": 0,
"errMsg": "openapi.templateMessage.getTemplateLibraryById:ok",
"id": "AT0002",
"title": "Purchase success notification",
"keywordList": [
{
"name": "Purchase location",
"example": "TITShipbuilding factory",
"keywordId": 3
},
{
"name": "Purchase time",
"example": "2016-6-6, ",
"keywordId": 4
},
{
"name": "Item name",
"example": "Coffee",
"keywordId": 5
}
]
}