M2X Data Service - Downloading location data as CSV
Downloading location data as CSV
10.19.2016 04:39 PM
Also, the location json only gives me the last 3 location values. Is there any way to download ALL location values?
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.
Sample request to the Export Values endpoint:
curl -i https://api-m2x.att.com/v2/devices/02h280h4j05536hh19k5il21i085997i/values/export.csv?include_location -H "X-M2X-KEY: [YOUR_API_KEY]"
202 Accepted Location: https://api-m2x.att.com/v2/jobs/20150789ab77eaffd7e16b4bb09bf746b5ba0a
curl -i https://api-m2x.att.com/v2/jobs/20150789ab77eaffd7e16b4bb09bf746b5ba0a -H "X-M2X-KEY: [YOUR_API_KEY]"
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.