Rest api, pin history how do I decompress the data?

i am using the rest api to get back pin data for presentation in a web page

i need the history to fill in the area chart…

so I use the sample node js , and I get back the zipped data,

    var request = require('request');

    request('http://blynk-cloud.com/auth_token/data/pin', function (error, response, body) {
      console.log('Status:', response.statusCode);
      console.log('Headers:', JSON.stringify(response.headers));
      console.log('Response:', body);
    });

but using either node_gzip or zlib both fail with Error: incorrect header check

zlib.gunzip(body, function(err, dezipped) {
	if(err!=null)
         	console.log("unzip error="+err);
	else
	        callback(dezipped.toString());
        })

what am I doing wrong?

a gzip header is 1F8B
the data coming back is 1fef bfbd 0800 0000 0000 0000 74ef

solution, In the request options, add

encoding: null,

that will prevent request from trying to turn the data into a string
then gunzip will work

request({
            url: url+"/data/"+pin
						encoding: null,   <----------
						headers: {					   
							'Accept-Encoding': 'gzip'
					  },  
						gzip:true,        
						method: 'GET'
        	}, (error, response, body) => {

Are you still asking, or did you solve your own question? :stuck_out_tongue:

solved it… but can’t find how to mark this solved

Done it for you, but for future reference you click the pencil icon next to the topic title and change the category from “need help…” to “solved” and click the tick/check button.

Pete.

thx