Device Magic Database API

This API allows you to read submissions from your form's Device Magic Database.

You need to have the Device Magic Database attached to your form and can only read submissions that have been sent to the database.

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

Because a device magic database is associated with a form, all your API requests that work with the database need to identify the form that you’re referring to. So requests will be based on the following URL (note the HTTPS):

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

where

  1. The form_id is the id of the form you’d like to work with

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://www.devicemagic.com/api/forms/[form_id]/device_magic_database.json

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

 Param  Description  Default   Example
page The page number to show. 1 2
per_page The number of items to show per page  30 5
from_date Submission made after date null  2016/01/05 15:35
to_date Submissions made before date null  2016/01/10 12:00
submission_ids  Comma separated list of submission ids  (note: ids not submission identifiers) null  25,53
device_id The device identifier, this will filter to submissions from this device. null  iPhone_1X93653B-13235-3338-ZZ-5DDD7 
search A free text search that matches against the text in the submission. null  Some string

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

Request

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

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": "http://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": "http://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": "http://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": "http://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": "http://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"
      }
    }
  }]
}

 

 

 

Have more questions? Submit a request

Comments

Powered by Zendesk