Programmable API Reducing Feeds And Information Threads
Because feeds got layers!
PARFAIT is a web API that provides a method for concise weather data or RSS feed data to be imported or consumed when the raw XML formatted file is larger than allowed to be imported and processed by the recipient, when the recipient can't handle XML, or when the recipient wants some simple data already processed out. The size issue was especially true for Second Life (a virtual world) at the time this API was first developed in 2011, and was the reason for PARFAIT to be developed. It is assumed that since virtual worlds have many constraints around processing live external data, this will be the primary use. However, due to the ability of the API to preprocess and return specific weather datum, it is expected that there will be some use in other 'real' world situations.
To learn how to retrieve current weather observations, refer to the documentation here: help-current.php.
To learn how to retrieve forecast weather information, refer to the documentation here: help-forecast.php.
To learn how to retrieve Reuters news feeds, refer to the documentation here: help-reuters.php.
To learn how to retrieve NASA news feeds, refer to the documentation here: help-nasa.php.
To learn how to retrieve ESPN news feeds, refer to the documentation here: help-espn.php.
For more information or assistance with this website, please e-mail me: Mike@OmegaTower.com.
The weather data is courtesy of NOAA's National Weather Service.
The Reuters news feeds are courtesy of Reuters.com.
The NASA news feeds are courtesy of NASA.
The ESPN news feeds are courtesy of ESPN.
With the exception of the Current Datum and Current Capsule which return a single text string, the returned data is in a double (or triple) delimited format. That is to say that the lines of data have a unique terminators, and the data elements have a different unique delimiter. This allows the use of layered string splits to retrieve the data element required. Calling for the current conditions with 'head', 'high' and 'extra' layers will return something like this:
hd*ParfaitAPI*http://parfait.snarkybox.com/*current****KLAX**head,high,extra*20141210*2118*184.108.40.206*2014.12.10.13~hi*Los Angeles Intl Airport, CA*Last Updated on Dec 10 2014, 5:53 pm PST*Overcast*62.0 F (16.7 C)*90*Southwest at 4.6 MPH (4 KT)*59.0 F (15.0 C)**62 F (17 C)*7.00*ovc.png~ex*33.94*-118.4****1013.9 mb*1013.9*29.94**~
This is three lines, one for the header information and one for each layer requested, with the lines terminated with a '~' character. So, using an split operation on the full string would separate it into three lines:
hi*Los Angeles Intl Airport, CA*Last Updated on Dec 10 2014, 5:53 pm PST*Overcast*62.0 F (16.7 C)*90*Southwest at 4.6 MPH (4 KT)*59.0 F (15.0 C)**62 F (17 C)*7.00*ovc.png~
From here, another split operation on each of the strings will allow for the selection of an individual datum. In addition to the tilde and asterisk shown here, the forecast and other news feeds have an additional terminator placed at the end of each layer section: the pipe '|'. The full specification for the data returned by each of the different layers is fully explained in the help files (help-current.php, help-forecast.php, help-reuters.php, help-nasa.php and help-espn.php).
To determine which line you want to look at you can test against the first two characters of each line to find its identifier code.
In Second Life I used these calls to create various weather related objects that would display live observed real world data as well as broadcast the current weather and forecast information to others in the region. Currently I am working on creating a digital clock with live temperature and news crawls.
- Added the '^' chunk to display Weather String Title in the Current Capsule.
- Added the '<' chunk to display the icon URL text in the Current Capsule.
- Added the '~' chunk to display an arbitrary HTML Entity Code in the Current Capsule.
- Added the 'r' modifier to the 'i' chunk to display the Relative Humidity as a Weather String in the Current Capsule.
- Added the '|' modifier to the 'i' chunk to display the Wind Chill or Heat Index as a Weather String in the Current Capsule.
- Added the 'c' modifier to the 'o' chunk to display the Observation Time as a Weather String in the Current Capsule.
- Added the 'c' modifier to the 'o' chunk to display a more informative Current Observation in the Forecast Capsule.
- Changed the Forecast Capsule so that the gray bar effect isn't based on even and odd rows, but rather on day or night time forecast.
- PARFAIT now has a logo and favicon.
- Added the Capsule Retrieval to the Forecast Weather API.
- Removed Icon-location data element from the Forecast Meta layer.
- Changed the Icon data element in the Forecast Low Layer to be the full URL of the icon.
- Added Station ID to the Capsule Retrieval in the Current Weather API.
- Added Degree Symbol replace to the Capsule Retrieval in the Current Weather API.
- Added Space Symbol replace to the Capsule Retrieval in the Current Weather API.
- Added Location to the Capsule Retrieval in the Current Weather API.
- Added Observation Time to the Capsule Retrieval in the Current Weather API.
- Added New Line to the Capsule Retrieval in the Current Weather API.
- Added HTML Output to the Capsule Retrieval in the Current Weather API.
- Changed default degree symbol from 'o' to '*' in the Capsule Retrieval in the Current Weather API.
- Expanded the features of the Capsule Retrieval in the Current Weather API.
- Added the Capsule Retrieval to the Current Weather API.
- Added HTTP User Agent to all API retrieval calls.
- Added 'API identification' and 'API URL' elements to all header layers.
- The 'current' API's 'other' layer has been re-identified as 'meta' to bring it in line with the other APIs.
- The 'forecast' API's 'forecast' layer has been re-identified as 'low' to bring it in line with the other APIs.
- The error messages have been changed from HTML documents to a PARFAIT layer. See any of the help files, under Errors, for more information.
- New API: ESPN. You can now download a news feed from ESPN.
- All CDATA and HTML has been removed from the output.
- The Smeather API has been officially re-branded as PARFAIT.
- The 'type' parameter has been changed to be the 'layer' parameter.
- New API: NASA. You can now download a news feed from NASA.
- A pipe '|' character has now been placed at the end of each layer's output lines when calling the forecast and news APIs. This will make it easier parsing when there is an inconsistent number of lines between calls.
- New API: Reuters. You can now download a news feed from Reuters.com.
- The three separator characters have now been stripped from the raw XML before it is returned.
- Spaces are now stripped if sent in the layer parameter
- The header line is now optional using the new layer parameter = 'head' for both current and forecast
- Current Test Mode 2 now outputs the XML data rather than a converted array
- Current now uses the PHP SimpleXML object instead of an converted array to allow the use of xpaths
- Added the actual URL called when the test parameter is used in both current and forecast
- Added these elements: mt08, mt09, mt10, mt11, fc08
- Changed tx02 to be the period range in a date time format
- Changed fc06 and fc07 to match more closely the data available in the new DWML file
- Converted forecast to use the more modern DWML output from NOAA
- Forecast.mt06 is now a UTC time string
- Forecast Test Mode 2 now outputs the XML data rather than a converted array
- Forecast now uses the PHP SimpleXML object instead of an converted array to allow the use of xpaths
- Added data layers to help-forecast.php
- All calls to current are now captured to a database
- All calls to forecast are now captured to a database
- Added error page when either current or forecast are called without any parameters
- Added robots.txt and 'rel="nofollow" ' to links in help-current.php and help-forecast.php
- Added trim function to all data elements
- Make displayed version number dynamic throughout all php code
- Added version to parameter table when using test mode.
- Added link to MapQuest Latitude/Longitude Finder in the help-forecast.php
- Added data layers to help-current.php
- Added header line
- Several language changes in introduction and help files
- Changed all layer codes to be 2 characters
- Reformatted output of the the forecast lines so that each period had it's own line
- Added periods parameter to forecast so that fewer periods could be returned
- Updated call to NOAA to match their change to only accept uppercase ICAO values
- This is also the first formally recorded version number. Previous versions of this API had no version number.