Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 06:28 29 Mar 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : CheckWX

Author Message
lew247

Guru

Joined: 23/12/2015
Location: United Kingdom
Posts: 1676
Posted: 12:02pm 19 Aug 2019
Copy link to clipboard 
Print this post

Good Afternoon  

I wonder if anyone can help

I'd like to be able to receive the data from CheckWX.com API service

The reason I'd like to do this is to get the local data from the nearest Airport
Mainly pressure but other information would be nice to get
I want to be able to parse it and use it on a Micrommite

This is an example they suggest but I have not been able to figure out how to get it to work with the MM the same as the api's below
$ curl 'https://api.checkwx.com/{endpoint}/' -H 'X-API-Key: API_KEY'


This is the same request in Python
import requests

hdr = { 'X-API-Key': 'API_KEY' }
req = requests.get('https://api.checkwx.com/station/:icao', headers=hdr)
print(req.text)


Jquery example
$.ajax({
 type: 'GET',
 url: 'https://api.checkwx.com/station/:icao',
 headers: { 'X-API-Key': 'API_KEY'  },
 dataType: 'json',
 success: function (result) {
   console.log(result)
 }
});


  Quote  Getting Started
This documentation is structured first by a group of related functionality: STATION, METAR or TAF. Then by endpoint which is a specific method within that API that performs one action and is located at a specific URL.

The API is organized around REST
All requests should be made over SSL
All request and response bodies, including errors, are encoded in JSON by default
Each endpoint in this documentation is described using several parts:

Base URL https://api.checkwx.com/
API Endpoint
Header Parameters
URL Parameters
Querystring Parameters

Authentication
All endpoints require an API key, which is unique for each user.

You must register for a free API key at CheckWX.com

Provided your API key as a Header Parameter with each request as shown in the examples
In all our examples replace API_KEY with your unique API key



I've been able in the past to get Wunderground, Darksky and other API's and I can parse Json data but I cannot figure how to actually call the data on this one

These are the calls I use
system "wget -q -O-  "+q$+"https://api.darksky.net/forecast/API-KEY/53.440120,-2.106181?units=uk2&exclude=flags,alerts,minutely"+q$,a()
'Current weather from Darksky

system "wget -q -O-  "+q$+"api.openweathermap.org/data/2.5/forecast/daily?id=2651357&units=metric&appid=API-KEY"+q$,c()
'Current weather from Openweathermap

system "wget -q -O- "+q$+"api.wunderground.com/api/API-KEY/geolookup/conditions/q/GB/HYDE.json"+q$,d()
'Current weather from Wunderground


This Website has the information on the API used on the CheckWX website

THIS Page is where anyone can register for a free API key


I'm using a Pi and I can either use Pi-Cromite or Python as I have 2 pi's doing different things and either would suffice
Preferably the Pi-Cromite one though
Edited 2019-08-20 01:31 by lew247
 
disco4now

Guru

Joined: 18/12/2014
Location: Australia
Posts: 839
Posted: 07:23am 20 Aug 2019
Copy link to clipboard 
Print this post

Hi Lewis,
This worked from the commandline in win10, where XXXXXXXXXX is the API key


curl https://api.checkwx.com/station/KPIE -H "x-api-key:XXXXXXXXXXXXXXXXXXXXXXXXXX"


Regards
Gerry
Latest F4 Latest H7
 
disco4now

Guru

Joined: 18/12/2014
Location: Australia
Posts: 839
Posted: 07:28am 20 Aug 2019
Copy link to clipboard 
Print this post


