Authentication

To use the API, you’ll need to obtain an access token and pass this along in each call – please see our authentication topic for more information. Your API token can be obtained from your “Edit Organization” screen.


Base URL

Each Device Magic Database is associated with a specific form, therefore all API requests that work with the database need to identify the form that you’re referring to.

API Call Requests will be based on the following URL (note the HTTPS):

https://api.devicemagic.com/api/forms/[form_id]/device_magic_database

Your form_id number can be found in the browser URL when viewing your form's Summary page.

Note: Your form's Device Magic Database Destination needs to be active and have submissions in it, in order to view these submissions using the API.


Viewing Submissions In a Device Magic Database

To get submissions from the Device Magic Database, simply issue an HTTP GET request to the Base URL.

https://api.devicemagic.com/api/forms/[form_id]/device_magic_database.json


Parameters

There are some parameters you can use to filter the submissions that are returned:

This will return a list of all the submissions that match your criteria.

Example Request

https://api.devicemagic.com/api/forms/441/device_magic_database.json?per_page=5

Example Response

{
  "per_page": 5,
  "current_page": 1,
  "total_pages": 2,
  "current_count": 5,
  "total_count": 7,
  "submissions": [{
    "form": {
      "id": 441,
      "name": "Simple Test Form",
      "version": "1.00"
    },
    "metadata": {
      "device_id": {
        "value": "iPhone_1",
        "type": "string"
      },
      "user_id": {
        "value": null,
        "type": "string"
      },
      "username": {
        "value": "Matty6s",
        "type": "string"
      },
      "submitted_at": {
        "value": "2016-05-04 11:25:49 +02:00",
        "type": "datetime"
      },
      "received_at": {
        "value": "2016-05-04 09:25:49 +00:00",
        "type": "datetime"
      },
      "submission_id": {
        "value": "233",
        "type": "integer"
      },
      "device_submission_identifier": {
        "value": "A8F925ED-52E0-4243-AD25-E0EDBB051A3F",
        "type": "integer"
      },
      "form_name": {
        "value": "Simple Test Form"
      },
      "form_namespace": {
        "value": "https://www.devicemagic.com/xforms/9be7df80-f407-0133-d8cb-14109fd23119"
      },
      "form_version": {
        "value": "1.00"
      },
      "device": {
        "value": {
          "a": null
        }
      }
    },
    "submission": {
      "Basic_Question": {
        "value": "Test answer 1",
        "type": "text"
      },
      "Date___Time_Question": {
        "value": "2016-05-03 09:25:42",
        "type": "datetime"
      }
    }
  }, {
    "form": {
      "id": 441,
      "name": "Simple Test Form",
      "version": "1.00"
    },
    "metadata": {
      "device_id": {
        "value": "iPhone_1",
        "type": "string"
      },
      "user_id": {
        "value": null,
        "type": "string"
      },
      "username": {
        "value": "Matty6s",
        "type": "string"
      },
      "submitted_at": {
        "value": "2016-05-04 11:26:04 +02:00",
        "type": "datetime"
      },
      "received_at": {
        "value": "2016-05-04 09:26:04 +00:00",
        "type": "datetime"
      },
      "submission_id": {
        "value": "234",
        "type": "integer"
      },
      "device_submission_identifier": {
        "value": "74F31AFF-2475-4EB2-A333-7BD43CF6CD93",
        "type": "integer"
      },
      "form_name": {
        "value": "Simple Test Form"
      },
      "form_namespace": {
        "value": "https://www.devicemagic.com/xforms/9be7df80-f407-0133-d8cb-14109fd23119"
      },
      "form_version": {
        "value": "1.00"
      },
      "device": {
        "value": {
          "a": null
        }
      }
    },
    "submission": {
      "Basic_Question": {
        "value": "Test answer 2",
        "type": "text"
      },
      "Date___Time_Question": {
        "value": "2016-05-04 11:25:58",
        "type": "datetime"
      }
    }
  }, {
    "form": {
      "id": 441,
      "name": "Simple Test Form",
      "version": "1.00"
    },
    "metadata": {
      "device_id": {
        "value": "iPhone_1",
        "type": "string"
      },
      "user_id": {
        "value": null,
        "type": "string"
      },
      "username": {
        "value": "Matty6s",
        "type": "string"
      },
      "submitted_at": {
        "value": "2016-05-04 11:26:15 +02:00",
        "type": "datetime"
      },
      "received_at": {
        "value": "2016-05-04 09:26:16 +00:00",
        "type": "datetime"
      },
      "submission_id": {
        "value": "235",
        "type": "integer"
      },
      "device_submission_identifier": {
        "value": "BBEDE777-893E-4075-8D92-A4764BC08953",
        "type": "integer"
      },
      "form_name": {
        "value": "Simple Test Form"
      },
      "form_namespace": {
        "value": "https://www.devicemagic.com/xforms/9be7df80-f407-0133-d8cb-14109fd23119"
      },
      "form_version": {
        "value": "1.00"
      },
      "device": {
        "value": {
          "a": null
        }
      }
    },
    "submission": {
      "Basic_Question": {
        "value": "Test answer 3",
        "type": "text"
      },
      "Date___Time_Question": {
        "value": "2016-05-04 11:26:11",
        "type": "datetime"
      }
    }
  }, {
    "form": {
      "id": 441,
      "name": "Simple Test Form",
      "version": "1.00"
    },
    "metadata": {
      "device_id": {
        "value": "iPhone_1",
        "type": "string"
      },
      "user_id": {
        "value": null,
        "type": "string"
      },
      "username": {
        "value": "Matty6s",
        "type": "string"
      },
      "submitted_at": {
        "value": "2016-05-04 11:26:35 +02:00",
        "type": "datetime"
      },
      "received_at": {
        "value": "2016-05-04 09:26:35 +00:00",
        "type": "datetime"
      },
      "submission_id": {
        "value": "236",
        "type": "integer"
      },
      "device_submission_identifier": {
        "value": "7688475F-1659-4E67-A5BE-915449D104E3",
        "type": "integer"
      },
      "form_name": {
        "value": "Simple Test Form"
      },
      "form_namespace": {
        "value": "https://www.devicemagic.com/xforms/9be7df80-f407-0133-d8cb-14109fd23119"
      },
      "form_version": {
        "value": "1.00"
      },
      "device": {
        "value": {
          "a": null
        }
      }
    },
    "submission": {
      "Basic_Question": {
        "value": "Test answer 4",
        "type": "text"
      },
      "Date___Time_Question": {
        "value": "2016-06-16 02:28:23",
        "type": "datetime"
      }
    }
  }, {
    "form": {
      "id": 441,
      "name": "Simple Test Form",
      "version": "1.00"
    },
    "metadata": {
      "device_id": {
        "value": "iPhone_1",
        "type": "string"
      },
      "user_id": {
        "value": null,
        "type": "string"
      },
      "username": {
        "value": "Matty6s",
        "type": "string"
      },
      "submitted_at": {
        "value": "2016-05-04 11:26:48 +02:00",
        "type": "datetime"
      },
      "received_at": {
        "value": "2016-05-04 09:26:48 +00:00",
        "type": "datetime"
      },
      "submission_id": {
        "value": "237",
        "type": "integer"
      },
      "device_submission_identifier": {
        "value": "9BAD6AA2-1D03-4E74-8962-8BC9FD80C57B",
        "type": "integer"
      },
      "form_name": {
        "value": "Simple Test Form"
      },
      "form_namespace": {
        "value": "https://www.devicemagic.com/xforms/9be7df80-f407-0133-d8cb-14109fd23119"
      },
      "form_version": {
        "value": "1.00"
      },
      "device": {
        "value": {
          "a": null
        }
      }
    },
    "submission": {
      "Basic_Question": {
        "value": "Test answer 5",
        "type": "text"
      },
      "Date___Time_Question": {
        "value": "2016-05-25 10:03:40",
        "type": "datetime"
      }
    }
  }]
}



Combining Parameters

To combine parameters use &.

For example, to view submission on a certain date combine the from_date & to_date parameters, as follows:

https://api.devicemagic.com/api/forms/[form_id]/device_magic_database.json?from_date=2022-09-15&to_date=2022-09-16

If you have any questions or comments feel free to send us a message at support@devicemagic.com.


Other Useful Articles:

Did this answer your question?