Skip to content

REDCap External Module APIs

Aditya Chinchure edited this page Aug 28, 2020 · 4 revisions

getData:

This endpoint internally uses REDCap::getData() API function to get data from the REDCap database.

POST /?type=module&prefix=leap_connector&NOAUTH&page=getData

With form-data:

  • 'auth': (Required) The authentication key generated by the LEAP Connector External Module in REDCap. Example: "9caae41bd3b3205f2b938d8cb014339f"
  • 'pid': (Required) The project ID of the REDCap project to retrieve data from. Easiest way to obtain this is from the URL of the project when you open it on REDCap. Example: 13
  • 'filters': (Required) Any filter criteria, in the REDCap API format. If no filter, then send an empty string "". Example: "[age] > 10 and [chemo] = 1"
  • 'fields': (Required) Selected fields to return, in the REDCap API format. If all fields, then send an empty string "". Example: "yrbirth, postalcode"

Returned JSON:

{
    "success": true,
    "data": [
        {
            "yrbirth": "1938",
            "postalcode": "V3W"
        },
        {
            "yrbirth": "",
            "postalcode": ""
        },
        {
            "yrbirth": "1968",
            "postalcode": "B9N"
        }
    ]
}

getQueryResult:

This accepts an SQL query that will run on REDCap::query() and the results are returned without any modification

POST /type=module&prefix=leap_connector&NOAUTH&page=getQueryResult

With form-data:

  • 'auth': (Required) The authentication key generated by the LEAP Connector External Module in REDCap. Example: "9caae41bd3b3205f2b938d8cb014339f"
  • 'query': (Required) The SQL query. Example: "SELECT * from redcap_data where project_id=13"

Returned JSON:

{
    "success": true,
    "data": [
        {
            "project_id": "13",
            "event_id": "40",
            "record": "1",
            "field_name": "calc_csi",
            "value": "55",
            "instance": null
        },
        {
            "project_id": "13",
            "event_id": "40",
            "record": "1",
            "field_name": "calc_ehp_core",
            "value": "56.818181818182",
            "instance": null
        },
        {
            "project_id": "13",
            "event_id": "40",
            "record": "1",
            "field_name": "calc_fsds",
            "value": "38",
            "instance": null
        }
    ]
}