电子实验记录本的数据导出API接口,使用JSON格式进行数据交换。用于导出按存储的原始格式导出数据。
在调用API时,在Header里要加入如下的信息
Authorization: Bearer {AccessToken}
AccessToken 的获取方式,见“认证接口”
请求URL: https://eln.iphy.ac.cn:61262/eln_api/export
请求参数有两种写法,一种是通过搜索条件导出数据,另一种是通过指定具体记录的信息导出想要的记录。具体方式的判断以uids参数是否存在为准,如果存在uids参数则为指定记录的方式。
1. 通过查询导出数据参数
| eln | 选填,数组。要查询的记录本名称合集。所有指定的记录本必须是存放在同一服务器上的;如果此参数为空,则搜索范围为自己的所有记录本。记录本名称有两种表示方法,1. 字符串,自己的记录本名称。2. {“title": "记录本名称“, "user": "xxx@abc.com"},指定他人的记录本; |
| user | 选填。字符串。如果是自己的记录本,可不填写;他人的合作编辑记录本,需要填写记录本所有者的Email |
| date_start | 选填,日期格式字符串。搜索晚于此记录创建的日期的记录(包含当天); |
| date_end | 选填,日期格式字符串。搜索早于此记录创建的日期的记录(包含当天); |
| keywords | 选填,数组。在包含关键词中的记录中查找; |
通过查询导出数据示例
{
"eln": [
"记录本名称1",
"记录本名称2",
{"title":"记录本名称2", "user":"xxx@abc.com"},
{"title":"记录本名称3", "user":"xxxx@abc.com"}
],
"date_start": "2000-1-1",
"date_end": "2000-12-31",
"keywords": ["关键词1", "关键词2"]
}
2. 通过指定具体实验记录导出参数
这种方式仅支持主服务器数据导出,不支持课题组服务器
| uids | 必填,数组。要查找的记录的UID; |
指定导出记录示例
{
"uids": [
{
"eln": "记录本0",
"uid": "K3PB7JTBLJ2KC7JS"
},
{
"eln": {"title":"记录本1", "user":92},
"uid": "A2021306-6"
},
{
"eln": {"title":"记录本2", "user":test@abc.com},
"uid": "A2021306-7"
}
]
}
返回数据会包含所有符合条件的条目的原始存储数据。
| code | 错误代码;
|
| msg | 错误描述; |
| dataset | 数据集;
|
示例
{
"code": 0,
"dataset": [{
"eln_name": "记录本名称",
"id": 1024,
"comm": "数据名称",
"data": [
{
"type": "richtext",
"name": "富文本",
"uid": "1234",
"width": false,
"data": "<p>Text</p>"
},
{
"type": "form",
"name": "表单1",
"uid": "2s023322",
"width": false,
"data": [
{
"type": "date",
"uid": "sdfdfdf",
"required": false,
"name": "日期",
"date": "2000-1-1"
},
{
"type": "time",
"uid": "sdfdfdf",
"required": false,
"name": "时间",
"date": "23:59"
},
{
"type": "text",
"uid": "edf3",
"required": false,
"name": "文本",
"date": "text"
},
{
"type": "number",
"uid": "dddd",
"required": false,
"name": "数字",
"date": 1024
},
{
"type": "bool",
"uid": "dddd",
"name": "布尔值",
"date": true
},
{
"type": "file",
"uid": "dddd",
"name": "文件上传",
"date": {
"hash": "1234567890abcdef",
"filename": "a.zip",
"size": 1024
}
},
{
"type": "select",
"uid": "dddd",
"name": "选择",
"options": [
{"key": "a", "value": "1"},
{"key": "b", "value": "2"}
]
"date": "2"
}
]
},
{
"type": "table",
"name": "表格1",
"uid": "2s023322",
"width": false,
"data": [
{
"type": "date",
"name": "日期",
"data": ["2000-1-1","2000-1-1"]
},
{
"type": "time",
"name": "时间",
"date": ["23:59","23:59"]
},
{
"type": "text",
"name": "文本",
"date": ["text","text"]
},
{
"type": "number",
"name": "数字",
"date": [1024,1024]
},
{
"type": "bool",
"name": "布尔值",
"date": [true,true]
},
{
"type": "file",
"name": "文件上传",
"date": [
{
"hash": "1234567890abcdef",
"filename": "a.zip",
"size": 1024
},
{
"hash": "1234567890abcdef",
"filename": "a.zip",
"size": 1024
}
]
},
{
"type": "select",
"name": "选择",
"options": [
{
"key": "a",
"value": "1"
},
{
"key": "b",
"value": "2"
}
]
"date": ["2","2"]
}
]
},
{
"type": "images",
"name": "图片1",
"uid": "2s023322",
"width": false,
"data": [
{
"hash": "1234567890abcdef",
"filename": "a.zip",
"size": 1024
},
{
"hash": "1234567890abcdef",
"filename": "a.zip",
"size": 1024
}
]
}
]
}
}
使用正则表达式,查找 符合 /="elnurl:\/\/([^>"]*)"/i 的字符串,替换为
="http://记录本服务器/eln_url/eln?token={用户token}&eln={记录本id}&i={记录id}&{正则匹配部分}"
上传的文件在JSON中存储的格式为:
{"hash":"1234567890ABCDEFG", "size":12345, "filename":"filename.ext"}
使用这些信息,生成url
https://记录本服务器/eln_url/eln?token={用户token}&eln={记录本id}&i={记录id}&h={hash}&s={size}&f={filename}