Source Code Samples

API integration code samples


var xhttp = new XMLHttpRequest();
 
xhttp.onreadystatechange = function() {
  if (this.readyState == 4 && this.status == 200) {
    console.log(xhttp.responseText);
  }
};

xhttp.setRequestHeader('X-API-Key', 'YOUR_API_KEY')
xhttp.open("GET", "https://api.checkwx.com/metar/KJFK/decoded", true);
xhttp.send();


$.ajax({
  type: 'GET',
  url: 'https://api.checkwx.com/metar/KJFK/decoded',
  headers: { 'X-API-Key': 'YOUR_API_KEY' },
  dataType: 'json',
  success: function (result) {
    console.log(result)
  }
});


const axios = require('axios');

const options = {
  headers: {'X-API-Key': 'YOUR_API_KEY'}
};

axios.get('https://api.checkwx.com/metar/KJFK/decoded', options).then(resp => {
  console.log(resp.data);
});


$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.checkwx.com/metar/kjfk/decoded');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, ['X-API-Key: YOUR_API_KEY']);

$resp = curl_exec($ch);
print_r($resp);

curl_close $ch);


import requests
import json

hdr = {"X-API-Key": "YOUR_API_KEY"}
req = requests.get("https://api.checkwx.com/metar/kjfk/decoded", headers=hdr)

print("Response from CheckWX.... \n")

try:
    req.raise_for_status()
    resp = json.loads(req.text)
    print(json.dumps(resp, indent=1))

except requests.exceptions.HTTPError as e:
    print(e)


require 'net/http'

uri = URI('https://api.checkwx.com/metar/KJFK/decoded')

Net::HTTP.start(uri.host, uri.port,: use_ssl => uri.scheme ==
'https') do |http |
    req = Net::HTTP::Get.new uri
  req.add_field("X-API-Key", "YOUR_API_KEY")
  
resp = http.request req
puts resp.body
end


curl 'https://api.checkwx.com/metar/KJFK/decoded' \
  -H 'X-API-Key: YOUR_API_KEY'