NetAtmo Programming Synology

Export NetAtmo weather station data to CSV / Excel

Update (2019-03-14): Netatmo changed their login process on Mar 7th 2019 – the download link below refers to the updated script on my GitHub page.

I’m a proud owner of a NetAtmo weather station for a couple of months and I think it’s the best wheater station with a great user experience you can get:


Some days ago I noticed the option in the web dashboard to export all my weather data into a comma-separated (CSV) or Microsoft Excel file. That’s a great feature for archiving your measured data….but wait – how could this be done in an automated way?


The short answer is: yes – but unfortunately not out-of-the-box. NetAtmo offers a great RESTful API for accessing the weather station data, so I started to do some coding with their web API. But I had no luck – there isn’t a method available for exporting the data. So I did a manual download and created some http/https traces to see what’s going on there. I simply put together the required http-calls and made a shell script that will do the job for me:

getmeasurecsv() {
    # ------------------------------------------------------
    # Help
    # ------------------------------------------------------
    # USER + PASSWORD -> your NetAtmo Website login
    # DEVICE_ID -> Base Station ID
    # MODULE_ID -> Module ID
    # TYPE -> Comma-separated list of sensors (Temperature,Humidity,etc.)
    # STARTDATE -> Begin export date in format YYYY-mm-dd HH:MM
    # ENDDATE -> End export date in format YYYY-mm-dd HH:MM
    # FORMAT -> csv or xls
    # ------------------------------------------------------
    # Parsing Arguments
    # ------------------------------------------------------
    # ------------------------------------------------------
    # Define some constants
    # ------------------------------------------------------
    # ------------------------------------------------------
    # Convert start and end date to timestamp
    # ------------------------------------------------------
    DATEBEGIN="$(date --date="$DATETIMEBEGIN" "+%d.%m.%Y")"
    TIMEBEGIN="$(date --date="$DATETIMEBEGIN" "+%H:%M")"
    DATE_BEGIN="$(date --date="$DATETIMEBEGIN" "+%s")"
    DATEEND="$(date --date="$DATETIMEEND" "+%d.%m.%Y")"
    TIMEEND="$(date --date="$DATETIMEEND" "+%H:%M")"
    DATE_END="$(date --date="$DATETIMEEND" "+%s")"
    # ------------------------------------------------------
    # URL encode the user entered parameters
    # ------------------------------------------------------
    USER="$(urlencode $USER)"
    PASS="$(urlencode $PASS)"
    DEVICE_ID="$(urlencode $DEVICE_ID)"
    MODULE_ID="$(urlencode $MODULE_ID)"
    TYPE="$(urlencode $TYPE)"
    DATEBEGIN="$(urlencode $DATEBEGIN)"
    TIMEBEGIN="$(urlencode $TIMEBEGIN)"
    DATEEND="$(urlencode $DATEEND)"
    TIMEEND="$(urlencode $TIMEEND)"
    FORMAT="$(urlencode $FORMAT)"
    # ------------------------------------------------------
    # Now let's fetch the data
    # ------------------------------------------------------
    # get token from hidden <input> field
    TOKEN="$(curl --silent -c $SESSION_COOKIE $URL_LOGIN | sed -n '/token/s/.*name="_token"\s\+value="\([^"]\+\).*/\1/p')"

    # and now we can login using cookie, id, user and password
    curl --silent -d "_token=$TOKEN&email=$USER&password=$PASS" -b $SESSION_COOKIE -c $SESSION_COOKIE $URL_POSTLOGIN > /dev/null

    # next we extract the access_token from the session cookie
    ACCESS_TOKEN="$(cat $SESSION_COOKIE | grep netatmocomaccess_token | cut -f7)"
    # build the POST data
    # now download data as csv
    # clean up
urlencode() {
    # ------------------------------------------------------
    # urlencode function from mrubin
    # usage: urlencode <string>
    # ------------------------------------------------------
    local length="${#1}"
    for (( i = 0; i < length; i++ )); do
        local c="${1:i:1}"
        case $c in [a-zA-Z0-9.~_-])
            printf "$c" ;;
            *) printf '%%%02X' "'$c"
getmeasurecsv "" "mySecretPassword" "12:23:45:56:78:33" "02:00:00:12:23:45" "Temperature,Humidity" "2015-05-17 10:00:00" "2015-05-18 12:00:00" "csv"

You just need to modify the last line to fit your environment. Here are some detailed information regarding the DEVICE_ID and the MODULE_ID. Both IDs can be found in your NetAtmo Dashboard settings. The DEVICE_ID will be the MAC-Address of your NetAtmo Base Station. The MODULE_ID is based on the serial number of your additional NetAtmo Modules:

  • Serial numbers starting with iXXXXXX are indoor modules – the MODULE_ID will be: 03:00:00:XX:XX:XX (e.g. i1245E4 – 03:00:00:12:45:E4)
  • Serial numbers starting with hXXXXXX are outdoor modules – the MODULE_ID will be: 02:00:00:XX:XX:XX (e.g. h76A123 – 02:00:00:76:A1:23)
  • When querying the base station the DEVICE_ID and MODULE_ID value must be the same – the MAC-Address of the base station. The Output in the CSV file will look like this:


    I duplicated the last line for each of my NetAtmo modules and configured the script to run on my Synology DiskStation NAS for an automatic backup.

      UPDATE 2017:

    See my recent blog post Netatmo Weather Station Shell Script

    You may also like
    LotusScript: Move all items without a view into Inbox Folder
    SCCM 2012 Extension: Remove a Computer from all Collections
    Synology DS Photo+ DLNA Mirroring Reverse Engineering Part 1
    • Helmut
      June 2, 2020 at 19:00

      Hallo Michael,

      ich würde gerne die Daten von Netatmo auf dem Rasphery pi 3 regelmäßig in eine CSV holen. Habe leider keine Ahnung von der Programmierung. Wo genau kommen Zugangsdaten, Passwort, Device ID etc. hin. ? ist es richtig, dass nur ein Sensor damit ausgelesen werden kann? Wie bekommt man alle Daten in die CSV?

    • Zaiman1906
      September 10, 2019 at 17:37

      Hello again!
      I have a new problem. Since 05.09.2019, 22 o’clock I can’t get any data.
      I become this error message:

      cat: cookie_sess.txt: No such file or directory
      % Total % Received % Xferd Average Speed Time Time Time Current
      Dload Upload Total Spent Left Speed
      0 0 0 0 0 0 0 0 –:–:– –:–:– –:–:– 0curl: (7) Failed to connect to port 443: Connection refused
      rm: cannot remove `cookie_sess.txt’: No such file or directory
      ### ### ### Retrieved file too small. Expected 140, got 0 bytes. Retrying. ### ### ###

      Anybody who can help me?

      • Zaiman1906
        September 14, 2019 at 08:07

        No one?
        What does it mean:
        cat: cookie_sess.txt: No such file or directory?

        • Zaiman1906
          September 17, 2019 at 22:29

          Finally I solved my problem. It did not depend on the script. On my NAS there was an adapter defect, so the internet connection got lost. After I have fixed that, the script is working again.

    • Zaiman1906
      June 14, 2019 at 07:17

      Hi there,
      since yesterday evening (13.06.2019) I only get temperature data till the 4th of june and rain data till the 9th of June, when I use the script with the monthly parameter -M . But I didn’t change anything and the station ist working fine. Has anyone else this problem too? What can I do?

      • Morten Kristensen
        June 16, 2019 at 00:37

        I see the same problem.. Cant understand why. Also the same problem if I use -s and -e to specify a full month.

        • June 16, 2019 at 09:24


          I checked the issued and the Netatmo API is only returning a CSV or XLS file with 1024 measurements. I don’t know why this is happening. The best solution would be, to download the data every 24h. There is no official documentation for the used getmeasurecsv API and Netatmo does not provide support this API.

      • June 16, 2019 at 09:24


        I checked the issued and the Netatmo API is only returning a CSV or XLS file with 1024 measurements. I don’t know why this is happening. The best solution would be, to download the data every 24h. There is no official documentation for the used getmeasurecsv API and Netatmo does not provide support this API.

    • Jonathan
      March 25, 2019 at 17:59

      Okey, the post to site comment is messing up the response. You will have to check the TOKEN line code from the Github code. It’s slightly different from the code on this page. Then it will work.

    • March 14, 2019 at 09:42

      I just updated the code – now it should work with the new login process from netatmo.

      • Chris
        March 14, 2019 at 19:14

        still (with just copy&paste with my netatmo credentials)

        {“error”:{“code”:2,”message”:”Invalid access token”}}

        • Chris
          March 14, 2019 at 19:33

          Hat geklappt,
          Vielen Dank ! Großartige Arbeit

          • js
            March 23, 2019 at 11:28

            How did you solve the problem? I am getting the same error.
            I think the sed statement parsing the session cookie doesn’t work properly

            • Jonathan
              March 25, 2019 at 17:51

              I replaced the TOKEN line with this one:
              TOKEN=”$(curl –silent -c $SESSION_COOKIE $URL_LOGIN | sed -n ‘/token/s/.*name=”_token”s+value=”([^”]+).*/1/p’)”

            • Jonathan
              March 25, 2019 at 17:55

              Sorry this one:
              TOKEN=”$(curl –silent -c $SESSION_COOKIE $URL_LOGIN | sed -n ‘/token/s/.*name=”_token”s+value=”([^”]+).*/1/p’)”

    • Christoph Steffin
      March 12, 2019 at 15:19

      Since 07.03.2019 apparently the address of the URL-Login of …/de-DE/… has been changed. on …/de-de/… which leads to the script not being able to log in. The only error message you get is that the cookie files do not exist. 😀

      • Christoph Steffin
        March 12, 2019 at 15:22

        Change Line:


        • Chris
          March 12, 2019 at 21:00

          not really…you already made another post with a much different solution than just change from DE to de

          big error code with CSS and at the end

          ” An Error Was Encountered”
          ” The action you have requested is not allowed. “

    • take
      December 1, 2018 at 20:20

      so now that i have the datam is there any way to use this data to make Graphics comparison by selected dates?

    • Luca
      June 20, 2018 at 10:17

      You need to replace API_GETMEASURECSV=””



      • Hermann
        June 20, 2018 at 12:25

        Many thanks for the script, that I have been using for more than a year now. It seems that yesterday NetAtmo changed the paths to their scripts and the download did not work anymore. I then used a HTTP Trace and found out that apparently they changed the path to getmeasurecsv from “” to “”…
        At least for me it seems to work again..

        • Jerome
          August 18, 2018 at 21:55

          Thank you for the Update 🙂 Now the Script is working like a charm again :-D. I owe you a Beer 😉

    • Eivind
      April 29, 2017 at 10:10

      Hello, and thank you for a great script! I’ve used it to fetch data from my newly bought Netatmo, and it’s working great.

      I’m trying to expand a little on your work here, but I don’t have much experience with bash. What I’m planning to do is to have a perl script execute your bash script, and have the bash script store the exported data in csv files. Then, the perl script will parse those csv files, and put the data into a mysql database. Then I’ll make a separate web interface that outputs the data from mysql.

      That might sound silly, given that Netatmo already provides a web interface. I do like to keep my own backup of the data, though. Also, I miss several features on the Netatmo interface – for instance being able to compare data (e.g. indoor and outdoor temperature in the same chart, or the outdoor temperature of this year compared to last year on the same chart).

      So, my question is: Is there any way to set the parametres of the bash script via command line? That way I would be able to have the perl script give the date range when running the script.

      Thanks again for the great work in making the script!

      • Eivind
        April 29, 2017 at 10:39

        Sorry to bother you – I figured it out.

        In case you or anyone else would like to do the same, here’s what I’ve done:

        After the end of getmeasurecsv() {}, I’ve added this:

        while [[ $# -gt 1 ]]

        case $key in
        shift # past argument
        shift # past argument
        # unknown option
        shift # past argument or value

        echo START DATE = "${STARTDATE}"
        echo END DATE = "${ENDDATE}"

        Then I’ve added several lines calling the getmeasurecsv(), specifying the different modules and the date range:

        getmeasurecsv "" "my_password" "70:ee:50:00:00:00" "70:ee:50:00:00:04" "Temperature,Humidity,CO2,Pressure,Noise" "${STARTDATE}" "${ENDDATE}" "csv" > inndoors.csv

        getmeasurecsv "" "my_password" "70:ee:50:00:00:00" "70:ee:50:00:00:04" "Rain" "${STARTDATE}" "${ENDDATE}" "csv" > rain.csv

        Then I call the script by command line like this:

        bash -s "2017-04-25 00:00:00" -e "2017-04-29 10:15:00"

        Next up is writing the perl script to parse the data and add it to mysql. Thanks again for the great script! 🙂

    • sunitha
      April 10, 2017 at 18:39

      I would like to retrieve the public data from netatmo. I know only python. Could you help me to retrieve to csv file. Thank you.

    • Jiri Dobsovic
      April 7, 2017 at 23:03

      I´m sorry for my stupid question (I’m a beginner), but how can I run this script? Can I run it in Windows computer or how can I run it in Synology, as you wrote…
      Thank you for your help.

      • Frank
        April 10, 2017 at 20:07

        Hi Jiri,
        this is a bash script (bash – born again shell) . Windows will not work, bash is running on unix systems like ubuntu. also unix based raspberry os will work.

    • Lode
      December 28, 2016 at 00:26

      Great job !!!!

    • July 22, 2016 at 07:58

      […] two really cool bash scripts using curl to query base information about one’s devices and download the weather data. I modified them, especially for postprocessing (=grouping) the rain data, so I attach them to this […]

    • June 9, 2016 at 12:28

      Thanks a lot for this script and the script to get the device data. With it getting my netatmo data was a piece of cake.

    • Sandro
      May 15, 2016 at 13:36

      Hallo Michael,
      Kennst Du dich mit VBA auch aus?
      Da ich kein Linux habe, würde ich die Abfrage gerne direkt mit Excel machen.

      • June 1, 2016 at 20:27


        in VBA nur ein bisschen, aber in VB. Das ganze nennt sich ReST API – im Internet gibts viele Beispiele wie man über VBA Daten von einer ReST Schnittstelle abfragen kann. Ich vermute aber über VBA könnte es etwas umständlich werden, da VBA ja schon etwas betagt ist – aber machbar ist es sicherlich.

    • Niklaus Schneeberger
      April 14, 2016 at 21:26

      Hi Michael,

      This looks exactly like what I need but I don’t get it to work. First I get en email from Netatmo everytime I run the script and second I get the following error: date: illegal option — –
      Any ideas?

      • April 28, 2016 at 09:22

        Hello Niklaus,

        you can change your notification settings from the NetAtmo Website and disable the login notification.

    • Fiaskogaul
      February 12, 2016 at 13:38

      Ich will die Daten via Statusboard darstellen. Da kommt mir das CSV sehr gelegen.

      Ich bekomm aber beim Ausführen des Script einige Rechtefehler:

      Returncode: 126
      Ausgabe des Scripts:
      [0] => line 73: /bin/grep: Permission denied
      [1] => line 73: /bin/cat: Permission denied
      [2] => line 79: /bin/grep: Permission denied
      [3] => line 79: /bin/cat: Permission denied
      [4] => % Total % Received % Xferd Average Speed Time Time Time Current
      [5] => Dload Upload Total Spent Left Speed
      [6] =>
      0 0 0 0 0 0 0 0 –:–:– –:–:– –:–:– 0
      100 257 100 3 100 254 11 946 –:–:– –:–:– –:–:– 1909
      [7] => 9;
      [8] => line 88: /bin/rm: Permission denied
      [9] => line 89: /bin/rm: Permission denied
      [10] => line 73: /bin/grep: Permission denied
      [11] => line 73: /bin/cat: Permission denied
      [12] => line 79: /bin/grep: Permission denied
      [13] => line 79: /bin/cat: Permission denied
      [14] => % Total % Received % Xferd Average Speed Time Time Time Current
      [15] => Dload Upload Total Spent Left Speed
      [16] =>
      0 0 0 0 0 0 0 0 –:–:– –:–:– –:–:– 0
      100 257 100 3 100 254 20 1713 –:–:– –:–:– –:–:– 2134
      [17] => 9;
      [18] => line 88: /bin/rm: Permission denied
      [19] => line 89: /bin/rm: Permission denied

      Ich versteh nicht so recht was das Script da jetzt nicht darf.
      Freue mich über jegliche Hilfe!

      Vielen Dank

    • Kai
      February 5, 2016 at 15:16

      Hallo Michael,
      eine andere Frage: Wäre es möglich das Skript so zu modifizieren, dass immer nur ein Zeitraum von z.B. 24h als CSV Datei exportiert würde? Aktuell ist es ja so, dass die Startzeit/Datum stets definiert werden MUSS. Das Enddatum kann auch weiter in die Zukunft gesetzt werden – das ist kein Problem, ergibt lediglich NaN am Ende der CSV Datei. Ich nutze dein Skript nicht nur als Datenbackup, sondern lasse jede Stunde damit die Werte ab dem 1.1. in eine CSV Datei exportieren. Somit kommen jede Stunde neue Daten hinzu (der Scale Wert wurde dafür bereits angepasst, so dass nur eine Zeile / Wert(e) pro Stunde hinzukommt).
      Mit einem fest definiertem Zeitraum von stets 24h könnte dann jede Stunde ein neuer, aktueller Zeitraum von 24h (jetzt minus 24h) exportiert werden und wie bei mir mit Charts visualisiert werden.

    • dagrun schuler
      January 26, 2016 at 08:53

      I wonder if you have any idea if it is possible to download data from other netatmo weather stations which distribute their data on the netatmo world maps?

      • January 26, 2016 at 11:55

        Hello Dagrun,

        you can access the weather map data by using the public API method GETPUBLICDATA. NetAtmo offers a great example on their website:
        You can pass an area specified by longitude and latitude to the API and get the measures from all weather stations within the specified area.


      • March 23, 2017 at 11:54

        You are so awesome for helping me solve this mysetry.

    • Kai
      January 17, 2016 at 22:34

      Hallo Michael,
      ersteinmal vielen Dank für Deine tolle Anleitung zur Ausgabe der Netatmo Daten im CSV Format. Das ist genau das was ich gesucht habe 🙂
      Aber: Wie kann ich die ausgegebenen Daten auch als dateiname.csv in einem bestimmten Pfad abspeichern? Oder wird hier schon irgendwo das Ergebnis der Abfrage abgelegt? Wenn ja, wo? Das Skript läuft in der Konsole bei mir einwandfrei und spuckt alle Werte der definierten Zeitspanne aus – aber halt nur in der Konsole, oder?

      • January 18, 2016 at 06:20

        Hallo Kai,

        damit die Ausgabe in eine Datei geschrieben wird, musst du am Ende der letzten Zeile “getmeasurecsv…..” einfach “> /pfad/zu/meiner/datei.csv” anhängen. Somit wird die gesamte Ausgabe in die angegebene Datei umgeleitet /geschrieben.



        • Kai
          January 18, 2016 at 10:44

          Hallo Michael,
          prima – vielen Dank für die schnelle Hilfe – funktioniert!

    • August 31, 2015 at 21:47

      The script works great for the base module. But I’ve discovered some problems with the outside- and rain module. Somehow there is a little mismatch in the adress that I can’t figure out the examples.
      “12:23:45:56:78:33” “02:00:00:12:23:45”
      “03:00:00:XX:XX:XX” “03:00:00:12:45:E4”
      I tried both combinations but it only downloads “9;”
      Somebody else having the same?

      • September 1, 2015 at 07:00

        Unfortunately, I don’t have a rain module. But the outdoor module is working for me. What is the first character of your outdoor module serial number shown on the netatmo page? First character should be something between A-Z?

        • January 26, 2016 at 14:04

          Hi there,
          my rain module has a serial number starting with ‘k’, so the module id starts with ’05’. The only possible filter ($TYPE) is “Rain”.
          My wind module starts with a ‘l’, module id: ’06:..:.’. filter: “WindAngle,WindStrength,GustAngle,GustStrength”

          Viele Grüße

          @Michael: Schönes bash-script, sehr verständlich geschrieben. Sieht man leider selten.

      • September 1, 2015 at 14:15

        Please have a look on my new blog post how to get all module data, including base_id and module_id:

        Read NetAtmo weather station data via Script

    Leave Your Comment

    Your Comment*

    Your Name*
    Your Webpage