Api update intervals

This is what happens.

Establish a web socket with the WeatherFlow server.
Subscribe to events.
On data received, parse the data and store it in MySQL.

That being said, there is a LOT of code involved to do each step.

Here is some sample data received via the socket.



This data has to be parsed and put into variables, which in turn are stored in the proper table. I store the data in the units it comes in and later convert the data to different units.

You are doing a lot more than just getting data from WeatherFlow so I’m not sure how much help I can be.

1 Like

ok no problem here is what im using and parsing every 3 seconds



function initWS() {
var socket = new WebSocket(“ws://ws.weatherflow.com/swd/data?api_key=xxxxxx”),
container = $("#container")
socket.onopen = function() {
socket.onmessage = function (e) {
document.getElementById(“log”).innerHTML = e.data;


// Connection opened send to command to weatherflow listen_rapid_start device_id":5961
socket.addEventListener(‘open’, function (event) {
return socket;

That looks correct. Are you actually getting the data?

If yes, then you are half way there.

1 Like

yes every three seconds I’ve been stuck at that point for three weeks on getting the data to dump to a file I am neither able to work out how to get the data dumped to text file or found any solution ,I’ve read and tried to understand every write up on websocket I can find … most are all talking about chat and video streaming benefits but ill get there sooner or later


bold is the wind speed and wind direction

in the screenshot you can see the time is at three second intervals


1 Like

Okay, I understand more now.

How is the above getting to the file you are reading?

1 Like

code in a single php file

1 Like

What are you using to write the file ‘MBrealtimeupload.txt’ ?

1 Like

meteobridge has a built in function to send data direct to the template

in the file meteobridge calls and then we use file_put_contents

$filename = “MBrealtimeupload.txt”;
if( isset($_GET[‘d’]) ) {
file_put_contents($filename, $string);
header(‘Content-Type: text/plain’);
echo “success”;

Copy that code to write the JSON code to the file you want.

$filename = “MBrealtimeupload.txt”;
$string = [received JSON string];
file_put_contents($filename, $string);
header(‘Content-Type: text/plain’);
echo “success”;

The only question is; What format do you need to write the data to the file?"

1 Like

im lost ? which file I don’t need to change anything in the meteobridge files im more interested in resolving websocket for weather flow or re you saying put this into the websocket file and use a different filename.txt

1 Like


var obj = JSON.parse(string);

and write the obj data to SQL

(timestamp, speed, direction)
(obj.ob[0], obj.ob[1], obj.ob[2])

1 Like

Ok Gary I see where you going I’ll look at it tomorrow evening it’s 1:30am now and I have to take the wife shopping tomorrow which I’m dreading looking at a 1000s pairs of shoes… probably need a beer with my breakfast to numb the feeling…thanks we will get there sooner or later…brian

1 Like

Mummmm. Beer.

I hoped I’ve helped. If so please use the :heart: to like my posts.


1 Like

Hi, Brian,

Have you made progress toward your goal?

1 Like

no preoccupied on other things , I will get to it but need to allocate some dedicated time.


For those of us that don’t speak “programming” how can I get access to my historical data? Is it possible through your dashboard on the web based WF account?

What do you mean by access?
The API can give you access to the raw data:

Do you mean graphs using your stations data?


That was exactly what I was looking for. Now I just need to know how to download it.

Thanks a lot!

There are ways to get the data or have an application get the data foe you.

WFArchive has this built in.

You can get the data yourself by using the WeatherFlow REST API. Here is an example:


where 11973 is the device_id of your Air or Sky and day_offset the the UTC day back you want. 0 = today, 1 = yesterday, etc.

Once you download the data, it is up to you how you handle it.


Thanks a lot @GaryFunk for the helpful info and all the contribute to this forum!