Skip to content
Brian Riley edited this page Nov 9, 2022 · 3 revisions

API Overview

Every DMP generated within the DMPTool is based on a template. You can retrieve the names, descriptions, organizational affiliation and the identifier of all published templates through this API endpoint.

The most common use case scenario for this would be in integrations that will be creating DMPs via the API. For example you could provide the user with a select list of available templates and then pass their selection along to the create DMP API endpoint.

This feature requires standard access (see the API Authentication section for more details). Once you have acquired your access token, you can send the following request to the DMPTool API:

curl -v https://dmptool.org/api/v2/templates \
  -H "Accept: application/json" \
  -H "Authorization: Bearer MY_ACCESS_TOKEN"

Including the optional api/v2/templates/show_phases=true query argument will return the entire contents of the template (section titles, questions, etc.).

If the request was successful you will receive an HTTP 200 ok and the following JSON response:

{
 "application": "dmptool-dev",
 "api_version": 2,
 "source": "GET /api/v2/templates",
 "time": "2021-04-16T11:44:09-07:00",
 "caller": "your_email OR your_application_name",
 "code": 200,
 "message": "OK",
 "page": 1,
 "per_page": 20,
 "total_items": 38,
 "next": "/api/v2/templates?page=2&per_page=20",
 "items": [
   {  
     "dmp_template": {
       "title": "Example Template",
       "description": "A brief description of what this template should be used for",
       "version": 3,
       "created": "2018-02-13T07:18:08Z",
       "modified": "2020-07-07T20:22:21Z",
       "affiliation": {
         "name": "Example Funding Organization",
         "abbreviation": "EFO",
         "affiliation_id": { "type": "ror", "identifier": "https://ror.org/abcd123xyz" }
       },
       "template_id": { "type": "other", "identifier": "123" }
     }
   }
 ]
}

Sample output when including the show_phases=true query parameter:

{
 "application": "dmptool-dev",
 "api_version": 2,
 "source": "GET /api/v2/templates",
 "time": "2021-04-16T11:44:09-07:00",
 "caller": "your_email OR your_application_name",
 "code": 200,
 "message": "OK",
 "page": 1,
 "per_page": 20,
 "total_items": 38,
 "next": "/api/v2/templates?page=2&per_page=20",
 "items": [
   {
    "dmp_template": {
      "title": "NEH-ODH: Office of Digital Humanities",
      "version": 4,
      "created": "2021-03-31T18:52:53Z",
      "modified": "2021-10-25T18:42:53Z",
      "affiliation": {
        "name": "National Endowment for the Humanities (neh.gov)",
        "abbreviation": "NEH",
        "affiliation_id": {
          "type": "ror",
          "identifier": "https://ror.org/02vdm1p28"
        }
      },
      "template_id": {
        "type": "other",
        "identifier": "1887"
      },
      "phases": [
        {
          "title": "Data Management Plan",
          "number": 1,
          "template_id": 1280,
          "modifiable": true,
          "created": "2021-03-31T18:52:53Z",
          "modified": "2021-03-31T18:52:53Z",
          "sections": [
            {
              "title": "Roles and responsibilities",
              "number": 1,
              "phase_id": 1428,
              "modifiable": true,
              "created": "2021-03-31T18:52:53Z",
              "modified": "2021-03-31T18:52:53Z",
              "questions": [
                {
                  "text": "<p>The DMP should clearly articulate how sharing of primary data is to be implemented. It should ...</p>",
                  "default_value": "",
                  "number": 1,
                  "section_id": 7693,
                  "modifiable": true,
                  "created": "2021-03-31T18:52:53Z",
                  "modified": "2021-03-31T18:52:53Z",
                  "question_format_id": 1,
                  "option_comment_display": true
                }
              ]
            }
          ]
        }
      ]
    }
   }
 ]
}

Note that the above example only shows a single template record. An actual response would contain the a number of template records as specified by the per_page attribute. Please refer to the section on API pagination for more information.

For examples of error response that you may receive, please see the section on API Errors

Clone this wiki locally