const { tlsOpenapi } = require('@volcengine/openapi');
const tlsOpenapiService = tlsOpenapi.defaultService;
tlsOpenapiService.setHost('your host');
tlsOpenapiService.setSecretKey('your secret key');
tlsOpenapiService.setAccessKeyId('your access key id');
const project = await tlsOpenapiService.CreateProject({
ProjectName: 'your project name',
Region: 'project belong to which region',
const topic = await tlsOpenapiService.CreateTopic({
ProjectId: 'your project id',
ShardCount: 'your shard count',
TopicName: 'your topic name',
const index = await tlsOpenapiService.CreateIndex({
TopicId: 'your topic id',
FullText: 'your full-text config',
KeyValue: 'your kv config',
// Use the objToProtoBuffer method to convert structured log data to Protobuf log data.
const logBuffer = await tlsOpenapi.TlsService.objToProtoBuffer({
Contents: [{ Key: 'content key', Value: 'key value' }]
LogTags: [{ Key: 'tag key', Value: 'key value' }],
ContextFlow: 'context flow',
// The PutLogs API action accepts TopicId, CompressType, and LogGroupList as input parameters to upload log data to TLS. Note that LogGroupList specifies logs in Protobuf format.
const putLogsResult = await tlsOpenapiService.PutLogs({
TopicId: 'your topic id',
CompressType: 'log compress type',
LogGroupList: logBuffer,
const searchLogsResult = await tlsOpenapiService.SearchLogs({
StartTime: 'log start time',
EndTime: 'log end time',
TopicId: 'your topic id',