As part of our efforts to provide additional services on our soon-to-be revised Australian Security Journal, we're building a number of APIs that support the information we'd like to generally share and use. One of those APIs deals with Australian Road Fatalities. Since we'd like to provide a reference to the impact of the fatality count over time (say, per 100,000 population), we needed a source of historical population data from which to calculate those numbers. In playing with data from the Australian Bureau of Statistics we stumbled across a funky little tool that provides incremental real-time population growth based on predictive data. The following article will show you how to include that data on your website.
The following shortcode will return data almost exactly as the ABS has done on its website. The shortcode of
[bmauspop] returns the following:
We're caching data for 18 hours.
Copy and paste the WordPress function into your theme's
functions.php file or, if you sensibly have one installed, your custom functions plugin.
Usage requires the Simple Cache plugin. This simply makes life easier by retrieving older data is the transient has expired and the API is unresponsive.
The following shortcode attributes are available.
meta="1"will show the bullet list of data underneath the population (default). To disable, use
meta="0"in your shortcode or hardcode it into the shortcode function. The resulting population figure without meta data is shown below.
font-size: 2.0em; color: #008000; text-align: center; text-decoration: bold;.
Used outside of WordPress, the following may be used. Usage of Simple Cache is required (to avoid making repeated requests to the ABS API).
- The ABS JSON data unfolds as follows. Use as required:
- The data is copyright of the ABS and appropriate attribution should be provided.
- Given the growth rate is provided, you might consider providing projections. Additionally, you might store current data in a cookie or session and then provide growth since a last visit etc.
- There's a lot of data on the ABS website... some that we'll return to over time. In particular, we'll be sourcing finance data for our clients and will incorporate relevant code into the BM Finance Plugin.