Re: Downloading location data as CSV 10.19.2016 07:57 PM
You can download your device's location data as a CSV using the Export Values from all Data Streams of a Device endpoint, making sure to pass the `include_location` parameter. The benefit of using this endpoint is that you may choose download *all* of your device's historical data, even if it is a large volume of data, as this endpoint queues a background job to process the request for data.
You can then make a request to the View Job Results endpoint using the URL included in the Location (from above) to retreive the Job results. When the Job is finished running the `status` attribute of the View Job Results response will be set to `complete` and the `result` attribute will contain a `url` where the .csv data file can be downloaded. You will need to add some logic in your script to ping the View Job Results endpoint checking the `status` attribute until it is `complete`.
Once the job is complete, make a request to the `result``url` contained in the View Job Result response to download your .csv data file.
Note: assuming the API Key included in your post is an actual API key from your account, you should consider regenerating it so that others may not access your device(s). In the M2X Developer Portal, you can regenerate Master Keys from the Master Keys tab in the Account Settings section. Other resource keys such as Device API Keys from the API Keys tab in the detail page for the respective resource.