Example

In this example we will be downloading in CSV format the mean systolic blood pressure from all male patients in the NHANES database.

NOTE:
All commands are run against the https://nhanes.hms.harvard.edu e.g. https://nhanes.hms.harvard.edu/rest/v1/queryService/runQuery

Step Command Output
Get the BD2K PIC-SURE API Key Go to nhanes.hms.harvard.edu, and click the Public User button on the top right, and then the User Profile from the dropdown menu. In the top right you will see an alphanumeric key. Copy that key
Start a secure session with API Key /rest/v1/secureService/startSession?key=mcljn8qlu742g93gpu7teb8sna
{
  "status": "success"
}
Run a Query /rest/v1/queryService/runQuery
{
  "select": [
      {
        "field": {
          "pui": "/nhanes/Demo/examination/examination/blood pressure/mean systolic/",
          "dataType": "STRING"
        },
        "alias": "Systolic Pressure"
      }
  ],
  "where": [
      {
        "field": {
          "pui": "/nhanes/Demo/demographics/demographics/SEX/male",
          "dataType": "STRING"
        },
        "predicate": "CONTAINS",
        "fields": {
          "ENOUNTER": "YES"
        }
      }
  ]
}
{
  "resultId": 22449
}
Check the status of the result /rest/v1/resultService/resultStatus/22449
{
  "resultId": 22449,
  "status": "AVAILABLE"
}
Check the available formats for the result /rest/v1/resultService/availableFormats/22449
[
  "JSON",
  "XML",
  "XLSX",
  "CSV"
]
Download the results as a CSV /rest/v1/resultService/result/22449/CSV?download=yes File should be downloaded to your computer.
End the session /rest/v1/securityService/endSession
{
  "status": "success"
}