POST https://lxapi.lexiangla.com/cgi-bin/v1/docs
document
{
"data":{
"type":"doc",
"attributes":{
"title":"通过开放接口创建的文档",
"content":"<h1>富文本内容</h1>",
"is_markdown":0,
"privilege_type":1,
"source":"reship",
"reship_url":"https://lexiangla.com",
"signature":"Peter Chan",
"allow_comment":1,
"picture_url":"https://lexiangla.com/assets/123",
"only_team":0,
"enable_image_watermark":1,
"enable_watermark":1,
"enable_copy_limit":1,
"tags": [
"666666",
"77777777"
]
},
"relationships":{
"category":{
"data":{
"type":"category",
"id":"uuid123"
}
},
"team":{
"data":{
"type":"team",
"id":"uuid123"
}
},
"directory":{
"data":{
"type":"directory",
"id":"uuid123"
}
},
"privilege": {
"data": [
{
"type": "staff",
"id": "ThreeZhang"
},
{
"type": "department",
"id": 1
}
]
},
"attachments": {
"data": [
{
"type": "attachment",
"id": "uuid123"
},
{
"type": "attachment",
"id": "uuid123"
}
]
}
}
}
}
参数 | 是否必须 | 默认值 | 说明 |
---|---|---|---|
data.type | 是 | 无 | 资源对象类型,必须为 doc,表示文档 |
data.attributes.title | 是 | 无 | 文档标题 |
data.attributes.content | 是 | 无 | 文档内容 |
data.attributes.is_markdown | 是 | 无 | 0表示 HTML 格式,1表示 Markdown 格式 |
data.attributes.privilege_type | 否 | 0 | 0表示文档公开 1表示部分人可见,需要配合 privilege 参数使用 2表示仅创建者可见 |
data.attributes.source | 否 | original | original 表示原创,reship 表示转载 |
data.attributes.reship_url | 否 | 无 | 当 source 为 reship 时,reship_url表示转载来源 |
data.attributes.signature | 否 | 无 | 署名 |
data.attributes.allow_comment | 否 | 1 | 是否允许评论:0表示不允许评论,1表示允许评论 |
data.attributes.picture_url | 否 | 无 | 封面图 |
data.attributes.only_team | 否 | 0 | 参数为0,文档发布到k吧或公共知识库, 参数为1,文档将不发表在公共知识库内,也无需设置category.id,此时必须设置K吧team.id |
data.attributes.enable_image_watermark | 否 | 0 | 0表示不开启图片水印,1表示开启图片水印,上传文档不支持这个参数 |
data.attributes.enable_watermark | 否 | 0 | 0表示不开启页面文字水印,1表示开启页面文字水印;如果在安全合规中文档始终显示水印,则浏览文档始终会显示水印,不受此字段影响 |
data.attributes.enable_copy_limit | 否 | 0 | 0表示不开启禁止复制文字,1表示开启禁止复制文字;如果在安全合规中开启文档始终禁止复制,则浏览文档始终禁止复制文字,不受此字段影响 |
data.attributes.tags | 否 | 无 | 关联标签,值为数组类型,最多关联5个标签 |
data.relationships.category | 否 | 无 | 关联的资源对象,类型为 category,表示文档所属分类,默认为未分类 |
data.relationships.team | 否 | 无 | 关联的资源对象,类型为 team,表示文档所属K吧 |
data.relationships.directory | 否 | 无 | 关联的资源对象,类型为 directory,表示文档所属目录 目录仅附属于K吧下,仅传入K吧ID时有意义 若传入K吧时缺省此项则默认文档创建于K吧根目录 |
data.relationships.privilege | 否 | 无 | 关联的资源对象,类型为 privilege,仅当 privilege_type 为1时有效 可传入多个 staff,department,team,contact_tag 对象 |
data.relationships.attachments | 否 | 无 | 关联的资源对象,类型为 attachments,表示附件 |
$attributes = [
'title' => '通过开放接口创建的文档',
'content' => '<h1>富文本内容</h1>',
'is_markdown' => 0,
];
$options = [
'privilege_type' => 2,
'source' => 'reship',
'reship_url' => 'https://lexiangla.com',
'signature' => 'Peter Chan',
'allow_comment' => 1,
'picture_url' => 'https://lexiangla.com/assets/123',
'only_team'=>1,
'enable_image_watermark'=>1,
'enable_watermark'=>0,
'enable_copy_limit'=>0,
'category_id' => null,
'team_id' => 'uuid123',
'directory_id' => 'uuid123',
'attachments' => [uuid1, uuid2, uuid3],
];
$Lxapi = new \Lexiangla\Openapi\Api(AppKey, AppSecret);
$response = $Lxapi->postDoc(StaffID, $attributes, $options);
document
{
"data":{
"type":"doc",
"id":"65185ea6540311e895d2fb755adc6cb4",
"attributes":{
"name": "通过开放接口创建的文档",
"privilege_type": 1,
"is_star": 0,
"created_at": "2023-03-21 17:28:45",
"read_count": 0,
"comment_count": 0,
"allow_comment": 1,
"updated_at": "2023-03-21 17:28:45",
"recommended_at": null,
"picture_url": "https://lexiangla.com/assets/123",
"edited_at": "2023-03-21 17:28:45",
"only_team": true
},
"links":{
"platform":"https://lexiangla.com/teams/k00001/docs/65185ea6540311e895d2fb755adc6cb4"
},
"relationships":{
"category":{
"data":{
"type":"category",
"id":"3dc4337252dc11e693940800278acc25"
}
},
"owner":{
"data":{
"type":"staff",
"id":"ThreeZhang"
}
},
"target":{
"data":{
"type":"document",
"id":"6517eaf2540311e8b59b57582a142694"
}
}
}
},
"included":[
{
"type":"category",
"id":"3dc4337252dc11e693940800278acc25",
"attributes":{
"name":"其他",
"created_at":"2016-07-26 10:54:16"
}
},
{
"type":"staff",
"id":"ThreeZhang",
"attributes":{
"name":"张三",
"english_name":"ThreeZhang",
"organization":"运营组"
}
},
{
"type":"document",
"id":"6517eaf2540311e8b59b57582a142694",
"attributes":{
"is_markdown":"0",
"content":"<h1>富文本内容</h1>",
"source":"reship",
"reship_url":"https://lexiangla.com",
"read_count":"0",
"comment_count":"0",
"like_count":"0",
"favorite_count":"0",
"md_content":null
}
}
],
"links":{
"self":"https://lxapi.lexiangla.com/cgi-bin/v1/docs/65185ea6540311e895d2fb755adc6cb4"
}
}
此接口只用于创建文档实体,不负责文件传输。开发者需先通过 文件上传 接口将文件上传于腾讯云,再把state
通过此接口把文件和实体关联起来。
POST https://lxapi.lexiangla.com/cgi-bin/v1/docs/upload?state={STATE}
document
{
"data":{
"type":"doc",
"attributes":{
"name": "文档名",
"downloadable": 0,
"privilege_type":1,
"only_team":0,
"tags": [
"3",
"4",
"5",
"66666",
"777777777"
]
},
"relationships":{
"category":{
"data":{
"type":"category",
"id":"uuid123"
}
},
"team": {
"data": {
"type": "team",
"id": "uuid124"
}
},
"directory":{
"data":{
"type":"directory",
"id":"uuid123"
}
},
"privilege": {
"data": [
{
"type": "staff",
"id": "ThreeZhang"
},
{
"type": "contact_tag",
"id": 1
}
]
}
}
}
}
参数 | 是否必须 | 默认值 | 说明 |
---|---|---|---|
data.type | 是 | 无 | 资源对象类型,必须为 doc,表示文档 |
data.attributes.name | 否 | 无 | 自定义文档名,若不填则默认使用上传的文档名 |
data.attributes.downloadable | 否 | 1 | 是否允许下载:0表示不能下载,1表示允许下载 |
data.attributes.allow_comment | 否 | 1 | 是否允许评论:0表示不允许评论,1表示允许评论 |
data.attributes.privilege_type | 否 | 无 | 0表示文档公开 1表示部分人可见,需要配合 privilege 参数使用 2表示仅创建者可见 |
data.attributes.only_team | 否 | 0 | 参数为0,文档发布到k吧或公共知识库, 参数为1,文档将不发表在公共知识库内,也无需设置category.id,此时必须设置K吧team.id |
data.attributes.tags | 否 | 无 | 关联标签,值为数组类型,最多关联5个标签 |
data.relationships.category | 否 | 无 | 关联的资源对象,类型为 category,表示文档所属分类,默认为未分类 |
data.relationships.team | 否 | 无 | 关联的资源对象,类型为 team,表示文档所属K吧 |
data.relationships.directory | 否 | 无 | 关联的资源对象,类型为 directory,表示文档所属目录 目录仅附属于K吧下,仅传入K吧ID时有意义 若传入K吧时缺省此项则默认文档创建于K吧根目录 |
data.relationships.privilege | 否 | 无 | 关联的资源对象,类型为 privilege,仅当 privilege_type 为1时有效 可传入多个 staff,department,team,contact_tag 对象 |
state | 是 | 无 | 腾讯云直传-获取资源签名接口中object.state |
$options = [
'name' => '文档名',
'downloadable' => 0, // 是否可下载
'privilege_type' => 1,
'category_id' => '5b3109d6dd7611e88d4f5254009b5a66', // 文档分类
'only_team' => 1,
'team_id' => 'uuid124', // 文档所属k吧
'directory_id' => 'uuid124', // 文档所属目录
'privilege' => [
['type' => 'department', 'id' => 1],
['type' => 'contact_tag', 'id' => 1],
],// 文档的可见范围
];
$Lxapi = new \Lexiangla\Openapi\Api(AppKey, AppSecret);
$file_path = '/path/to/测试.xlsx'; // 文件的绝对路径
$response = $Lxapi->uploadDoc($staff_id, $file_path, $options);
document
{
"data":{
"type":"doc",
"id":"65e14486efb811e98dcd10e7c61c70fc",
"links":{
"platform":"https://lexiangla.com/teams/xxx/docs/65e14486efb811e98dcd10e7c61c70fc"
},
"attributes":{
"name":"测试",
"privilege_type":1,
"updated_at":"2019-10-16 09:58:07",
"created_at":"2019-10-16 09:58:07"
},
"relationships":{
"target":{
"data":{
"type":"file",
"id":"65c9cf90efb811e9a2ca10e7c61c70fc"
}
}
}
},
"included":[
{
"type":"file",
"id":"65c9cf90efb811e9a2ca10e7c61c70fc",
"attributes":{
"name":"测试"
}
}
],
"links":{
"self":"https://lxapi.lexiangla.com/cgi-bin/v1/docs/65e14486efb811e98dcd10e7c61c70fc"
}
}
此接口只用于修改文档实体关联的文件,不负责文件传输。开发者需先通过 文件上传 接口将文件上传于腾讯云,再把state
通过此接口把文件和实体关联起来。
PATCH https://lxapi.lexiangla.com/cgi-bin/v1/docs/{doc_id}/re-upload?state={state}
参数 | 是否必须 | 默认值 | 说明 |
---|---|---|---|
doc_id | 是 | 无 | 要修改的文档id |
state | 是 | 无 | 腾讯云直传-获取资源签名接口中object.state |
$Lxapi = new \Lexiangla\Openapi\Api(AppKey, AppSecret);
$file_path = '/path/to/测试.xlsx'; // 文件的绝对路径
$response = $Lxapi->reUploadDoc($staff_id, $doc_id, $file_path);
document
is_markdown 属性不能修改,若文档本身是 markdown 格式的,要修改 content 字段也要使用 markdown 格式。
PATCH https://lxapi.lexiangla.com/cgi-bin/v1/docs/{doc_id}?target_type={target_type}
参数 | 是否必须 | 默认值 | 说明 |
---|---|---|---|
doc_id | 是 | 无 | 要编辑的文档id |
target_type | 否 | document | 文档的创建类型:document 表示富文本类型文档,file 表示上传类型文档 两个类型编辑的属性略有不同,详细区别看以下示例 |
document
{
"data":{
"type":"doc",
"attributes":{
"title":"通过开放接口创建的文档",
"content":"<h1>富文本内容</h1>",
"source":"reship",
"reship_url":"https://lexiangla.com",
"signature":"Peter Chan",
"allow_comment":1,
"picture_url":"https://lexiangla.com/assets/123",
"only_team":0,
"privilege_type":1,
"enable_image_watermark":0,
"enable_watermark":1,
"enable_copy_limit":1,
"tags": [
"3",
"4",
"5",
"66666",
"777777777"
]
},
"relationships":{
"category":{
"data":{
"type":"category",
"id":"uuid123"
}
},
"team": {
"data": {
"type": "team",
"id": "uuid124"
}
},
"directory":{
"data":{
"type":"directory",
"id":"uuid123"
}
},
"privilege": {
"data": [
{
"type": "staff",
"id": "ThreeZhang"
},
{
"type": "contact_tag",
"id": 1
}
]
},
"attachments": {
"data": [
{
"type": "attachment",
"id": "uuid123"
},
{
"type": "attachment",
"id": "uuid123"
}
]
}
}
}
}
参数 | 是否必须 | 默认值 | 说明 |
---|---|---|---|
data.type | 是 | 无 | 资源对象类型,必须为 doc,表示文档 |
data.attributes.title | 否 | 无 | 文档标题 |
data.attributes.content | 否 | 无 | 文档内容 |
data.attributes.privilege_type | 否 | 无 | 0表示文档公开 1表示部分人可见,需要配合 privilege 参数使用 2表示仅创建者可见 |
data.attributes.source | 否 | 无 | original 表示原创,reship 表示转载 |
data.attributes.reship_url | 否 | 无 | 当 source 为 reship 时,reship_url表示转载来源 |
data.attributes.signature | 否 | 无 | 署名 |
data.attributes.allow_comment | 否 | 无 | 是否允许评论:0表示不允许评论,1表示允许评论 |
data.attributes.picture_url | 否 | 无 | 封面图 |
data.attributes.only_team | 是 | 0 | 参数为0,文档发布到k吧或公共知识库,当k吧文档发表到公共知识库,category.id必须填写, 参数为1,文档将不发表在公共知识库内,也无需设置category.id,此时必须设置K吧team.id |
data.attributes.enable_image_watermark | 否 | 无 | 0表示不开启图片水印,1表示开启图片水印,上传文档不支持这个参数 |
data.attributes.enable_watermark | 否 | 0 | 0表示不开启页面文字水印,1表示开启页面文字水印;如果在安全合规中文档始终显示水印,则浏览文档始终会显示水印,不受此字段影响 |
data.attributes.doc.enable_copy_limit | 否 | 0 | 0表示不开启禁止复制文字,1表示开启禁止复制文字;如果在安全合规中开启文档始终禁止复制,则浏览文档始终禁止复制文字,不受此字段影响 |
data.attributes.tags | 否 | 无 | 关联标签,值为数组类型,最多关联5个标签 |
data.relationships.category | 否 | 无 | 关联的资源对象,类型为 category,表示文档所属分类 |
data.relationships.team | 否 | 无 | 关联的资源对象,类型为 team,表示文档所属K吧。若只修改K吧,不指定目录,会默认转移到新K吧的根目录下。 |
data.relationships.directory | 否 | 无 | 关联的资源对象,类型为 directory,表示文档所属目录 目录仅附属于K吧下,仅传入K吧ID时有意义 若传入K吧时缺省此项则默认文档创建于K吧根目录 |
data.relationships.privilege | 否 | 无 | 关联的资源对象,类型为 privilege,仅当 privilege_type 为1时有效 可传入多个 staff,department,team,contact_tag 对象 |
data.relationships.attachments | 否 | 无 | 关联的资源对象,类型为 attachments,表示附件 |
$options = [
'target_type' => 'document',
'title' => '编辑后的标题',
'content' => '修改后的内容',
'source' => 'reship',
'reship_url' => 'https://lexiangla.com',
'signature' => 'Peter Chan',
'allow_comment' => 1,
'picture_url' => 'https://lexiangla.com/assets/123',
'only_team' => 1,
'enable_image_watermark' => 1,
'enable_watermark'=>1,
'enable_copy_limit'=>1,
'category_id' => uuid123,
'attachments' => [uuid1, uuid2, uuid3],
'team_id' => '17304108ab3411e8b4705254009b5a66',
'directory_id' => '95d54c8005f911ea838c5254009b5a66',
'privilege' => [
['type' => 'staff', 'id' => staff_id],
['type' => 'department', 'id' => department_id],
]
];
$Lxapi = new \Lexiangla\Openapi\Api(AppKey, AppSecret);
$response = $Lxapi->patchDoc(StaffID, $doc_id, $options);
document
{
"links": {
"self": "https://lxapi.lexiangla.com/cgi-bin/v1/docs/16d313f8abfb11e8bfc65254009b5a66"
},
"data": {
"type": "doc",
"id": "16d313f8abfb11e8bfc65254009b5a66",
"links": {
"platform": "https://lexiangla.com/teams/k100302/docs/16d313f8abfb11e8bfc65254009b5a66"
},
"attributes": {
"name": "name",
"privilege_type": 0,
"is_star": 0,
"created_at": "2018-08-30 10:19:14",
"read_count": 5,
"comment_count": 0,
"updated_at": "2019-11-13 17:59:47",
"recommended_at": null
},
"relationships": {
"category": {
"data": {
"type": "category",
"id": "bad963a25a0f11e68298525400f26262"
}
},
"owner": {
"data": {
"type": "staff",
"id": "ThreeZhang"
}
},
"directory": {
"data": {
"type": "directory",
"id": "591a36b4ab3411e895cd5254009b5a66"
}
},
"team": {
"data": {
"type": "team",
"id": "17304108ab3411e8b4705254009b5a66"
}
},
"target": {
"data": {
"type": "document",
"id": "16cfd490abfb11e8afe05254009b5a66"
}
}
}
},
"included": [
{
"type": "category",
"id": "bad963a25a0f11e68298525400f26262",
"attributes": {
"name": "其他"
}
},
{
"type": "staff",
"id": "ThreeZhang",
"attributes": {
"name": "a",
"english_name": "ThreeZhang"
}
},
{
"type": "directory",
"id": "591a36b4ab3411e895cd5254009b5a66",
"attributes": {
"name": "全部文档"
}
},
{
"type": "team",
"id": "17304108ab3411e8b4705254009b5a66",
"attributes": {
"code": "k100302",
"name": "test",
"type": 1,
"signature": null,
"is_secret": 0
}
},
{
"type": "document",
"id": "16cfd490abfb11e8afe05254009b5a66",
"attributes": {
"summary": "摘要",
"is_markdown": 0,
"content": "<p>摘要</p>",
"md_content": "",
"source": "original",
"reship_url": null,
"read_count": 5,
"comment_count": 0,
"like_count": 0,
"favorite_count": 0
}
}
]
}
document
{
"data":{
"type":"doc",
"attributes":{
"name": "文档名",
"downloadable": 0,
"privilege_type":1,
"signature":"Peter Chan",
"allow_comment":1,
"picture_url":"https://lexiangla.com/assets/123",
"only_team":0,
"tags"[
"aaa",
"bbb"
]
},
"relationships":{
"category":{
"data":{
"type":"category",
"id":"uuid123"
}
},
"team": {
"data": {
"type": "team",
"id": "uuid124"
}
},
"directory":{
"data":{
"type":"directory",
"id":"uuid123"
}
},
"privilege": {
"data": [
{
"type": "staff",
"id": "ThreeZhang"
},
{
"type": "contact_tag",
"id": 1
}
]
}
}
}
}
参数 | 是否必须 | 默认值 | 说明 |
---|---|---|---|
data.type | 是 | 无 | 资源对象类型,必须为 doc,表示文档 |
data.attributes.name | 否 | 无 | 自定义文档名,若不填则默认使用上传的文档名 |
data.attributes.downloadable | 否 | 无 | 是否允许下载:0表示不能下载,1表示允许下载 |
data.attributes.privilege_type | 否 | 无 | 0表示文档公开 1表示部分人可见,需要配合 privilege 参数使用 2表示仅创建者可见 |
data.attributes.signature | 否 | 无 | 署名 |
data.attributes.allow_comment | 否 | 无 | 是否允许评论:0表示不允许评论,1表示允许评论 |
data.attributes.picture_url | 否 | 无 | 封面图 |
data.attributes.only_team | 是 | 0 | 参数为0,文档发布到k吧或公共知识库,当k吧文档发表到公共知识库,category.id必须填写, 参数为1,文档将不发表在公共知识库内,也无需设置category.id,此时必须设置K吧team.id |
data.attributes.tags | 否 | 无 | 关联标签,值为数组类型,最多关联5个标签 |
data.relationships.category | 否 | 无 | 关联的资源对象,类型为 category,表示文档所属分类 |
data.relationships.team | 否 | 无 | 关联的资源对象,类型为 team,表示文档所属K吧。若只修改K吧,不指定目录,会默认转移到新K吧的根目录下。 |
data.relationships.directory | 否 | 无 | 关联的资源对象,类型为 directory,表示文档所属目录 目录仅附属于K吧下,仅传入K吧ID时有意义 若传入K吧时缺省此项则默认文档创建于K吧根目录 |
data.relationships.privilege | 否 | 无 | 关联的资源对象,类型为 privilege,仅当 privilege_type 为1时有效 可传入多个 staff,department,team,contact_tag 对象 |
data.relationships.attachments | 否 | 无 | 关联的资源对象,类型为 attachments,表示附件 |
$options = [
'target_type' => 'file',
'name' => '编辑后的标题',
'downloadable' => 0,
'privilege_type' => 0,
'signature' => 'Peter Chan',
'allow_comment' => 1,
'picture_url' => 'https://lexiangla.com/assets/123',
'category_id' => uuid123,
'attachments' => [uuid1, uuid2, uuid3],
'team_id' => '17304108ab3411e8b4705254009b5a66',
'directory_id' => '95d54c8005f911ea838c5254009b5a66',
'privilege' => [
['type' => 'staff', 'id' => staff_id],
['type' => 'department', 'id' => department_id],
]
];
$Lxapi = new \Lexiangla\Openapi\Api(AppKey, AppSecret);
$response = $Lxapi->patchDoc(StaffID, $doc_id, $options);
DELETE https://lxapi.lexiangla.com/cgi-bin/v1/docs/{doc_id}
参数 | 是否必须 | 默认值 | 说明 |
---|---|---|---|
doc_id | 是 | 无 | 资源对象类型为 doc 的资源对象id,即文档id |
$Lxapi = new \Lexiangla\Openapi\Api(AppKey, AppSecret);
$response = $Lxapi->deleteDoc(StaffID, doc_id);
document
把文档加入个人收藏中
POST https://lxapi.lexiangla.com/cgi-bin/v1/docs/{doc_id}/relationships/favorites
参数 | 是否必须 | 默认值 | 说明 |
---|---|---|---|
doc_id | 是 | 无 | 资源对象类型为 doc 的资源对象id,即文档id |
document
{
"data": [
{
"type": "staffs",
"id": "zhangsan"
}
]
}
参数 | 是否必须 | 默认值 | 说明 |
---|---|---|---|
type | 是 | 无 | 资源对象为类型staff ,staff表示成员 |
id | 是 | 无 | 成员账号 |
$Lxapi = new \Lexiangla\Openapi\Api(AppKey, AppSecret);
$operators = [
'zhangsan'
];
//staff_id是调用接口的用户
//operator是收藏文档的用户
//一般情况下,staff_id可以跟operator是同一个用户ID
$response = $Lxapi->postDocFavorite($staff_id, $doc_id, $operators);
document
DELETE https://lxapi.lexiangla.com/cgi-bin/v1/docs/{doc_id}/relationships/favorites
参数 | 是否必须 | 默认值 | 说明 |
---|---|---|---|
doc_id | 是 | 无 | 资源对象类型为 doc 的资源对象id,即文档id |
document
{
"data": [
{
"type": "staffs",
"id": "zhangsan"
}
]
}
参数 | 是否必须 | 默认值 | 说明 |
---|---|---|---|
type | 是 | 无 | 资源对象为类型staff ,staff表示成员 |
id | 是 | 无 | 成员账号 |
$Lxapi = new \Lexiangla\Openapi\Api(AppKey, AppSecret);
$operators = [
'zhangsan'
];
//staff_id是调用接口的用户
//operator是收藏文档的用户
//一般情况下,staff_id可以跟operator是同一个用户ID
$response = $Lxapi->deleteDocFavorite($staff_id, $doc_id, $operators);
document
GET https://lxapi.lexiangla.com/cgi-bin/v1/docs/{doc_id}
参数 | 是否必须 | 默认值 | 说明 |
---|---|---|---|
doc_id | 是 | 无 | document 中资源对象类型为doc的资源对象id,即文档id |
$Lxapi = new \Lexiangla\Openapi\Api(AppKey, AppSecret);
$response = $Lxapi->get('docs/3754ef90540611e88b15cbea5266a5e7');
document
富文本类型文档
{
"data": {
"type": "doc",
"id": "7c6cca86484411ec922f960346af4b7a",
"attributes": {
"name": "文档的标题",
"privilege_type": 1,
"is_star": 0,
"is_shelved": 1,
"comment_count": 1,
"read_count": 2,
"created_at": "2021-11-18 15:52:32",
"updated_at": "2021-11-18 15:52:39",
"edited_at": "2021-11-18 15:52:32",
"recommended_at": null,
"picture_url": "",
"allow_comment": 1,
"only_team": false,
"tags": [
"111",
"222"
]
},
"links": {
"platform": "https://lexiangla.com/docs/7c6cca86484411ec922f960346af4b7a?company_from=35a8fa86146711ecaced62e1943b6xxx"
},
"relationships": {
"category": {
"data": {
"type": "category",
"id": "90f784ac146711ec990062e1943b6703"
}
},
"owner": {
"data": {
"type": "staff",
"id": "dragonzhang"
},
"team": {
"data": {
"type": "team",
"id": "e681907aa0a611eeb1a83aa5174815f1"
}
}
},
"target": {
"data": {
"type": "document",
"id": "7c67ef84484411ec85c6960346af4b7a"
}
},
"attachments": {
"data": [
{
"type": "attachment",
"id": "80326b86009711efad0dfaeca504eb8b"
}
]
},
"tags": {
"data": [
{
"type": "tag",
"id": "32dc8d44f6a811e7ab175254002b6735"
},
{
"type": "tag",
"id": "888e1450183411eb809c8e5237bd6043"
}
]
},
"privilege": {
"data": [
{
"type": "contact_tag",
"id": "b96a1e8eeb5b11eb86cefa390de91f52"
},
{
"type": "department",
"id": "154"
},
{
"type": "staff",
"id": "zhangsan"
}
]
}
}
},
"included": [
{
"type": "category",
"id": "90f784ac146711ec990062e1943b6703",
"attributes": {
"name": "规章制度"
}
},
{
"type": "staff",
"id": "dragonzhang",
"attributes": {
"name": "张龙",
"english_name": null,
"organization": "开发部"
}
},
{
"type": "team",
"id": "e681907aa0a611eeb1a83aa5174815f1",
"attributes": {
"code": "k1015xx",
"name": "kba",
"type": 2,
"logo": "//static.lexiang-asset.com/build/img/default@2x-42e4b0xx.png",
"signature": "",
"is_secret": 0
},
"links": {
"platform": "https://km.lexiangla.com/teams/k1015xx"
}
},
{
"type": "document",
"id": "7c67ef84484411ec85c6960346af4b7a",
"attributes": {
"summary": "内容",
"is_markdown": 0,
"content": "内容",
"md_content": "",
"source": "original",
"reship_url": null,
"like_count": 0,
"favorite_count": 0,
"signature": ""
}
},
{
"type": "tag",
"id": "32dc8d44f6a811e7ab175254002b6735",
"attributes": {
"name": "111",
"recommended_at": null
}
},
{
"type": "tag",
"id": "888e1450183411eb809c8e5237bd6043",
"attributes": {
"name": "222",
"recommended_at": null
}
},
{
"type": "validity_config",
"id": 27422,
"attributes": {
"enable_validity": 1,
"validity_started_at": "2025-06-09 00:00:00",
"validity_ended_at": "2026-06-08 00:00:00",
"validity_days": 0,
"enable_inspection": 1,
"inspection_extend_days": 365,
"enable_unshelve": 0,
"unshelve_expired_days": 0
}
}
],
"links": {
"self": "https://lxapi.lexiangla.com/cgi-bin/v1/docs/7c6cca86484411ec922f960346af4bxx"
}
}
参数 | 说明 |
---|---|
data.attributes.name | 文档标题 |
data.attributes.privilege_type | 文档可见范围 0表示文档公开 1表示部分人可见 2表示仅创建者可见 |
data.attributes.is_star | 文档是否K吧内星标文档 |
data.attributes.is_shelved | 文档的上下架状态,1表示上架状态,0表示下架状态 |
data.attributes.created_at | 文档创建时间 |
data.attributes.updated_at | 文档最后的修改时间 |
data.attributes.read_count | 文档浏览数 |
data.attributes.comment_count | 文档评论数 |
data.attributes.recommended_at | 若文档是管理员设置为推荐文档,则此处值为设置时间,否则为null |
data.relationships.tags | 文档关联标签 |
data.relationships.attachment | 文档关联附件 |
data.relationships.privilege | 部分人可见关联的组织架构对象,仅当 privilege_type 为1时 返回多个 staff,department,team,contact_tag 对象 |
data.included.category.attributes.name | 文档所属分类名 |
data.included.staff.attributes.organization | 文档创建者所属部门 |
data.included.team.attributes.name | 文档所在的K吧名 |
data.included.document.attributes.is_markdown | 文档是否markdown格式 |
data.included.document.attributes.summary | 文档详情摘要 |
data.included.document.attributes.content | 文档正文内容(富文本) |
data.included.document.attributes.source | 文档来源 |
data.included.document.attributes.reship_url | 文档转载链接 |
data.included.document.attributes.like_count | 文档点赞数 |
data.included.document.attributes.favorite_count | 文档收藏数 |
data.included.document.attributes.md_content | 若文档是markdown格式,此处存放markdown原文 |
data.included.validity_config.attributes.enable_validity | 文档是否开启有效期设置,1表示开启,0表示未开启 |
data.included.validity_config.attributes.validity_started_at | 文档有效期开始时间 |
data.included.validity_config.attributes.validity_ended_at | 文档有效期结束时间 |
data.included.validity_config.attributes.validity_days | 文档有效期总天数 |
data.included.validity_config.attributes.enable_inspection | 文档是否开启定期检视,1表示开启,0表示未开启 |
data.included.validity_config.attributes.inspection_extend_days | 文档检视完成后延期天数 |
data.included.validity_config.attributes.enable_unshelve | 文档是否开启到期下架,1表示开启,0表示未开启 |
data.included.validity_config.attributes.unshelve_expired_days | 文档有效期到期自动下架天数 |
文件类型文档
file.links.download
提供了可以下载的链接,有效时间为3分钟。
{
"data": {
"type": "doc",
"id": "d1a30c6a0b4011eab54210e7c61c70fc",
"attributes": {
"name": "test",
"privilege_type": 0,
"is_star": 0,
"is_shelved": 0,
"created_at": "2019-11-20 10:52:41",
"read_count": 0,
"comment_count": 0,
"updated_at": "2019-11-20 10:58:04",
"recommended_at": null
},
"links": {
"platform": "https://lxapi.lexiangla.com/docs/d1a30c6a0b4011eab54210e7c61c70fc"
},
"relationships": {
"category": {
"data": {
"type": "category",
"id": "e46259ac80e311e8ab323464a915a5a6"
}
},
"owner": {
"data": {
"type": "staff",
"id": "ThreeZhang"
}
},
"directory": {
"data": {
"type": "directory",
"id": "093be678519e11e89df33464a915a5a6"
}
},
"team": {
"data": {
"type": "team",
"id": "1aff40327c2c11ec93fe3ebd64d9b4xx"
}
},
"target": {
"data": {
"type": "file",
"id": "d14c39120b4011eaa33510e7c61c70fc"
}
},
"tags": {
"data": [
{
"id": "c90c68be776111e7a2935254002b6735",
"type": "tag"
}
]
}
}
},
"included": [
{
"type": "category",
"id": "e46259ac80e311e8ab323464a915a5a6",
"attributes": {
"name": "默认分类"
}
},
{
"type": "staff",
"id": "ThreeZhang",
"attributes": {
"name": "张三",
"english_name": "ThreeZhang",
"organization": "开发部"
}
},
{
"type": "team",
"id": "1aff40327c2c11ec93fe3ebd64d9b4xx",
"attributes": {
"code": "k101245",
"name": "通过开放接口创建的K吧",
"type": 1,
"logo": null,
"signature": "这是通过开放接口创建的K吧",
"is_secret": 0
}
},
{
"type": "directory",
"id": "093be678519e11e89df33464a915a5a6",
"attributes": {
"name": "全部文档"
}
},
{
"type": "file",
"id": "d14c39120b4011eaa33510e7c61c70fc",
"attributes": {
"name": "test",
"like_count": 0,
"favorite_count": 0
},
"links": {
"download": "https://file.lexiang-asset.com/xxxx/2019/11/40108baa-0b41-11ea-84a6-10e7c61c70fc.docx?hc=098f6bcd4621d373cade4e832627b4f6&sign=xxxx"
}
},
{
"type": "validity_config",
"id": 28352,
"attributes": {
"enable_validity": 1,
"validity_started_at": "2025-07-24 00:00:00",
"validity_ended_at": "2025-07-26 00:00:00",
"validity_days": 0,
"enable_inspection": 1,
"inspection_extend_days": 30,
"enable_unshelve": 1,
"unshelve_expired_days": 3
}
}
],
"links": {
"self": "https://lxapi.lexiangla.com/cgi-bin/v1/docs/d1a30c6a0b4011eab54210e7c61c70fc"
}
}
参数 | 说明 |
---|---|
data.attributes.name | 文档标题 |
data.attributes.privilege_type | 文档可见范围 0表示文档公开 1表示部分人可见 2表示仅创建者可见 |
data.attributes.is_star | 文档是否K吧内星标文档 |
data.attributes.is_shelved | 文档的上下架状态,1表示上架状态,0表示下架状态 |
data.attributes.created_at | 文档创建时间 |
data.attributes.updated_at | 文档最后的修改时间 |
data.attributes.read_count | 文档浏览数 |
data.attributes.comment_count | 文档评论数 |
data.attributes.recommended_at | 若文档是管理员设置为推荐文档,则此处值为设置时间,否则为null |
data.attributes.tags | 文档标签,必须为数组 |
data.included.category.attributes.name | 文档所属分类名,没有发表到知识库或未分类不返回 |
data.included.staff.attributes.organization | 所属部门 |
data.included.team.attributes.name | 文档所在的K吧名 |
data.included.directory.attributes.name | 文档所在的K吧文件夹名字 |
data.included.file.attributes.name | 上传的文档名 |
data.included.file.attributes.like_count | 文档点赞数 |
data.included.file.attributes.favorite_count | 文档收藏数 |
data.included.validity_config.attributes.enable_validity | 文档是否开启有效期设置,1表示开启,0表示未开启 |
data.included.validity_config.attributes.validity_started_at | 文档有效期开始时间 |
data.included.validity_config.attributes.validity_ended_at | 文档有效期结束时间 |
data.included.validity_config.attributes.validity_days | 文档有效期总天数 |
data.included.validity_config.attributes.enable_inspection | 文档是否开启定期检视,1表示开启,0表示未开启 |
data.included.validity_config.attributes.inspection_extend_days | 文档检视完成后延期天数 |
data.included.validity_config.attributes.enable_unshelve | 文档是否开启到期下架,1表示开启,0表示未开启 |
data.included.validity_config.attributes.unshelve_expired_days | 文档有效期到期自动下架天数 |
{
"errors":{
"detail":"不存在ID为`3754ef90540611e88b15cbea5266a5e7`的doc资源"
}
}
GET https://lxapi.lexiangla.com/cgi-bin/v1/docs
支持分页参数和排序:(通用说明?)
支持时间范围过滤
参数 | 是否必须 | 默认值 | 说明 |
---|---|---|---|
list_type | 否 | public | hot :最热文档;public :公开可见的文档;all :全部文档; |
date_range | 否 | 无 | 获取最热文档时(list_type=hot )时必传;值为1到100之间的整数,表示获取距今多少天内的最热文档 |
category_id | 否 | 无 | 指定分类的文档,仅当list_type 为public 、all 时有效,不支持查询这个分类的子分类 |
tag_id | 否 | 无 | 标签id |
team_id | 否 | 无 | K吧id,当is_star参数值为1时,K吧id为必填字段 |
directory_id | 否 | 无 | 文件夹id,仅当team_id指定时有效,不支持查询这个文件夹的子文件夹 |
page | 否 | 1 | 当前页数 |
per_page | 否 | 20 | 每页返回的数量 |
sort | 否 | -created_at | 排序方式,目前仅支持created_at |
is_recommended | 否 | 无 | 是否推荐 1:推荐 不传值:非推荐文档 |
is_star | 否 | 无 | 是否星标 1:星标文档 不传值:非星标文档 |
获取公开可见的文档列表(支持指定分类)
$Lxapi = new \Lexiangla\Openapi\Api(AppKey, AppSecret);
$response = $Lxapi->get('docs',[
'list_type' => 'public',
// 'category_id' => 'xxxxxx', // 支持指定文档分类
'page' => 1,
'per_page' => 3
]);
获取所有的文档列表(支持指定分类)
$Lxapi = new \Lexiangla\Openapi\Api(AppKey, AppSecret);
$response = $Lxapi->get('docs',[
'list_type' => 'all',
// 'category_id' => 'xxxxxx', // 支持指定文档分类
'page' => 1,
'per_page' => 3
]);
获取公开可见的最热文档(不支持指定分类)
$Lxapi = new \Lexiangla\Openapi\Api(AppKey, AppSecret);
$response = $Lxapi->get('docs',[
'list_type' => 'hot',
'date_range' => 30, // 获取30天的最热文档
'page' => 1,
'per_page' => 3
]);
document
{
"data": [
{
"type": "doc",
"id": "4560d152beb211eb9d76ce84ae800ba0",
"attributes": {
"name": "K吧下的文档",
"privilege_type": 0,
"is_star": 0,
"comment_count": 0,
"read_count": 2,
"created_at": "2021-05-27 14:10:44",
"updated_at": "2021-05-27 14:10:44",
"recommended_at": null,
"picture_url": "",
"allow_comment": 1,
"edited_at": "2021-05-27 14:10:44",
"tags": [
"222",
"333"
]
},
"links": {
"platform": "https://lexiangla.com/teams/k100045/docs/4560d152beb211eb9d76ce84ae800ba0?company_from=XXXXX"
},
"relationships": {
"category": {
"data": {
"type": "category",
"id": "91d55a7efbd711eabf8b22f21195fed5"
}
},
"owner": {
"data": {
"type": "staff",
"id": "LX001"
}
},
"team": {
"data": {
"type": "team",
"id": "9588b2a496bb11ebb55c4a77494882b0"
}
},
"target": {
"data": {
"type": "document",
"id": "455bedeabeb211ebafdace84ae800ba0"
}
},
"directory": {
"data": {
"type": "directory",
"id": "319d6f86beb211eb8d300e18ff6b2369"
}
}
}
},
{
"type": "doc",
"id": "131e877abeb211ebaed30e18ff6b2369",
"attributes": {
"name": "文档",
"privilege_type": 0,
"is_star": 0,
"comment_count": 0,
"read_count": 1,
"created_at": "2021-05-27 14:09:19",
"updated_at": "2021-05-27 14:09:19",
"recommended_at": null,
"picture_url": "",
"allow_comment": 1,
"edited_at": "2021-05-27 14:09:19"
},
"links": {
"platform": "https://lexiangla.com/teams/k100045/docs/131e877abeb211ebaed30e18ff6b2369?company_from=XXXXX"
},
"relationships": {
"category": {
"data": {
"type": "category",
"id": "91d55a7efbd711eabf8b22f21195fed5"
}
},
"owner": {
"data": {
"type": "staff",
"id": "LX001"
}
},
"team": {
"data": {
"type": "team",
"id": "9588b2a496bb11ebb55c4a77494882b0"
}
},
"target": {
"data": {
"type": "document",
"id": "1316aebabeb211eba2510e18ff6b2369"
}
},
"directory": {
"data": {
"type": "directory",
"id": "2127bd5eb88211eb949e3e3611627ba6"
}
}
}
}
],
"links": {
"first": "https://lxapi.lexiangla.com/cgi-bin/v1/docs?per_page=2&page=1",
"last": "https://lxapi.lexiangla.com/cgi-bin/v1/docs?per_page=2&page=5",
"prev": null,
"next": "https://lxapi.lexiangla.com/cgi-bin/v1/docs?per_page=2&page=2"
},
"meta": {
"current_page": 1,
"from": 1,
"last_page": 5,
"path": "https://lxapi.lexiangla.com/cgi-bin/v1/docs",
"per_page": 2,
"to": 2,
"total": 10
},
"included": [
{
"type": "category",
"id": "91d55a7efbd711eabf8b22f21195fed5",
"attributes": {
"name": "技术研发"
}
},
{
"type": "staff",
"id": "LX001",
"attributes": {
"name": "zhangsan",
"english_name": null,
"organization": "测试部"
}
},
{
"type": "team",
"id": "9588b2a496bb11ebb55c4a77494882b0",
"attributes": {
"code": "k100045",
"name": "有图标的K吧",
"type": 1,
"logo": "https://lexiangla.com/assets/439301f0b88211ebad1d3e3611627ba6",
"signature": "",
"is_secret": 0
}
},
{
"type": "document",
"id": "455bedeabeb211ebafdace84ae800ba0",
"attributes": {
"source": "original",
"reship_url": null,
"like_count": 0,
"favorite_count": 0,
"signature": ""
}
},
{
"type": "document",
"id": "1316aebabeb211eba2510e18ff6b2369",
"attributes": {
"source": "original",
"reship_url": null,
"like_count": 0,
"favorite_count": 0,
"signature": ""
}
},
{
"type": "directory",
"id": "319d6f86beb211eb8d300e18ff6b2369",
"attributes": {
"name": "文件夹1"
}
},
{
"type": "directory",
"id": "2127bd5eb88211eb949e3e3611627ba6",
"attributes": {
"name": "文档2"
}
}
]
}
当没有传递参数list_type=hot
时,没有传递date_range
,会返回400状态码,且响应体如下所示:
{
"errors":{
"detail":{"date_range":["date range 是必须的当 list_type 是 hot."]}
}
}
当传递错误的list_type
时,会返回400状态码,且响应体如下所示:
{
"errors":{
"detail":{"list_type":["选定的 list_type 是无效的."]}
}
}
当传递的category_id
对应的分类不存在时,会返回300状态码,且响应体如下所示:
{
"errors":{
"detail":{"category_id":["category id 是无效的."]}
}
}
GET https://lxapi.lexiangla.com/cgi-bin/v1/docs/{doc_id}/rewards
参数 | 是否必须 | 默认值 | 说明 |
---|---|---|---|
doc_id | 是 | 无 | 文档的id |
$Lxapi = new \Lexiangla\Openapi\Api(AppKey, AppSecret);
$response = $Lxapi->get('docs/352e6c24482f11e889ca8db592c332a7/rewards',[
'page' => 1,
'per_page' => 20
]);
document
{
"data": [
{
"type": "reward",
"id": "1047cba0494a11e8a2b84f24209a18d6",
"attributes": {
"created_at": "2018-04-26 20:05:08",
"amount": 111
},
"relationships": {
"owner": {
"data": {
"type": "staff",
"id": "ThreeZhang"
}
}
}
}
],
"links": {
"first": "https://lxapi.lexiangla.com/cgi-bin/v1/docs/352e6c24482f11e889ca8db592c332a7/rewards?page=1",
"last": "https://lxapi.lexiangla.com/cgi-bin/v1/docs/352e6c24482f11e889ca8db592c332a7/rewards?page=1",
"prev": null,
"next": null
},
"meta": {
"current_page": 1,
"from": 1,
"last_page": 1,
"path": "https://lxapi.lexiangla.com/cgi-bin/v1/docs/352e6c24482f11e889ca8db592c332a7/rewards",
"per_page": 20,
"to": 3,
"total": 3
},
"included": [
{
"type": "staff",
"id": "ThreeZhang",
"attributes": {
"name": "张三",
"english_name": "ThreeZhang",
"organization": "开发组"
}
}
]
}
参数 | 说明 |
---|---|
data.attributes.amount | 赞赏的金额,单位分 |
data.attributes.created_at | 赞赏的时间 |
data.relationships.owner | 赞赏人 |