Download CSV

The Netatmo API is a set of webservices allowing developers and third parties to access Netatmo device's data.
Post Reply
Dai
Posts: 46
Joined: 09 Jan 2016, 09:02

Download CSV

Post by Dai »

Hello Development Team,

unfortunately you destroyed my data export once again. I collect data since 2016 now and since 9th May 2022 you changed a lot of things in the authentication again and removed CSV export. I only find JSON format.

How can I download data automatically in CSV Format ?

I tried to change the access token but it doesn't work (shell script)

ACCESS_TOKEN=`curl --silent --location --request POST "https://api.netatmo.com/oauth2/token" \
--form "grant_type=password" \
--form "client_id=$ID" \
--form "client_secret=$SEC" \
--form "username=$USER" \
--form "password=$PASS" | jq -r '.access_token'`


# build the POST data
PARAM="access_token=$ACCESS_TOKEN&device_id=$DEVICE_ID&type=$TYPE&module_id=$MODULE_ID&scale=max&datebegin=$DATEBEGIN&timebegin=$TIMEBEGIN&dateend=$DATEEND&timeend=$TIMEEND&date_begin=$DATE_BEGIN&date_end=$DATE_END"

# now download data as csv
retrieved_data=$(curl --silent -d $PARAM $API_GETMEASURECSV)
if [ $? -eq 0 ];then
echo "${retrieved_data}"
fi


Manual download via your website is now the only way for me once a month to get the data. I'm very upset and just can't believe it
Leslie
Posts: 113
Joined: 12 Feb 2020, 11:07

Re: Download CSV

Post by Leslie »

Hello,

/getmeasurecsv method is not available anymore to third-parties. It was not an official endpoint and wasn't documented
The best solution is to make a call to /getmeasure method (https://dev.netatmo.com/apidocumentatio ... getmeasure) and then convert the retrieved JSON in .csv format

Here is an example of a Python script allowing the JSON > csv conversion :

import json
import csv
# Opening JSON file and loading the data
# into the variable data
with open('data.json') as json_file:
data = json.load(json_file)
jsondata = data['body']['value']
# now we will open a file for writing
cvs_data = open('data_file.csv', 'w')
# create the csv writer object
csv_writer = csv.writer(cvs_data)
# write values in csv
# write header
header = ["sum_rain", "temperature"]
csv_writer.writerow(header)
# write values
for value in values:
csv_writer.writerow(value)
csv_data.close()

Have a good day,
Leslie - Community Manager
Post Reply

Return to “Netatmo API”