Repository navigation
API v0
Every application/user that wishes to use the DMPHub API must have an account registered within the system. To register an application you will need to add an entry into the following tables:
-
api_clientsthis is the primary API Client table. The name of the client should be lower case. -
provenancesthis table is used to relate an entry in one of the DMP tables to the API Client. Thenamemust match the one in theapi_clientstable. -
api_client_permissionsan entry for each type of permission the client is allowed to perform should be added here. See the enum on the ApiClientPermission model for a list of possible permissions.
See the 'Security' section of the main README.md for details about adding these records.
At some point in the near future we will be adding an Admin login that will include a UI page that allows you to perform these actions via the website.
curl -v -X POST http://localhost:3000/api/v0/authenticate
-H "Accept: application/json"
-d "grant_type=client_credentials&client_id=[my application uid]&client_secret=[my application secret]"Returns 40x errors when you send invalid credentials, are unauthorized or your token has expired Unauthorized
Returns a 200 and the authorization token as JSON like the following when successful:
{
"access_token":"eyJhbGciOiJIUzI1NiJ9.eyJjbGllbnRfaWQiOiJKeWJ3UHEzeHphZ1pBRGUtSUNTUWxtVEhsT1FLRnplNllmZ1pIOFhMSm5VIiwiZXhwIjoxNjAxNDE4Mzc1fQ.GUxmND3qEY9RACn7Oq1N0mhg1p0M7Z3PuV-vDZOabZg",
"token_type":"Bearer",
"expires_in":1601418375,
"created_at":"2020-09-28T22:26:15:00Z"
}This token should then be passed along with a Server-Agent in the Headers of all subsequent requests to the API as follows:
-H "Content-Type: application/json"
-H "Accept: application/json"
-H "User-Agent: [api_clients.name] ([api_clients.client_id])"
-H "Authorization: Bearer [token]"For example:
curl -v http://localhost:3000/api/v0/data_management_plans
-H "Content-Type: application/json"
-H "Accept: application/json"
-H "User-Agent: dmphub (1234567890)"
-H "Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJjbGllbnRfaWQiOiJKeWJ3UHEzeHphZ1pBRGUtSUNTUWxtVEhsT1FLRnplNllmZ1pIOFhMSm5VIiwiZXhwIjoxNjAxNDE4Mzc1fQ.GUxmND3qEY9RACn7Oq1N0mhg1p0M7Z3PuV-vDZOabZg"Results are returned as a subset of the JSON in the RDA Common Standard format. The response contains the DMP's title, DOI and other high level information that would be relevant in helping you identify records.
Note that each DMP's JSON contains an "dmphub_links" array which contains all of the available REST API calls for that DMP. You can use the 'get' link to retrieve the full metadata for that DMP (see below for an example of the full metadata record).
When there are multiple pages of results, you can use the "next" and "prev" links returned in the top level of the JSON response.
See above for the appropriate HTTP headers to send along with your request
curl -v http://localhost:3000/api/v0/data_management_plans
This will return a 404 Not Found for invalid or unauthorized requests.
If successful it will return a list of your Data Management Plans and their primary contact as JSON. For example:
{
"application": "dmphub",
"status": "OK",
"code": 200,
"time": "2020-09-28T22:33:25:00Z",
"caller": "dmphub",
"source": "GET https://dmphub-stg.cdlib.org/api/v0/data_management_plans",
"page": 2,
"per_page": 20,
"total_items": 63,
"prev": "https://dmphub-stg.cdlib.org/api/v0/data_management_plans?page=1",
"next": "https://dmphub-stg.cdlib.org/api/v0/data_management_plans?page=3",
"items": [
{
"dmp": {
"schema":"https://github.com/RDA-DMP-Common/RDA-DMP-Common-Standard/tree/master/examples/JSON/JSON-schema/1.0",
"extensions": [
{ "name": "dmphub", "uri": "https://github.com/CDLUC3/dmphub-json-schema" },
{ "name": "dmproadmap", "uri": "https://github.com/DMPRoadmap/api-json-schema" }
],
"title": "My sample DMP",
"created": "2020-08-27T16:01:58:00Z",
"modified": "2020-08-27T16:01:58:00Z",
"dmp_id": {
"type": "DOI",
"identifier": "https://doi.org/10.9999/ABCDEFG"
},
"contact": {
"name": "Jane Doe",
"affiliation":{
"name": "Some University",
"affiliation_id": {
"type": "ROR",
"identifier": "https://ror.org/0000001"
}
}
},
"dmphub_links": {
"get": "http://localhost:3001/api/v0/data_management_plans/doi:10.9999/ABCDEFG",
"post": "http://localhost:3001/api/v0/data_management_plans",
"put": "http://localhost:3001/api/v0/data_management_plans/doi:10.9999/ABCDEFG",
"delete": "http://localhost:3001/api/v0/data_management_plans/doi:10.9999/ABCDEFG"
}
}
},
{
"dmp": "..."
}
]
}The DMP is returned as JSON in the RDA Common Standard format. Note that the example below contains a complete metadata record. The DMP you are retrieving may not contain all elements from the common standard. In situations where no data is available for a particular field, then it is omitted from the JSON. For example if your DMP's dataset has no distribution information, then the distribution portion of the record will not appear in the JSON response.
See above for the appropriate HTTP headers to send along with your request (be sure to include the doi: prefix)
curl -v http://localhost:3000/api/v1/data_management_plans/doi:10.9999/ABCDEFG
Note that the 'is_metadata_for' link in the 'dmproadmap_related_identifiers' section is the link back to the original system's DMP. For example if a researcher created a DMP in SystemA and SystemA in sent the metadata to the DMPHub, then the 'is_metadata_for' URL would point back to SystemA's page for the current version of the DMP.
This will return a 404 not found if the DMP does not exist or if you are unauthorized to retrieve it.
Example success message:
{
"application": "dmphub",
"status": "OK",
"code": 200,
"time": "2020-09-28T22:44:19:00Z",
"caller": "dmphub",
"source": "GET https://dmphub-stg.cdlib.org/api/v0/data_management_plans/10.9999/ABCDEFG",
"page": 1,
"per_page": 20,
"total_items": 1,
"items": [
{
"dmp": {
"schema": "https://github.com/RDA-DMP-Common/RDA-DMP-Common-Standard/tree/master/examples/JSON/JSON-schema/1.0",
"extensions": [
{ "name": "dmphub", "uri": "https://github.com/CDLUC3/dmphub-json-schema" },
{ "name": "dmproadmap", "uri": "https://github.com/DMPRoadmap/api-json-schema" }
],
"title": "Sample DMP",
"description": "An abstract for our sample data management plan.",
"created": "2020-08-27T16:01:58:00Z",
"modified": "2020-08-27T16:01:58:00Z",
"language": "eng",
"ethical_issues_exist": "yes",
"ethical_issues_description": "Our datasets will be based off of patient information",
"ethical_issues_report": "https://some.uni.org/privacy_policy.html",
"dmp_id": {
"type": "DOI",
"identifier": "https://doi.org/10.0000/AB12CD34"
},
"contact": {
"name": "Jane Doe",
"mbox": "jane.doe@sample.edu",
"contact_id": {
"type": "ORCID",
"identifier": "https://orcid.org/0000-0000-0000-0000"
},
"affiliation": {
"name": "Some University",
"affiliation_id": {
"type": "ROR",
"identifier": "https://ror.org/000000"
}
}
},
"contributor": [
{
"name": "John Doe",
"mbox":"john.doe@another.edu",
"affiliation": {
"name": "Another University",
"affiliation_id": {
"type": "ROR",
"identifier": "https://ror.org/000009"
}
},
"contributor_id": {
"type": "ORCID",
"identifier": "https://orcid.org/0000-0000-0000-000X"
},
"role": [
"https://dictionary.casrai.org/Contributor_Roles/Data_curation",
"https://dictionary.casrai.org/Contributor_Roles/Investigation"
]
}
],
"cost": [
{
"currency_code": "USD",
"title": "Long term server storage",
"description": "The cost of storing the research outputs for preservation",
"value": 10500
}
],
"project": [
{
"title": "Sample DMP project",
"description": "An abstract describing what this project is about.",
"start": "2020-08-27T15:14:09:00Z",
"end": "2022-08-27T15:14:09:00Z",
"funding": [
{
"name": "National Science Foundation (NSF)",
"funder_id": {
"type": "ROR",
"identifier": "https://ror.org/00000X"
},
"funding_status": "granted",
"grant_id": {
"type": "URL",
"identifier": "https://nsf.org/awards/123abc"
},
"extension": {
"dmphub": {
"funded_affiliations": [
{
"name": "Another University",
"affiliation_id": {
"type": "ROR",
"identifier": "https://ror.org/000009"
}
}
]
}
}
}
]
}
],
"dataset": [
{
"title": "Dataset: Sample dataset A",
"type": "dataset",
"personal_data": "unknown",
"sensitive_data": "unknown",
"data_quality_assurance": "Our data will be of very high quality!",
"dataset_id": {
"type": "DOI",
"identifier": "https://doix.org/10.1234.123abc/y3"
},
"description": "A collection of MRI scans of cerebral cortex for all candidates",
"distribution": [
{
"title": "Open access copy of Dataset A",
"access_url": "https://secure.repo.org/dataset/12345",
"available_until": "2050-01-01",
"byte_size": 10000,
"data_access": "open",
"description": "Open access copy of the dataset",
"download_url": "https://secure.repo.org/dataset/12345.pdf",
"format": "image/tiff",
"host": {
"title": "Dryad",
"availability": "99,5",
"backup_frequency": "weekly",
"backup_type": "tapes",
"certified_with": "coretrustseal",
"description": "Merritt repository via Dryad",
"geo_location": "US",
"pid_system": "doi",
"storage_type": "AWS cloud disk",
"support_versioning": "yes",
"url": "https://datadryad.org"
},
"license": [
{
"license_ref": "https://creativecommons.org/licenses/by/4.0/",
"start_date": "2019-06-30"
}
]
}
],
"issued": "2020-09-13T08:48:12",
"keyword": ["brain", "cerebral", "squishy"],
"language": "eng",
"metadata": [
{
"description": "Some biological sample standard",
"language": "eng",
"metadata_standard_id": {
"type": "url",
"identifier": "https://some.standard.org/biology"
}
}
],
"preservation_statement": "We will preserve the data long term.",
"security_and_privacy": [
{
"title": "Patient personal information",
"description": "We are going to anonymize all of the patient personal info"
}
],
"technical_resource": [
{
"title": "123/45/43/AT",
"description": "MRI scanner"
}
]
}
],
"dmphub_links": {
"get": "http://localhost:3001/api/v0/data_management_plans/doi:10.9999/ABCDEFG",
"post": "http://localhost:3001/api/v0/data_management_plans",
"put": "http://localhost:3001/api/v0/data_management_plans/doi:10.9999/ABCDEFG",
"delete": "http://localhost:3001/api/v0/data_management_plans/doi:10.9999/ABCDEFG"
},
"related_identifiers": [
{ "type": "URL", "identifier": "https://www.example.org/project/1234/plan/123", "descriptor": "is_metadata_for" },
{ "type": "URL", "identifier": "https://doi.org/10.0000/1234.ZZZ", "descriptor": "is_referenced_by" }
]
}
}
]
}You should send the DMP as JSON in the RDA Common Standard format. See above for an example of the JSON.
See above for the appropriate HTTP headers to send along with your request
curl -v http://localhost:3000/api/v1/data_management_plans/10.0000/AB12CD34
Note that you can create DMPs if you have permission to do so.
curl -v -X POST http://localhost:3000/api/v1/data_management_plansIf successful an HTTP 201 - 'Created' status will be returned along with the full RDA Common Standard JSON for the DMP. Note that the dmp_id attribute will contain the new DMP ID (DOI) for your DMP.
If there is an issue with the JSON format, or a required attribute is missing then you will receive a 400 'Bad Request' response from the system with information about what the issue was in the 'errors' array. For example:
{
"application": "dmphub",
"status": "Bad Request",
"code": 400,
"time": "2020-09-28T22:44:19:00Z",
"caller": "dmphub",
"source": "POST https://dmphub-stg.cdlib.org/api/v0/data_management_plans",
"page": 1,
"per_page": 20,
"total_items": 0,
"items": [],
"errors": ["Invalid JSON format", "DataManagementPlan - title cannot by blank"]
}You should send the full DMP as JSON in the RDA Common Standard format. See above for an example of the JSON. Note that you should use the DMP ID (DOI) in the URL.
See above for the appropriate HTTP headers to send along with your request
curl -v http://localhost:3000/api/v1/data_management_plans/10.0000/AB12CD34
Note that you can only update DMPs that you have created or have been given permission to edit.
curl -v -X PUT http://localhost:3000/api/v1/data_management_plans/10.123/123ABC00If successful an HTTP 200 - 'Success' status will be returned along with the full RDA Common Standard JSON for the DMP (See above for an example). Note that the dmp_id attribute will contain the new DMP ID (DOI) for your DMP.
If there is an issue with the JSON format, or a required attribute is missing then you will receive a 400 'Bad Request' response from the system with information about what the issue was in the 'errors' array. For example:
{
"application": "dmphub",
"status": "Bad Request",
"code": 400,
"time": "2020-09-28T22:44:19:00Z",
"caller": "dmphub",
"source": "PUT https://dmphub-stg.cdlib.org/api/v0/data_management_plans/10.0000/AB12CD34",
"page": 1,
"per_page": 20,
"total_items": 0,
"items": [],
"errors": ["Invalid JSON format", "DataManagementPlan - title cannot by blank"]
}You should send the full DMP as JSON in the RDA Common Standard format. See above for an example of the JSON. Note that you should use the DMP ID (DOI) in the URL.
See above for the appropriate HTTP headers to send along with your request
curl -v http://localhost:3000/api/v1/data_management_plans/10.0000/AB12CD34
Note that you can only delete DMPs that you have created or have been given permission to edit.
curl -v -X PUT http://localhost:3000/api/v1/data_management_plans/10.123/123ABC00If successful an HTTP 200 - 'Success' status will be returned along with the full RDA Common Standard JSON for the DMP. Note that the dmp_id attribute will contain the new DMP ID (DOI) for your DMP.
{
"application": "dmphub",
"status": "Success",
"code": 200,
"time": "2020-09-28T22:44:19:00Z",
"caller": "dmphub",
"source": "DELETE https://dmphub-stg.cdlib.org/api/v0/data_management_plans/10.0000/AB12CD34",
"page": 1,
"per_page": 20,
"total_items": 0,
"items": []
}If you do not have the authority to delete the DMP, or it could not be found, you will receive a 404 'Not Found' response.
{
"application": "dmphub",
"status": "Not Found",
"code": 404,
"time": "2020-09-28T22:44:19:00Z",
"caller": "dmphub",
"source": "DELETE https://dmphub-stg.cdlib.org/api/v0/data_management_plans/10.0000/AB12CD34",
"page": 1,
"per_page": 20,
"total_items": 0,
"items": [],
"errors": []
}