# VATSIM Metar

**URL:** <https://forum.phpvms.net/t/vatsim-metar/8284>\
**Category:** Code Snippets\
**Created:** [July 7, 2013, 7:00am UTC](https://forum.phpvms.net/t/vatsim-metar/8284 "2013-07-07T07:00:07Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tylor\_Eddy](https://forum.phpvms.net/user_avatar/forum.phpvms.net/tylor_eddy/32/48_2.png) [@Tylor\_Eddy](https://forum.phpvms.net/u/Tylor_Eddy)\
**Post date:** [July 7, 2013, 7:00am UTC](https://forum.phpvms.net/t/vatsim-metar/8284/1 "2013-07-07T07:00:07Z")

</div>

G’day Guys,

I’ve been fidding around with METAR information, and have managed to get a working script of the VATSIM metar information. Best part about it is that there is NO iframes!

Here is a quick shot to show you what it looks like

For Departure Airport:

```
<?php
$metar = $_POST['metar'];
$url = 'http://metar.vatsim.net/'.$schedule->depicao.'';
$page = file_get_contents($url);
echo $page;
?>

```

For Arrival Airport:

```
<?php
$metar = $_POST['metar'];
$url = 'http://metar.vatsim.net/'.$schedule->arricao.'';
$page = file_get_contents($url);
echo $page;
?>

```

Hopefully you guys find this valuable

---

<div class="post-metadata">

**Author:** ![BaRBeR](https://forum.phpvms.net/user_avatar/forum.phpvms.net/barber/32/209_2.png) [@BaRBeR](https://forum.phpvms.net/u/BaRBeR)\
**Post date:** [July 7, 2013, 11:15am UTC](https://forum.phpvms.net/t/vatsim-metar/8284/2 "2013-07-07T11:15:22Z")

</div>

Thanks mate.

---

<div class="post-metadata">

**Author:** ![Fernando](https://forum.phpvms.net/user_avatar/forum.phpvms.net/fernando/32/169_2.png) [@Fernando](https://forum.phpvms.net/u/Fernando)\
**Post date:** [July 7, 2013, 2:09pm UTC](https://forum.phpvms.net/t/vatsim-metar/8284/3 "2013-07-07T14:09:09Z")

</div>

Tylor Eddy, Very nice!!!

Thank you!

---

<div class="post-metadata">

**Author:** ![bteixeira](https://forum.phpvms.net/user_avatar/forum.phpvms.net/bteixeira/32/275_2.png) [@bteixeira](https://forum.phpvms.net/u/bteixeira)\
**Post date:** [February 18, 2014, 2:09pm UTC](https://forum.phpvms.net/t/vatsim-metar/8284/4 "2014-02-18T14:09:01Z")

</div>

Hi and thanks. In what page do you change the code?

---

<div class="post-metadata">

**Author:** ![poole3003](https://forum.phpvms.net/letter_avatar_proxy/v4/letter/p/e8c25b/32.png) [@poole3003](https://forum.phpvms.net/u/poole3003)\
**Post date:** [August 24, 2014, 9:12pm UTC](https://forum.phpvms.net/t/vatsim-metar/8284/5 "2014-08-24T21:12:47Z")

</div>

and where am i inserting this

---

<div class="post-metadata">

**Author:** ![ln-asm](https://forum.phpvms.net/letter_avatar_proxy/v4/letter/l/258eb7/32.png) [@ln-asm](https://forum.phpvms.net/u/ln-asm)\
**Post date:** [August 31, 2014, 9:15am UTC](https://forum.phpvms.net/t/vatsim-metar/8284/6 "2014-08-31T09:15:23Z")

</div>

You can add the code where ever you want it to be displayed.

For anyone using this code: be aware, Vatsim is rather strict when it comes to downloading data from their servers, and with this code, every metar will be downloaded every time someone accesses the page. If you have quite some traffic to your site, they’ll easily block your server’s access to download from Vatsim, so you might want to consider downloading and save the data on your server, and then have a script check if your local file is older than x minutes, and if it is, redownload. It’s not too difficult to set up, and all you need can be found by a simple search (I don’t have access to my FTP at the moment so I can’t post my code)

Have a read in the Vatsim forums as well:

[http://forums.vatsim.net/viewtopic.php?f=68&t=65859](http://forums.vatsim.net/viewtopic.php?f=68&t=65859)

Anders

---

<div class="post-metadata">

**Author:** ![freshJet](https://forum.phpvms.net/user_avatar/forum.phpvms.net/freshjet/32/122_2.png) [@freshJet](https://forum.phpvms.net/u/freshJet)\
**Post date:** [August 31, 2014, 10:49am UTC](https://forum.phpvms.net/t/vatsim-metar/8284/7 "2014-08-31T10:49:22Z")

</div>

For the non-members:

> If you utilise the VATSIM METAR system on your website, please have a read of my post regarding the options available to you:
> 
> [http://forums.vatsim…hp?f=68&t=65858](http://forums.vatsim.net/viewtopic.php?f=68&t=65858)
> 
> Specifically please consider how many concurrent requests you are making and how often.
> 
> The IPs below have been flagged as having make grossly excessive numbers of requests to the METAR system. By this I’m talking in the tens of thousands of requests per day. Considering you can download the entire METAR file in a single request and that METARs don’t update more than about once every 30 mins, you can have all the METARs available to you with 48 requests per day.
> 
> The record was hit last night, I won’t single out the IP, but it was 99,904 individual requests in 24 hours!
> 
> **If your ARE in the list**
> 
> If your IP is below you need to re-think how you are calling the METARs and use the ability to obtain more than one at once, if you aren’t already. See my post for more details. From this time next week, I will start blocking IPs on this list that continue with “excessive” usage. Feel free to get in touch with me if you recognise your IP and would like me to hold off banning it while you make the appropriate changes.
> 
> **If you AREN’T in the list**
> 
> Please have a look anyway to make sure you are following the guidance in my post. Those I’ve listed below are requesting in the tens of thousands and therefore I’ve flagged as “grossly excessive”. There are still many many sites making an excessive number of requests that I haven’t listed below.
> 
> Above all, please keep in mind that it’s not just you using the system and that we want to keep it available to everyone. Thanks for your cooperation
> 
> * * *
> 
> 101.165.123.94
> 
> 109.152.30.23
> 
> 119.181.196.253
> 
> 121.214.207.15
> 
> 128.68.103.32
> 
> 134.117.250.14
> 
> 151.224.165.177
> 
> 173.168.164.239
> 
> 179.197.148.51
> 
> 179.236.68.51
> 
> 186.244.65.72
> 
> 186.59.153.154
> 
> 186.59.219.242
> 
> 186.66.71.95
> 
> 186.90.26.249
> 
> 190.213.227.80
> 
> 193.80.83.17
> 
> 193.83.62.198
> 
> 2.219.31.11
> 
> 202.156.9.10
> 
> 212.83.134.11
> 
> 212.83.134.8
> 
> 217.122.54.179
> 
> 24.177.217.208
> 
> 24.41.167.220
> 
> 31.209.47.229
> 
> 41.17.242.78
> 
> 46.117.61.240
> 
> 46.39.36.138
> 
> 5.65.94.212
> 
> 58.6.156.2
> 
> 62.129.239.116
> 
> 67.3.216.160
> 
> 69.80.37.100
> 
> 71.188.84.71
> 
> 71.92.161.212
> 
> 73.178.115.165
> 
> 76.11.67.0
> 
> 76.69.139.128
> 
> 77.57.18.47
> 
> 78.14.9.127
> 
> 81.251.202.245
> 
> 81.39.251.89
> 
> 82.55.215.63
> 
> 83.162.242.118
> 
> 84.113.101.240
> 
> 84.115.244.4
> 
> 84.146.230.75
> 
> 84.146.234.100
> 
> 86.134.154.127
> 
> 86.146.43.65
> 
> 86.169.95.252
> 
> 86.201.88.226
> 
> 88.181.163.7
> 
> 88.65.181.169
> 
> 89.144.217.195
> 
> 89.151.134.92
> 
> 89.178.219.172
> 
> 89.216.236.150
> 
> 89.227.116.51
> 
> 89.227.222.125
> 
> 90.217.68.196
> 
> 90.34.91.86
> 
> 92.104.43.160
> 
> 92.133.69.109
> 
> 92.237.208.32
> 
> 92.74.241.113
> 
> 92.74.243.178
> 
> 93.93.112.27
> 
> 94.159.246.194
> 
> 94.185.176.218
> 
> 94.216.166.63
> 
> 94.254.119.209
> 
> 94.38.138.98
> 
> 94.38.139.1
> 
> 95.26.131.229

---

<div class="post-metadata">

**Author:** ![freshJet](https://forum.phpvms.net/user_avatar/forum.phpvms.net/freshjet/32/122_2.png) [@freshJet](https://forum.phpvms.net/u/freshJet)\
**Post date:** [September 1, 2014, 8:54am UTC](https://forum.phpvms.net/t/vatsim-metar/8284/8 "2014-09-01T08:54:34Z")

</div>

I retreive directly from NOAA in most cases:

[http://weather.noaa.gov/pub/data/observations/metar/stations/ICAO.TXT](http://weather.noaa.gov/pub/data/observations/metar/stations/ICAO.TXT)

Albeit it does require some extra coding to remove the timestamp but useful if you use a function to call it whenever you need it.

---

<div class="post-metadata">

**Author:** ![ChrisTaylor](https://forum.phpvms.net/letter_avatar_proxy/v4/letter/c/ce7236/32.png) [@ChrisTaylor](https://forum.phpvms.net/u/ChrisTaylor)\
**Post date:** [September 2, 2014, 11:33am UTC](https://forum.phpvms.net/t/vatsim-metar/8284/9 "2014-09-02T11:33:08Z")

</div>

where do you put this in?

---

<div class="post-metadata">

**Author:** ![Vangelis](https://forum.phpvms.net/user_avatar/forum.phpvms.net/vangelis/32/38_2.png) [@Vangelis](https://forum.phpvms.net/u/Vangelis)\
**Post date:** [September 3, 2014, 9:18pm UTC](https://forum.phpvms.net/t/vatsim-metar/8284/10 "2014-09-03T21:18:35Z")

</div>

For Departure Airport:

```
<?php
$metar = $_POST['metar'];
$url = 'http://weather.noaa.gov/pub/data/observations/metar/stations/'.$schedule->depicao.'.txt'';
$page = file_get_contents($url);
echo $page;
?>

```

For Arrival Airport:

```
<?php
$metar = $_POST['metar'];
$url = 'http://weather.noaa.gov/pub/data/observations/metar/stations'.$schedule->arricao.'.txt'';
$page = file_get_contents($url);
echo $page;
?>

```

---

<div class="post-metadata">

**Author:** ![hurkulez](https://forum.phpvms.net/user_avatar/forum.phpvms.net/hurkulez/32/401_2.png) [@hurkulez](https://forum.phpvms.net/u/hurkulez)\
**Post date:** [September 16, 2014, 10:57pm UTC](https://forum.phpvms.net/t/vatsim-metar/8284/11 "2014-09-16T22:57:59Z")

</div>

Is there a way to get the data every hour, and have it post it to a DB @ phpvms\_metars. Then call it from the local DB?

---

<div class="post-metadata">

**Author:** ![Vangelis](https://forum.phpvms.net/user_avatar/forum.phpvms.net/vangelis/32/38_2.png) [@Vangelis](https://forum.phpvms.net/u/Vangelis)\
**Post date:** [September 17, 2014, 8:54pm UTC](https://forum.phpvms.net/t/vatsim-metar/8284/12 "2014-09-17T20:54:21Z")

</div>

there is no need to do that you can save the txt file on your server and grab it from there i might be able to give you a script 2morrow as i am still at work

---

<div class="post-metadata">

**Author:** ![hurkulez](https://forum.phpvms.net/user_avatar/forum.phpvms.net/hurkulez/32/401_2.png) [@hurkulez](https://forum.phpvms.net/u/hurkulez)\
**Post date:** [January 16, 2015, 4:02pm UTC](https://forum.phpvms.net/t/vatsim-metar/8284/13 "2015-01-16T16:02:02Z")

</div>

Sry for the long wait for a reply. Writing code for a new VA…

---

<div class="post-metadata">

**Author:** ![shakamonkey88](https://forum.phpvms.net/user_avatar/forum.phpvms.net/shakamonkey88/32/969_2.png) [@shakamonkey88](https://forum.phpvms.net/u/shakamonkey88)\
**Post date:** [April 30, 2018, 1:10pm UTC](https://forum.phpvms.net/t/vatsim-metar/8284/14 "2018-04-30T13:10:51Z")

</div>

> On 17/09/2014 at 9:54 PM, Vangelis said:
> 
> there is no need to do that you can save the txt file on your server and grab it from there i might be able to give you a script 2morrow as i am still at work

Hey Vangelis,

I know this post is old but I’m wondering whether you wrote a script for this?

Thanks,

Pete

---

<div class="post-metadata">

**Author:** ![Vangelis](https://forum.phpvms.net/user_avatar/forum.phpvms.net/vangelis/32/38_2.png) [@Vangelis](https://forum.phpvms.net/u/Vangelis)\
**Post date:** [May 1, 2018, 8:24pm UTC](https://forum.phpvms.net/t/vatsim-metar/8284/15 "2018-05-01T20:24:46Z")

</div>

No I did not&nbsp;

---

<div class="post-metadata">

**Author:** ![shakamonkey88](https://forum.phpvms.net/user_avatar/forum.phpvms.net/shakamonkey88/32/969_2.png) [@shakamonkey88](https://forum.phpvms.net/u/shakamonkey88)\
**Post date:** [May 1, 2018, 9:13pm UTC](https://forum.phpvms.net/t/vatsim-metar/8284/16 "2018-05-01T21:13:38Z")

</div>

No problem. We’re now using checkwx and their API. Will try out alternative PHP cache using&nbsp;apc\_store and apc\_fetch.&nbsp;

---

<div class="post-metadata">

**Author:** ![nabeel](https://forum.phpvms.net/user_avatar/forum.phpvms.net/nabeel/32/2971_2.png) [@nabeel](https://forum.phpvms.net/u/nabeel)\
**Post date:** [May 4, 2018, 3:24am UTC](https://forum.phpvms.net/t/vatsim-metar/8284/17 "2018-05-04T03:24:38Z")

</div>

> On 5/1/2018 at 4:13 PM, shakamonkey88 said:
> 
> No problem. We’re now using checkwx and their API. Will try out alternative PHP cache using&nbsp;apc\_store and apc\_fetch.&nbsp;

CheckWX is real easy to use. I took a super old PHP parser and updating it to run with the latest PHP:

[https://github.com/nabeelio/phpvms/blob/master/app/Support/Metar.php](https://github.com/nabeelio/phpvms/blob/master/app/Support/Metar.php)

This is the original:

[https://github.com/hsdn/metar-taf](https://github.com/hsdn/metar-taf)
