REST API
介绍
Zenodo REST API当前支持:
- 存款 -上传和发布研究成果(与 用户界面中提供的功能)。
- 记录 —搜索已发布的记录。
- 档案 —下载/上传文件。
看看 快速开始 有关如何操作的示例指南 以编程方式上传和发布您的研究成果。
在我们启动以下REST API之前,它们正在测试中 贝塔 带有完整的文档:
- 社区 -搜索社区。
- 资助者 —寻找资助者。
- 赠款 —搜索赠款。
- 执照 —搜索许可证。
您可以从我们的根端点窥探测试中的API: //americinnmankato.com/api/
快速入门-上传
本简短指南将简要概述如何在以下位置上载和发布 Zenodo,并将与Python一起使用 要求 包。
$ pip install requests
- 首先,请确保您拥有 要求 模组 installed:
$ python
蟒蛇 3.6.5
[GCC 4.8.1] on linux2
Type "help", "copyright", "credits" or "执照" for more information.
- 接下来,启动一个Python命令提示符:
import requests
- Import the
requests
模组:
>>> import requests
>>> r = requests.get("//americinnmankato.com/api/deposit/depositions")
>>> r.status_code
401
>>> r.json()
{
"message": "的 server could not verify that you are authorized 至 access
the URL requested. You either supplied the wrong credentials (e.g. a bad
password), or your browser doesn't understand how 至 supply the credentials
required.",
"status": 401
}
- 我们将尝试在没有身份验证令牌的情况下访问API:
- 所有API访问都需要访问令牌,因此 创造 一。
>>> ACCESS_TOKEN = 'ChangeMe'
>>> r = requests.get('//americinnmankato.com/api/deposit/depositions',
... params={'access_token': ACCESS_TOKEN})
>>> r.status_code
200
>>> r.json()
[]
- 让’s try again (replace
ACCESS_TOKEN
with your newly 创造d 个人 access 至ken):
>>> 标头s = {"Content-Type": "application/json"}
>>> params = {'access_token': ACCESS_TOKEN}
>>> r = requests.post('//sandbox.americinnmankato.com/api/deposit/depositions',
params=params,
json={},
# 标头s are not necessary here since "requests" automatically
# adds "Content-Type: application/json", because we're using
# the "json=" keyword argument
# 标头s=headers,
标头s=标头s)
>>> r.status_code
201
>>> r.json()
{
"conceptrecid": "542200",
"创造d": "2020-05-19T11:58:41.606998+00:00",
"files": [],
"id": 542201,
"links": {
"bucket": "//americinnmankato.com/api/files/568377dd-daf8-4235-85e1-a56011ad454b",
"discard": "//americinnmankato.com/api/deposit/depositions/542201/actions/discard",
"edit": "//americinnmankato.com/api/deposit/depositions/542201/actions/edit",
"files": "//americinnmankato.com/api/deposit/depositions/542201/files",
"html": "//americinnmankato.com/deposit/542201",
"latest_draft": "//americinnmankato.com/api/deposit/depositions/542201",
"latest_draft_html": "//americinnmankato.com/deposit/542201",
"publish": "//americinnmankato.com/api/deposit/depositions/542201/actions/publish",
"self": "//americinnmankato.com/api/deposit/depositions/542201"
},
"metadata": {
"prereserve_doi": {
"doi": "10.5072/zenodo.542201",
"recid": 542201
}
},
"modified": "2020-05-19T11:58:41.607012+00:00",
"owner": 12345,
"记录_id": 542201,
"state": "unsubmitted",
"submitted": false,
"title": ""
}
- 接下来,让’s创建一个新的空上传:
- 现在,让’s上传一个新文件。我们最近发布了一个新的API,该API的性能明显更高,并且支持更大的文件大小。虽然较旧的API每个文件支持100MB,但新API没有大小限制。
bucket_url = r.json()["links"]["bucket"]
$ curl //americinnmankato.com/api/deposit/depositions/222761?access_token=$ACCESS_TOKEN
{ ...
"links": {
"bucket": "//americinnmankato.com/api/files/568377dd-daf8-4235-85e1-a56011ad454b",
...,
},
... }
- 要使用 新文件API we will do a PUT request 到
bucket
link. 的 bucket is a folder-like 目的 storing the files of our 记录. Our bucket URL will look like this://americinnmankato.com/api/files/568377dd-daf8-4235-85e1-a56011ad454b
和 can be found under thelinks
key in our 记录s metadata.
# This will stream the file located in '/path/to/your/file.dat' 和 store it in our bucket.
# 的 uploaded file will be named according 到 last argument in the upload URL,
# 'file.dat' in our case.
$ curl --upload-file /path/to/your/file.dat //americinnmankato.com/api/files/568377dd-daf8-4235-85e1-a56011ad454b/file.dat?access_token=$ACCES_TOKEN
{ ... }
# New API
filename = "my-file.zip"
path = "/path/to/%s" % filename
# 的 target URL is a combination of the bucket link with the desired filename
# seperated by a slash.
with open(path, "rb") as fp:
r = requests.put(
"%s/%s" % (bucket_url, filename),
data=fp,
params=params,
)
r.json()
{
"key": "my-file.zip",
"mimetype": "application/zip",
"checksum": "md5:2942bfabb3d05332b66eb128e0842cff",
"version_id": "38a724d3-40f1-4b27-b236-ed2e43200f85",
"size": 13264,
"创造d": "2020-02-26T14:20:53.805734+00:00",
"updated": "2020-02-26T14:20:53.811817+00:00",
"links": {
"self": "//americinnmankato.com/api/files/44cc40bc-50fd-4107-b347-00838c79f4c1/dummy_example.pdf",
"version": "//americinnmankato.com/api/files/44cc40bc-50fd-4107-b347-00838c79f4c1/dummy_example.pdf?versionId=38a724d3-40f1-4b27-b236-ed2e43200f85",
"uploads": "//americinnmankato.com/api/files/44cc40bc-50fd-4107-b347-00838c79f4c1/dummy_example.pdf?uploads"
},
"is_head": true,
"delete_marker": false
}
# Old API
>>> # Get the 沉积 id from the previous response
>>> 沉积_id = r.json()['id']
>>> data = {'name': 'myfirstfile.csv'}
>>> files = {'file': open('/path/to/myfirstfile.csv', 'rb')}
>>> r = requests.post('//americinnmankato.com/api/deposit/depositions/%s/files' % 沉积_id,
... params={'access_token': ACCESS_TOKEN}, data=data,
... files=files)
>>> r.status_code
201
>>> r.json()
{
"checksum": "2b70e04bb31f2656ce967dc07103297f",
"name": "myfirstfile.csv",
"id": "eb78d50b-ecd4-407a-9520-dfc7a9d1ab2c",
"filesize": "27"
}
- 这是有关 旧文件API:
>>> data = {
... 'metadata': {
... 'title': 'My first upload',
... 'upload_type': 'poster',
... 'description': 'This is my first upload',
... 'creators': [{'name': 'Doe, John',
... 'affiliation': 'Zenodo'}]
... }
... }
>>> r = requests.put('//americinnmankato.com/api/deposit/depositions/%s' % 沉积_id,
... params={'access_token': ACCESS_TOKEN}, data=json.dumps(data),
... 标头s=标头s)
>>> r.status_code
200
- 最后缺少的就是添加一些元数据:
>>> r = requests.post('//americinnmankato.com/api/deposit/depositions/%s/actions/publish' % 沉积_id,
params={'access_token': ACCESS_TOKEN} )
>>> r.status_code
202
- 和我们’re ready 至 publish:
测试中
我们提供了一个沙盒环境,您可以在其中测试您的API集成 在开发过程中。可以在以下位置使用沙箱环境: http://sandbox.zenodo.org.
请注意,沙箱环境可以是 随时清洗. 另外,沙盒环境将使用10.5072前缀发布测试DOI instead of Zenodo’s普通前缀(10.5281)。
版本控制
REST API已版本化。我们努力不做出向后不兼容的更改 API,但如果这样做,我们将发布新版本。 变化 到 API记录在此页面上,并且预先通知在我们的 Twitter帐号.
认证方式
所有API请求都必须通过HTTPS进行身份验证。普通请求 HTTP将失败。我们支持通过OAuth 2.0进行身份验证。
创建个人访问令牌
- 寄存器 Zenodo帐户(如果您不这样做)’t already have 一。
- 去你的 应用领域, to 创建一个新令牌.
- 选择所需的OAuth范围(对于所需的快速入门教程,
deposit:write
和deposit:actions
).
使用访问令牌
访问令牌必须包含在所有请求中,如下所示:
GET /api/deposit/depositions?access_token=<ACCESS_TOKEN>
- an URL parameter (named
access_token
):
GET /api/deposit/depositions
Authorization: Bearer <ACCESS_TOKEN>
- or as HTTP request 标头 (
Authorization
):
范围
范围为您的访问令牌分配权限,以限制对数据和 Zenodo中的动作。存在以下范围:
名称 | 描述 |
---|---|
deposit:write |
授予写入内容的访问权限,但不允许发布上载内容。 |
deposit:actions |
授予对发布的发布,编辑和放弃编辑的访问权限。 |
要求
的 base URL of the API is //americinnmankato.com/api/
.
All POST
和 PUT
request bodies must be JSON格式 encoded, 和 must have content
type of application/json
unless specified otherwise in the specific 资源
(e.g. in the case of file uploads). 的 API will return a 415
error (see HTTP
status codes 和 错误回应)如果错了
提供了内容类型。
回应
{
"field1": "value",
"...": "..."
}
所有响应主体都是JSON编码(UTF-8编码)的。单一资源是 表示为JSON对象:
[
{
"field1": "value",
"...": "..."
}
"..."
]
资源的集合表示为JSON对象数组:
YYYY-MM-DDTHH:MM:SS+00:00
时间戳记采用UTC,并根据 ISO标准 8601:
HTTP状态码
我们使用以下HTTP状态代码来表示成功或失败 request.
码 | 名称 | 描述 |
---|---|---|
200 |
好 | 请求成功。包括回应。通常针对GET / PUT / PATCH请求发送。 |
201 |
已建立 | 请求成功。包括回应。通常发送用于POST请求。 |
202 |
公认 | 请求成功。包括回应。通常是为POST请求发送的,需要后台处理才能完成请求。 |
204 |
无内容 | 请求成功。没有回应。通常发送给DELETE请求。 |
400 |
错误的请求 | 请求失败。 错误回应 包括在内。 |
401 |
未经授权 | 由于访问令牌无效,请求失败。 错误回应 包括在内。 |
403 |
禁止的 | 由于缺少授权(例如,删除已提交的上传文件或缺少访问令牌的范围),请求失败。 错误回应 包括在内。 |
404 |
未找到 | 请求失败,原因是找不到资源。 错误回应 包括在内。 |
405 |
不允许的方法 | 由于HTTP方法不受支持,因此请求失败。 错误回应 包括在内。 |
409 |
冲突 | 由于资源的当前状态,请求失败(例如,编辑未完全集成的退役)。 错误回应 包括在内。 |
415 |
不支持的媒体类型 | Request failed, due 至 missing or invalid request 标头 Content-Type . 错误回应 包括在内。 |
429 |
请求太多 | 由于速率限制,请求失败。 错误回应 包括在内。 |
500 |
内部服务器错误 | 由于内部服务器错误,请求失败。错误回应 不 包括在内。唐’不必担心,Zenodo管理员已收到通知,将尽快处理此问题。 |
失误
400系列错误的错误响应(例如400、401、403,…) are returned as
a JSON格式 目的 with two attributes message
和 status
(HTTP status code), 和
possibly an attribute errors
with a list of more detailed errors.
{
"message": "存款ion not found",
"status": 404
}
没有更多详细错误的简单错误消息示例:
{
"message": "Validation error",
"status": 400,
"errors": [
{"code": 10, "message":"没有 t a valid choice", "field": "access_right"}
]
}
带有其他详细错误消息的错误消息示例:
的 attribute errors
is a JSON格式 对象数组, with the attributes message
和 code
, 和 possibly field
for validation errors.
实体
存款
表示
沉积资源用于在Zenodo上上载和编辑记录。
存款
领域 | 描述 |
---|---|
创造d 时间戳记 |
沉积的创建时间(采用ISO8601格式)。 |
doi 串 |
数字对象标识符(DOI)。当您发布论文时,我们会在以下位置注册DOI 数据城 进行上传,除非您手动向我们提供了一个。该字段仅适用于已发表的论文。 |
doi_url 网址 |
永久链接到您发表的论文。该字段仅适用于已发表的论文。 |
files 数组 |
的列表 沉积文件 资源。 |
id 整数 |
沉积物标识符 |
metadata 目的 |
A 沉积元数据 资源 |
modified 时间戳记 |
沉积的最后修改时间(采用ISO8601格式)。 |
owner 整数 |
沉积物所有者的用户标识。 |
记录_id 整数 |
记录标识符。该字段仅适用于已发表的论文。 |
记录_url 网址 |
此沉积记录的公开版本的URL。该字段仅适用于已发表的论文。 |
state 串 |
值之一: * inprogress : 存款ion metadata can be updated. If 沉积 is also unsubmitted (see submitted ) files can be updated as well. * done : 存款ion has been published. * error : 存款ion is in an error state - contact our support. |
submitted 布尔 |
沉积真值已发表,否则为假。 |
title 串 |
Title of 沉积 (automatically set from metadata ). Defaults 至 empty 串. |
存放元数据
属性 | 需要 | 描述 |
---|---|---|
upload_type 串 |
是 | 受控词汇:* publication : Publication* poster : Poster* presentation : Presentation* dataset : 数据set* image : Image* video : Video/Audio* software : Software* lesson : Lesson* physicalobject : Physical 目的* other : Other |
publication_type 串 |
是, if upload_type is "publication" . |
受控词汇:* annotationcollection : Annotation collection* book : Book* section : Book section* conferencepaper : Conference paper* datamanagementplan : 数据 management plan* article : Journal article* patent : Patent* preprint : Preprint* deliverable : Project deliverable* milestone : Project milestone* proposal : Proposal* report : Report* softwaredocumentation : Software documentation* taxonomictreatment : Taxonomic treatment* technicalnote : Technical note* thesis : 的sis* workingpaper : Working paper* other : Other |
image_type 串 |
是, if upload_type is "image" . |
受控词汇:* figure : Figure* plot : Plot* drawing : Drawing* diagram : Diagram* photo : Photo* other : Other |
publication_date 串 |
是 | Date of publication in ISO标准8601 format (YYYY-MM-DD ). Defaults 至 current 日期. |
title 串 |
是 | 沉积的标题。 |
creators 对象数组 |
是 | 证词的创建者/作者。每个数组元素都是具有以下属性的对象:* name : 名称 of creator in the format 姓氏,名字* affiliation : Affiliation of creator (optional).* orcid : ORCID identifier of creator (optional).* gnd : GND identifier of creator (optional).例: [{'name':'Doe, John', 'affiliation': 'Zenodo'}, {'name':'Smith, Jane', 'affiliation': 'Zenodo', 'orcid': '0000-0002-1694-233X'}, {'name': 'Kowalski, Jack', 'affiliation': 'Zenodo', 'gnd': '170118215'}] |
description 字符串(允许HTML) |
是 | 摘要或沉积说明。 |
access_right 串 |
是 | 受控词汇:* open : Open Access* embargoed : Embargoed Access* restricted : Restricted Access* closed : Closed Access Defaults 至 open . |
执照 串 |
是, if access_right is "open" or "embargoed" . |
受控词汇:所选的许可证适用于该存储中的所有文件,但不适用于根据以下内容许可的元数据 知识共享零。您可以通过我们的网站找到可用的许可证ID /api/licenses 终点. Defaults 至 cc-zero for datasets 和 cc-by for everything else. |
embargo_date 日期 |
是, if access_right is "embargoed" . |
系统将自动使存放的文件自动公开。默认为当前日期。 |
access_conditions 字符串(允许HTML) |
是, if access_right is "restricted" . |
指定授予用户访问上载文件的条件。要求访问权限的用户说明他们如何满足条件。根据理由,您可以决定授予/拒绝访问的人。您无权向用户授予授予对Zenodo上托管的数据的访问权的权利。 |
doi 串 |
没有 | 数字对象标识符。发布者是否已经为您保存的文件分配了DOI?如果没有,请将该字段留空,我们将在您发布时为您注册一个新的DOI。 DOI可以让其他人轻松而明确地引用您的证词。 |
prereserve_doi 对象/布尔 |
没有 | Set 至 true , 至 reserve a Digital Object Identifier (DOI). 的 DOI is automatically generated by our system 和 cannot be changed. Also, 的 DOI is not registered with 数据城 直到您发表论文,因此在此之前不能使用。如果需要将DOI包含在上载的文件中,或者需要将数据集DOI提供给发布者但尚未发布数据集,则保留DOI很有用。 REST API的响应将包括保留的DOI。 |
keywords 字符串数组 |
没有 | 此沉积的自由格式关键字。例: ["Keyword 1", "Keyword 2"] |
notes 字符串(允许HTML) |
没有 | 补充说明。 |
related_identifiers 对象数组 |
没有 | 相关出版物和数据集的永久标识符。支持的标识符包括:DOI,句柄,ARK,PURL,ISSN,ISBN,PubMed ID,PubMed Central ID,ADS书目代码,arXiv,生命科学标识符(LSID),EAN-13,ISTC,URN和URL。每个数组元素都是具有以下属性的对象:* identifier : 的 persistent identifier* relation : Relationship. Controlled vocabulary (isCitedBy , cites , isSupplementTo , isSupplementedBy , isNewVersionOf , isPreviousVersionOf , isPartOf , hasPart , compiles , isCompiledBy , isIdenticalTo , isAlternateIdentifier ).例: [{'relation': 'isSupplementTo', 'identifier':'10.1234/foo'}, {'relation': 'cites', 'identifier':'//doi.org/10.1234/bar'} ] 请注意,标识符类型(例如DOI)会自动检测到,并用于将标识符验证和标准化为标准格式。 |
contributors 对象数组 |
没有 | 沉积的贡献者(例如,编辑,数据策展人等)。每个数组元素都是具有以下属性的对象:* name : 名称 of creator in the format 姓氏,名字* type : Contributor type. Controlled vocabulary (联系Person , 数据Collector , 数据Curator , 数据Manager ,Distributor , 编辑or , Funder , HostingInstitution , Producer , ProjectLeader , ProjectManager , ProjectMember , RegistrationAgency , RegistrationAuthority , RelatedPerson , Researcher , ResearchGroup , RightsHolder ,Supervisor , Sponsor , WorkPackageLeader , Other )* affiliation : Affiliation of creator (optional).* orcid : ORCID identifier of creator (optional).* gnd : GND identifier of creator (optional).例: [{'name':'Doe, John', 'affiliation': 'Zenodo', 'type': 'Editor' }, ...] |
references 字符串数组 |
没有 | 参考文献列表。例: ["Doe J (2014). Title. 发布er. DOI", "Smith J (2014). Title. 发布er. DOI"] |
communities 对象数组 |
没有 | 您希望出现该沉积物的社区列表。社区所有者将收到通知,可以接受或拒绝您的请求。每个数组元素都是具有以下属性的对象:* identifier : Community identifier例: [{'identifier':'ecfunded'}] |
grants 对象数组 |
没有 | OpenAIRE支持的赠款清单,该赠款已资助了此项研究的研究。每个数组元素都是具有以下属性的对象:* id : grant ID.例: [{'id':'283595'}] (仅欧洲委员会资助)or funder DOI-prefixed: [{'id': '10.13039/501100000780::283595'}] (All grants, recommended) 接受的资助者DOI前缀: 澳大利亚研究理事会: 10.13039/501100000923 欧盟委员会: 10.13039/501100000780 基础技术基金会: 10.13039/501100001871 Ministarstvo Prosvete,纳伊克·特诺洛什科格·拉兹沃贾: 10.13039/501100004564 Ministarstvo Znanosti,Obrazovanja i Sporta: 10.13039/501100006588 国家卫生和医学研究理事会: 10.13039/501100000925 国家科学基金会: 10.13039/100000001 Nederlandse Organisatie voor Wetenschappelijk Onderzoek: 10.13039/501100003246 惠康信托: 10.13039/100004440 |
journal_title 串 |
没有 | 期刊标题(如果沉积是已发表的文章)。 |
journal_volume 串 |
没有 | 期刊量(如果沉积是已发表的文章)。 |
journal_issue 串 |
没有 | 期刊,如果沉积是已发表的文章。 |
journal_pages 串 |
没有 | 期刊页面(如果沉积是已发表的文章)。 |
conference_title 串 |
没有 | 会议标题(例如,第20届高能和核物理计算国际会议)。 |
conference_acronym 串 |
没有 | 会议的缩写(例如CHEP'13). |
conference_dates 串 |
没有 | 会议日期(例如2013年10月14日至18日)。如果指定了此字段,则还必须指定会议标题或缩写。 |
conference_place 串 |
没有 | 会议地点的格式为城市,国家/地区(例如,阿姆斯特丹,荷兰)。如果指定了此字段,则还必须指定会议标题或缩写。 |
conference_url 串 |
没有 | URL of conference (e.g. http://www.chep2013.org/). |
conference_session 串 |
没有 | 会议内的会议次数(例如VI)。 |
conference_session_part 串 |
没有 | 会话中的部分数(例如1)。 |
imprint_publisher 串 |
没有 | 书籍/报告/章节的出版商 |
imprint_isbn 串 |
没有 | 书/报告的ISBN |
imprint_place 串 |
没有 | 一本书/报告/每章的出版地点,格式为城市,国家/地区。 |
partof_title 串 |
没有 | 章节标题 |
partof_pages 串 |
没有 | 书页数 |
thesis_supervisors 对象数组 |
没有 | Supervisors of the thesis. Same format as for creators . |
thesis_university 串 |
没有 | 授予论文大学。 |
subjects 对象数组 |
没有 | 从分类法或受控词汇中指定主题。每个术语都必须唯一标识(例如URL)。对于自由格式的文本,请使用关键字字段。每个数组元素都是具有以下属性的对象:* term : Term from taxonomy or controlled vocabulary.* identifier : Unique identifier for term.* scheme : Persistent identifier scheme for id (automatically detected).例: [{"term": "Astronomy", "identifier": "http://id.loc.gov/authorities/subjects/sh85009003", "scheme": "url"}] |
version 串 |
没有 | 资源的版本。可以接受任何字符串,但是建议的格式是语义版本标记(请参阅有关语义版本的更多详细信息,网址为 semver.org)例: 2.1.5 |
language 串 |
没有 | 将记录的主要语言指定为ISO 639-2或639-3代码,请参见 国会图书馆ISO 639代码列表.例: eng |
locations 对象数组 |
没有 | 地点清单* lat (double): latitude * lon (double): longitude* place (string): place’s name (required)* description (string): place’s描述(可选)例: [{"lat": 34.02577, "lon": -118.7804, "place": "Los Angeles"}, {"place": "Mt.Fuji, Japan", "description": "Sample found 100ft from the foot of the mountain."}] |
日期s 对象数组 |
没有 | 日期间隔列表* start (ISO 日期 串): start 日期 (*) * end (ISO 日期 串): end 日期 (*)* type (Collected, Valid, Withdrawn): 的 interval’s type (required)* description (string): 的 interval’s描述(可选)(*) 没有 te that you have 至 specify at least a start or end 日期. For an exact 日期, use the same value for both start 和 end .例: [{"start": "2018-03-21", "end": "2018-03-25", "type": "Collected", "description": "Specimen A5 collection period."}] |
method 字符串(允许HTML) |
没有 | 用于研究或研究的方法。 |
清单
列出当前已认证用户的所有沉积。
import requests
response = requests.get('/api/deposit/depositions',
params={'q': 'my title',
'access_token': ACCESS_TOKEN})
print(response.json())
curl -i /api/deposit/depositions/?access_token=ACCESS_TOKEN
HTTP请求
GET /api/deposit/depositions
查询参数
参数 | 需要 | 描述 |
---|---|---|
q 串 |
可选的 | 搜索查询(使用Elasticsearch查询字符串语法)。 |
status 串 |
可选的 | Filter result based on deposit status (either draft or published ) |
sort 串 |
可选的 | 分类 order (bestmatch or mostrecent ). Prefix with minus 至 change form ascending 至 descending (e.g. -mostrecent ). |
page 整数 |
可选的 | 分页的页码。 |
size 整数 |
可选的 | 每页要返回的结果数。 |
成功回应
- 码:
200 好
- 身体:的数组 沉积 资源。
错误回应
看到 HTTP状态码 (400和500系列错误)和 错误回应.
创造
创建一个新的沉积资源。
curl -i -H "Content-Type: application/json" -X POST
--data '{}' /api/deposit/depositions/?access_token=ACCESS_TOKEN
# or
curl -i -H "Content-Type: application/json" -X POST
--data '{"metadata": {"title": "My first upload", "upload_type": "poster", "description": "This is my first upload", "creators": [{"name": "Doe, John", "affiliation": "Zenodo"}]}}' /api/deposit/depositions/?access_token=ACCESS_TOKEN
import json
import requests
网址 = "/api/deposit/depositions/?access_token=ACCESS_TOKEN"
标头s = {"Content-Type": "application/json"}
r = requests.post(网址, data="{}", 标头s=标头s)
HTTP请求
POST /api/deposit/depositions
请求头
Content-Type: application/json
数据
An empty JSON格式 目的 {}
or a 沉积元数据资源。例: {"metadata": {"upload_type": "presentation" } }
范围
deposit:write
成功回应
- 码:
201 已建立
- 身体: 一种 沉积 资源。
错误回应
看到 HTTP状态码 (400和500系列错误)和 错误回应.
取回
检索单个沉积资源。
curl -i /api/deposit/depositions/1234?access_token=ACCESS_TOKEN
import requests
r = requests.get("/api/deposit/depositions/1234?access_token=ACCESS_TOKEN")
HTTP请求
GET /api/deposit/depositions/:id
成功回应
- 码:
200 好
- 身体: 一种 沉积 资源。
错误回应
看到 HTTP状态码 (400和500系列错误)和 错误回应。 |
更新资料
更新现有的沉积资源。
curl -i -H "Content-Type: application/json" -X PUT
--data '{"metadata": {"title": "My first upload", "upload_type": "poster", "description": "This is my first upload", "creators": [{"name": "Doe, John", "affiliation": "Zenodo"}]}}' //americinnmankato.com/api/deposit/depositions/1234?access_token=ACCESS_TOKEN
import json
import requests
data = {
"metadata": {
"title": "My first upload",
"upload_type": "poster",
"description": "This is my first upload",
"creators": [
{"name": "Doe, John", "affiliation": "Zenodo"}
]
}
}
网址 = "//americinnmankato.com/api/deposit/depositions/1234?access_token=ACCESS_TOKEN"
标头s = {"Content-Type": "application/json"}
r = requests.put(网址, data=json.dumps(data), 标头s=标头s)
HTTP请求
PUT /api/deposit/depositions/:id
请求头
Content-Type: application/json
范围
deposit:write
{
"metadata": {
"upload_type": "presentation",
"...": "..."
}
}
数据参数
A 沉积元数据 资源。
成功回应
- 码:
200 好
- 身体: 一种 沉积 资源。
错误回应
看到 HTTP状态码 (400和500系列错误)和 错误回应.
删除
删除现有的沉积资源。请注意,只有未发表的论文可以 be deleted.
curl -i //americinnmankato.com/api/deposit/depositions/1234?access_token=ACCESS_TOKEN -X DELETE
import requests
r = requests.delete('//americinnmankato.com/api/deposit/depositions/1234',
params={'access_token': ACCESS_TOKEN})
HTTP请求
DELETE /api/deposit/depositions/:id
范围
deposit:write
成功回应
- 码:
201 已建立
- 身体:空。
错误回应
404 没有 t found
:不存在沉积。403 禁止的
:删除已经发布的内容。
也可以看看 HTTP状态码 (400和500系列错误)和 错误回应.
沉积文件
表示
沉积文件资源用于上载和编辑文件的资源。 在Zenodo上的沉积。
沉积文件
属性 | 描述 |
---|---|
id 串 |
沉积文件标识符 |
filename 串 |
文件名 |
filesize 整数 |
文件大小(以字节为单位) |
checksum 串 |
文件的MD5校验和,由我们的系统计算得出。这使您可以检查上载文件的完整性。 |
清单
列出给定沉积的所有沉积文件。
curl -i //americinnmankato.com/api/deposit/depositions/1234/files?access_token=ACCESS_TOKEN
import requests
r = requests.get('//americinnmankato.com/api/deposit/depositions/1234/files',
params={'access_token': ACCESS_TOKEN})
HTTP请求
GET /api/deposit/depositions/:id/files
成功回应
- 码:
200 好
- 身体:的数组 沉积文件 资源。
错误回应
看到 HTTP状态码 (400和500系列错误)和 错误回应.
创造
上载新文件。
curl -i //americinnmankato.com/api/deposit/depositions/1234/files?access_token=ACCESS_TOKEN
-F name=myfirstfile.csv
-F file=@path/to/local_file.csv
import json
import requests
网址 = '//americinnmankato.com/api/deposit/depositions/1234/files?access_token=ACCESS_TOKEN'
data = {'name': 'myfirstfile.csv'}
files = {'file': open('path/to/local_file.csv', 'rb')}
r = requests.post(网址, data=data, files=files)
HTTP请求
POST /api/deposit/depositions/:id/files
请求头
Content-Type: multipart/form-data
范围
deposit:write
成功回应
- 码:
201 已建立
- 身体: 一种 沉积文件 资源。
错误回应
看到 HTTP状态码 (400和500系列错误)和 错误回应.
分类
排序文件以进行沉积。默认情况下,第一个文件显示在文件中 preview.
curl -i //americinnmankato.com/api/deposit/depositions/1234/files?access_token=ACCESS_TOKEN -X PUT
-H "Content-Type: application/json"
--data '[{"id":"21fedcba-9876-5432-1fed-cba987654321"}, {"id":"12345678-9abc-def1-2345-6789abcdef12"}]'
import json
import requests
网址 = '//americinnmankato.com/api/deposit/depositions/1234/files?access_token=ACCESS_TOKEN'
标头s = {"Content-Type": "application/json"}
data = [{'id': '21fedcba-9876-5432-1fed-cba987654321'},
{'id': '12345678-9abc-def1-2345-6789abcdef12'}]
r = requests.put(网址, data=json.dumps(data), 标头s=标头s)
HTTP请求
PUT /api/deposit/depositions/:id/files
请求头
Content-Type: application/json
范围
deposit:write
数据
部分的JSON数组 沉积文件 仅资源
the id
attribute. 例:
[
{"id": "<file_id_1>"},
{"id": "<file_id_2>"},
"..."
]
成功回应
- 码:
200 好
- 身体:的数组 沉积文件 资源。
错误回应
看到 HTTP状态码 (400和500系列错误)和 错误回应.
取回
检索单个沉积文件。
curl -i //americinnmankato.com/api/deposit/depositions/1234/files/12345678-9abc-def1-2345-6789abcdef12?access_token=ACCESS_TOKEN
import requests
r = requests.get('//americinnmankato.com/api/deposit/depositions/1234/files/12345678-9abc-def1-2345-6789abcdef12',
params={'access_token': ACCESS_TOKEN})
HTTP请求
GET /api/deposit/depositions/:id/files/:file_id
成功回应
- 码:
200 好
- 身体: 一种 沉积文件 资源。
错误回应
看到 HTTP状态码 (400和500系列错误)和 错误回应.
更新资料
更新沉积文件资源。目前,唯一的用途是重命名已 上传的文件。如果您要替换实际文件,请删除该文件并 upload a new file.
curl -i //americinnmankato.com/api/deposit/depositions/1234/files/21fedcba-9876-5432-1fed-cba987654321?access_token=ACCESS_TOKEN -X PUT
-H "Content-Type: application/json"
--data '{"filename": "someothername.csv"}'
import json
import requests
网址 = '//americinnmankato.com/api/deposit/depositions/1234/files/21fedcba-9876-5432-1fed-cba987654321?access_token=ACCESS_TOKEN'
标头s = {"Content-Type": "application/json"}
data = {"name": "someothername.csv"}
r = requests.put(网址, data=json.dumps(data), 标头s=标头s)
HTTP请求
PUT /api/deposit/depositions/:id/files/:file_id
请求头
Content-Type: application/json
范围
deposit:write
数据
部分 沉积文件 资源只有
filename
属性。例:
{
"name": "<new_file_name>"
}
成功回应
- 码:
200 好
- 身体: 一种 沉积文件 资源。
错误回应
看到 HTTP状态码 (400和500系列错误)和 错误回应.
删除
删除现有的沉积文件资源。注意,仅用于的沉积文件 未发布的内容可能会被删除。
curl -i -X DELETE //americinnmankato.com/api/deposit/depositions/1234/files/21fedcba-9876-5432-1fed-cba987654321?access_token=ACCESS_TOKEN
import requests
r = requests.delete('//americinnmankato.com/api/deposit/depositions/1234/files/21fedcba-9876-5432-1fed-cba987654321',
params={'access_token': ACCESS_TOKEN})
HTTP请求
DELETE /api/deposit/depositions/:id/files/:file_id
范围
deposit:write
成功回应
- 码:
204 无内容
- 身体:空。
错误回应
404 没有 t found
:沉积文件不存在。403 禁止的
:删除已经发布的内容。
也可以看看 HTTP状态码 (400和500系列错误)和 错误回应.
沉积动作
发布
发表论文。请注意,发表论文后,您将无法再 delete it.
curl -i -X POST //americinnmankato.com/api/deposit/depositions/1234/actions/publish?access_token=ACCESS_TOKEN
import requests
r = requests.post('//americinnmankato.com/api/deposit/depositions/1234/actions/publish',
params={'access_token': ACCESS_TOKEN})
HTTP请求
POST /api/deposit/depositions/:id/actions/publish
范围
deposit:actions
成功回应
- 码:
202 公认
- 身体: 一种 沉积 资源。
错误回应
看到 HTTP状态码 (400和500系列错误)和 错误回应.
编辑
解锁已提交的沉积以进行编辑。
curl -i -X POST //americinnmankato.com/api/deposit/depositions/1234/actions/edit?access_token=ACCESS_TOKEN
import requests
r = requests.post('//americinnmankato.com/api/deposit/depositions/1234/actions/edit',
params={'access_token': ACCESS_TOKEN})
HTTP请求
POST /api/deposit/depositions/:id/actions/edit
范围
deposit:actions
成功回应
- 码:
201 已建立
- 身体: 一种 沉积 资源。
错误回应
400 错误的请求
:沉积状态不允许编辑(例如, depositions in stateinprogress
).409 冲突
:沉积正在整合中,请稍后 5分钟后再试一次。
看到 HTTP状态码 (400和500系列错误)和 错误回应.
丢弃
放弃当前编辑会话中的更改。
curl -i -X POST //americinnmankato.com/api/deposit/depositions/1234/actions/discard?access_token=ACCESS_TOKEN
import requests
r = requests.post('//americinnmankato.com/api/deposit/depositions/1234/actions/discard',
params={'access_token': ACCESS_TOKEN})
HTTP请求
POST /api/deposit/depositions/:id/actions/discard
范围
deposit:actions
成功回应
- 码:
201 已建立
- 身体: 一种 沉积 资源。
错误回应
400 错误的请求
:沉积不被编辑。
看到 HTTP状态码 (400和500系列错误)和 错误回应.
新版本
创建沉积的新版本。
此操作将创建一个新的存放区,该存放区将是当前资源的快照,并继承元数据以及文件的快照。 新版本的寄存将具有与未发布的新寄存相似的状态,最重要的是,其文件将可以更改为新寄存。
在任何时候都只能使用一次未发布的新版本存储,即:只要未发布或删除第一次调用产生的新版本存储,多次调用新版本操作将无效。
笔记:
-此操作的响应主体不是新版本存放,而是原始资源。
The new version 沉积 can be accessed through the "latest_draft"
under "links"
in the response body.
- 的 id
used 至 创造 this new version has 至 be the id
of the latest version. It is not possible 至 use the global id that references all the versions.
curl -i -X POST //americinnmankato.com/api/deposit/depositions/1234/actions/newversion?access_token=ACCESS_TOKEN
import requests
r = requests.post('//americinnmankato.com/api/deposit/depositions/1234/actions/newversion',
params={'access_token': ACCESS_TOKEN})
HTTP请求
POST /api/deposit/depositions/:id/actions/newversion
范围
deposit:actions
成功回应
- 码:
201 已建立
- 身体: 一种 沉积 资源。
错误回应
看到 HTTP状态码 (400和500系列错误)和 错误回应.
记录
表示
记录资源用于搜索已发布的记录。
清单
列出所有打开的访问记录。
import requests
response = requests.get('//americinnmankato.com/api/records',
params={'q': 'my title',
'access_token': ACCESS_TOKEN})
print(response.json())
curl -i /api/records/?access_token=ACCESS_TOKEN
HTTP请求
GET /api/records/
查询参数
参数 | 需要 | 描述 |
---|---|---|
q 串 |
可选的 | 搜索查询(使用Elasticsearch查询字符串语法)。 |
status 串 |
可选的 | Filter result based on the deposit status (either draft or published ) |
sort 串 |
可选的 | 分类 order (bestmatch or mostrecent ). Prefix with minus 至 change form ascending 至 descending (e.g. -mostrecent ). |
page 整数 |
可选的 | 分页的页码。 |
size 整数 |
可选的 | 每页要返回的结果数。 |
communities 串 |
可选的 | Return 记录s that are part of the specified communities. (Use of community identifier ) |
type 串 |
可选的 | Return 记录s of the specified type. (Publication , Poster , Presentation …) |
subtype 串 |
可选的 | Return 记录s of the specified subtype. (Journal article , Preprint , Proposal …) |
bounds 串 |
可选的 | Return 记录s filtered by a geolocation bounding box. (Format bounds=143.37158,-38.99357,146.90918,-37.35269 ) |
custom 串 |
可选的 | Return 记录s containing the specified custom keywords. (Format custom=[field_name]:field_value ) |
标头
可以通过在标题中指定搜索的响应格式来请求它。
接受 | 描述 |
---|---|
application/json |
JSON格式 |
application/vnd.zenodo.v1+json |
Zenodo |
application/marcxml+xml |
马克XML |
application/x-bibtex |
比比克斯 |
application/x-datacite+xml |
数据引用XML |
application/x-dc+xml |
都柏林核心区 |
成功回应
- 码:
200 好
- 身体:的数组 记录 资源。
错误回应
看到 HTTP状态码 (400和500系列错误)和 错误回应.
搜索指南
也可以通过搜索框在Zenodo网站上执行高级搜索查询。这记录在 搜索指南
取回
检索单个记录。
curl -i //americinnmankato.com/api/records/1234
import requests
r = requests.get("//americinnmankato.com/api/records/1234)
HTTP请求
GET //americinnmankato.com/api/records/:id
同样,搜索的输出格式可以在 标头
成功回应
- 码:
200 好
- 身体: 一种 记录.
错误回应
看到 HTTP状态码 (400和500系列错误)和 错误回应。 |
执照
表示
许可证资源用于提供许可证元数据,该元数据可以是 应用于Zenodo上的上传内容。
执照
领域 | 描述 |
---|---|
创造d 时间戳记 |
许可证的创建时间(ISO8601格式)。 |
updated 时间戳记 |
沉积的最后修改时间(采用ISO8601格式)。 |
metadata 目的 |
的 许可证元数据 资源 |
许可证元数据
属性 | 描述 |
---|---|
id 串 |
许可证的标识符。例: cc-by-nc-4.0 |
title 串 |
许可证名称例: GNU普通通用公共许可证v3.0 |
网址 串 |
许可证的URL例: http://www.opensource.org/licenses/MIT |
清单
搜索许可证。
import requests
response = requests.get('/api/licenses/')
print(response.json())
curl /api/licenses/
HTTP请求
GET /api/licenses/
查询参数
参数 | 需要 | 描述 |
---|---|---|
q 串 |
可选的 | 搜索查询(使用Elasticsearch查询字符串语法)。 |
page 整数 |
可选的 | 分页的页码。 |
size 整数 |
可选的 | 每页要返回的结果数。 |
成功回应
- 码:
200 好
- 身体:的数组 执照 资源。
错误回应
看到 HTTP状态码 (400和500系列错误)和 错误回应。 |
取回
检索单个许可证资源。
import requests
r = requests.get("/api/licenses/cc-by-nc-4.0")
curl /api/licenses/cc-by-nc-4.0
HTTP请求
GET /api/licenses/:id
成功回应
- 码:
200 好
- 身体: 一种 执照 资源。
错误回应
看到 HTTP状态码 (400和500系列错误)和 错误回应。 |
变化
2017-10-04
- Added new 可选的 field
version
沉积元数据。 - Added new 可选的 field
language
沉积元数据。
2017-06-15
- 作为存款操作的一部分,增加了对DOI版本控制的支持。
2016-09-12
- 增加了对搜索,分页,排序和过滤的支持。
- 速度明显提高。
2015-10-06
- Added new 可选的 field
contributors
沉积元数据。 - Added new 可选的 field
subjects
沉积元数据。 - Added new 可选的 subfield
gnd
至creators
在沉积元数据中。
2014-12-20
- Added new relationship
isAlternateIdentifier
in subfieldrelation
至related_identifiers
在沉积元数据中。
2014-12-10
- Added new relationships
hasPart
,isPartOf
&isIdenticalTo
in subfieldrelation
至related_identifiers
在沉积元数据中。
2014-11-20
- Added new 可选的 subfield
orcid
至creators
在沉积元数据中。
2014-10-21
- Added new 可选的 fields
conference_session
和conference_session_part
沉积元数据。
2014-09-09
- Added new 可选的 field
references
沉积元数据。
2014-06-13
- 身份验证从API密钥更改为OAuth 2.0。 API密钥身份验证为 已弃用,将于2014年10月淘汰。请使用 个人 access 至kens 而不是API密钥。
2013-12-18
REST API版本1.0最终版本:
- 沉积动作 moved from
deposit/depositions/:id/action
至deposit/depositions/:id/actions
- Added
edit
和discard
沉积 action 资源。 - 沉积资源表示:
state
:受控词汇已更改。submitted
:数据类型从“时间戳”更改为“布尔”。
2013-11-13
REST API初始版本候选。
OAI-PMH
Zenodo允许您通过Open Archives收集我们的整个存储库 元数据收集倡议协议(OAI- PMH)。 OAI-PMH是被广泛使用的协议 收集元数据和最受欢迎的存储库软件为 this protocol.
所有元数据均已获得许可 创作共用 Zero,而数据文件可能是打开的 访问并受元数据中描述的许可或封闭访问的约束,并且 不可下载。
基本网址
//americinnmankato.com/oai2d
恢复令牌
恢复令牌仅对 2分钟. In case a 至ken expired, you will receive a 422 Unprocessable Entity
HTTP error.
速率限制
OAI-PMH API的等级与REST API一样受到限制-即您将收到
a 429 请求太多
HTTP error if you exceed the limit.
元数据格式
每个记录的元数据有几种格式。可用格式 include:
oai_datacite
OAI 数据城(最新架构版本)—此元数据格式为 专为使用以下方式传播DataCite记录而建立 OAI-PMH。除了原始的DataCite元数据外,此格式还包含 其他几个描述元数据版本的元素,无论它是 参考质量和注册数据中心。有关更多信息 此格式及其架构,请参阅 数据城 OAI模式 网站。
这种元数据格式将始终根据最新的 可用的DataCite模式版本。
oai_datacite3
OAI 数据城-此元数据格式是专门为 使用OAI-PMH传播DataCite记录。除了原来的 DataCite v3.0元数据,此格式包含其他几个描述元素 元数据的版本,是否具有参考质量,以及 注册数据中心。有关此格式及其架构的更多信息 please see the 数据城 OAI模式 网站。
datacite
数据城(最新版本)—此元数据格式仅包含原始 DataCite元数据,无需根据最新内容进行添加或更改 DataCite模式。请注意,此格式不是OAI-PMH 2.0版 compliant.
datacite3
数据城 v3.0-此元数据格式仅包含原始DataCite 无需添加或更改的元数据。这种格式的架构可以 不存在,元数据将无法对其进行验证。请注意 格式不符合OAI-PMH 2.0版。
oai_dc
都柏林核心-这种格式仅包含最少的元数据。格式根据 OpenAIRE准则.
marc21
MARC21-主要出于遗留原因而支持导出格式。请考虑 使用其他导出格式之一,因为我们可能会停止对MARC21的支持。
套装
我们支持收获 整个仓库 以及 可选择的 harvesting 社区。
整个仓库
为了收获整个存储库,您可以不带OAI-PMH请求 通过任何设置规范。
user-<identifier>
社区集-允许选择性收获特定社区。更换
<identifier>
与社区标识符。另外,每个社区
在首页上提供直接的收割API链接,其中包括
正确的社区标识符。
如果您需要选择性收割并且上述情况不支持您的用例 sets, please 联系我们 我们可能 为您创建一个特定的集合。
更新时间表
大多数更新可立即获得,一些更新仅在每小时一次的OAI集中反映出来。
变化
2016-09-12
- Deprecated metadata formats
datacite3
和oai_datacite3
. End of life is 2018年2月。 - 移除了0.5个请求/秒的速率限制。
- 由于我们的重大更新,恢复令牌的到期时间已更改为两分钟 基础存储库软件。
2014-03-10
- Added metadata formats
datacite3
和oai_datacite3
至 support 数据城 v3.0.
2013-05-08
OAI-PMH API的初始版本。