{"results":1,"data":[{"state":{"code":"FL","name":"Florida"},"country":{"code":"US","name":"United States"},"location":{"coordinates":[-82.686493,27.908688],"type":"Point"},"timezone":{"gmt":-5,"dst":-4,"tzid":"America/New_York"},"elevation":{"feet":10.5,"meters":3.2,"method":"Surveyed"},"magnetic_variation":{"position":"05W","year":2010},"icao":"KPIE","iata":"PIE","name":"St Pete-Clearwater International","type":"Airport","city":"Clearwater","status":"Operational","useage":"Public","sectional":"MIAMI","activated":"10/1942","latitude":{"decimal":27.908688,"degrees":"27-¦ 54' 31.28\" N"},"longitude":{"decimal":-82.686493,"degrees":"82-¦ 41' 11.37\" W"}}]}


Latest F4 Latest H7
 
lew247

Guru

Joined: 23/12/2015
Location: United Kingdom
Posts: 1676
Posted: 10:22am 20 Aug 2019
Copy link to clipboard 
Print this post

Thank you so much  
 
lew247

Guru

Joined: 23/12/2015
Location: United Kingdom
Posts: 1676
Posted: 10:34am 20 Aug 2019
Copy link to clipboard 
Print this post

In case anyone wants to use it
The current weather conditions for my local airport (Manchester UK) is

curl https://api.checkwx.com/metar/EGCC/decoded?pretty=1 -H "x-api-key:Your-API-Key"


If you want the raw data use pretty=0

If you want the forecast use taf instead of metar

curl https://api.checkwx.com/taf/EGCC/decoded?pretty=1 -H "x-api-key:Your-API-Key"

Edited 2020-11-29 19:10 by lew247
 
lew247

Guru

Joined: 23/12/2015
Location: United Kingdom
Posts: 1676
Posted: 09:13am 29 Nov 2020
Copy link to clipboard 
Print this post

I've tried to get this working on Pi-cromite but it always fails.
Using terminal from a pc talking direct to the pi I can type curl https://api.CHECKWX.com/taf/EGCC/ -H "69ad9b73b10847ed8791fb0331"
Which it works and the result is this

{"results":1,"data":["TAF EGCC 290502Z 2906/3012 VRB03KT 6000 BKN010 TEMPO 2906/2912 2000 BR BKN004 PROB40 TEMPO 2918/3002 2000 BR BKN004 BECMG 3006/3009 9999 SCT020 TEMPO 3009/3012 BKN012"]}


Is there a way to use curl with the system command to make it work with mm?

This works for wget system "wget -q -O- "+q$+"https://api.openweathermap.org/data/2.5/onecall?lat=53.43&lon=-2.10&units=metric&exclude=current,daily&appid=YOUR-KEY"+q$,c()

but it won't with curl

I've tried numberous times using mixtures of
system curl https://api.CHECKWX.com/taf/EGCC/ -H "x-api-key:69ad9b73b10847ed8791fb0331" +q$,c()
system curl q$+ "https://api.CHECKWX.com/taf/EGCC/ -H "x-api-key:69ad9b73b10847ed8791fb0331"" +q$,c()  system curl q$+ https://api.CHECKWX.com/taf/EGCC/ -H "x-api-key:69ad9b73b10847ed8791fb0331" +q$,c()
but I can't get it to work
it says expected a string
 
disco4now

Guru

Joined: 18/12/2014
Location: Australia
Posts: 839
Posted: 09:30am 29 Nov 2020
Copy link to clipboard 
Print this post

Do these work. Second one just has some extra parameters for CURL


system "curl "+q$+"https://api.CHECKWX.com/taf/EGCC/ -H x-api-key:69ad9b73b10847ed8791fb0331"+q$,c()

system "curl "+q$+"https://api.CHECKWX.com/taf/EGCC/ -H x-api-key:69ad9b73b10847ed8791fb0331"+q$+" -m 60 -s -S",c()
Latest F4 Latest H7
 
lew247

Guru

Joined: 23/12/2015
Location: United Kingdom
Posts: 1676
Posted: 09:36am 29 Nov 2020
Copy link to clipboard 
Print this post

Close
system "curl "+q$+"https://api.CHECKWX.com/taf/EGCC/ -H x-api-key:69ad9b73b10847ed8791fb0331"+q$,c()
gives



system "curl "+q$+"https://api.CHECKWX.com/taf/EGCC/ -H x-api-key:69ad9b73b10847ed8791fb0331"+q$+" -m 60 -s -S",c()
gives



EDIT: I think system "curl "+q$+"https://api.CHECKWX.com/taf/EGCC/ -H x-api-key:69ad9b73b10847ed8791fb0331"+q$+" -m 60 -s -S",c() didn't work is because
x-api-key:69ad9b73b10847ed8791fb0331 has to be "x-api-key:69ad9b73b10847ed8791fb0331"
Edited 2020-11-29 19:41 by lew247
 
lew247

Guru

Joined: 23/12/2015
Location: United Kingdom
Posts: 1676
Posted: 10:24am 29 Nov 2020
Copy link to clipboard 
Print this post

I thought this should do it
system "curl "+q$+https://api.CHECKWX.com/taf/EGCC/ -H "x-api-key:69ad9b73b10847ed8791fb0331"+q$+" -m 60 -s -S",c()
but it says incompatible types in expression
 
disco4now

Guru

Joined: 18/12/2014
Location: Australia
Posts: 839
Posted: 10:32am 29 Nov 2020
Copy link to clipboard 
Print this post

Maybe this

system "curl "+q$+"https://api.CHECKWX.com/taf/EGCC/ -H"+q$+" "+q$+"x-api-key:69ad9b73b10847ed8791fb0331"+q$+" -m 60 -s -S",c()
Latest F4 Latest H7
 
lew247

Guru

Joined: 23/12/2015
Location: United Kingdom
Posts: 1676
Posted: 10:45am 29 Nov 2020
Copy link to clipboard 
Print this post

  disco4now said  Maybe this
system "curl "+q$+"https://api.CHECKWX.com/taf/EGCC/ -H"+q$+" "+q$+"x-api-key:69ad9b73b10847ed8791fb0331"+q$+" -m 60 -s -S",c()


 
lew247

Guru

Joined: 23/12/2015
Location: United Kingdom
Posts: 1676
Posted: 11:06am 29 Nov 2020
Copy link to clipboard 
Print this post

Maybe it's not possible it seems to be thinking the api key is another web address
 
lew247

Guru

Joined: 23/12/2015
Location: United Kingdom
Posts: 1676
Posted: 11:14am 29 Nov 2020
Copy link to clipboard 
Print this post

I've just tested it using terminal to the PI from Windows and
curl https://api.CHECKWX.com/taf/EGCC/ -H  x-api-key:69ad9b73b10847ed8791fb0331  works

system "curl https://api.CHECKWX.com/taf/EGCC/ -H  x-api-key:69ad9b73b10847ed8791fb0331"+q$,c() results in


I need a way to pass the spaces in the address through the system command "%20" doesn't work
and using %20 results in

Edited 2020-11-29 21:26 by lew247
 
lew247

Guru

Joined: 23/12/2015
Location: United Kingdom
Posts: 1676
Posted: 11:27am 29 Nov 2020
Copy link to clipboard 
Print this post

it's hard work posting and reading with the SSL cert out of date

using either of these
as in

system "curl https://api.CHECKWX.com/taf/EGCC/ -H x-api-key:69ad9b73b10847ed8791fb0331"+q$,c()
(Spaces are showing as spaces and not & #32;)
both give

Edited 2020-11-29 21:41 by lew247
 
lew247

Guru

Joined: 23/12/2015
Location: United Kingdom
Posts: 1676
Posted: 03:58pm 29 Nov 2020
Copy link to clipboard 
Print this post

Finally  

If anyone else needs to know how to use Curl with Pi-Cromite and it has a user/pass its'

  Quote  system "curl  -H x-api-key:69ad9b73b10847ed8791fb0331 "+q$+"https://api.CHECKWX.com/taf/EGCC/"+q$+" -m 60 -s -S",c()
 
Print this page


To reply to this topic, you need to log in.

© JAQ Software 2024