infonews.co.nz

API Documentation


Introduction

The infonews.co.nz API enables developers to access data from the infonews.co.nz database.

The API works over HTTP. By default, requests are HTTP GET requests and all arguments are passed as GET parameters. Return data is an XML data packet.

There are two methods available for the infonews.co.nz API, one to access news and one to access events.

If you have any further questions or would like to apply for access to the API please email fraser@infonews.co.nz.


News API



http://www.infonews.co.nz/api/news.cfm

Arguments
keyRequiredAPI key which will be supplied to you.
vOptionalVersion of API. Default is 1.
tOptionalInteger. The topic number.
lOptionalInteger. The location number.
idOptionalInteger. The news id number.
limitOptionalInteger (1-100). Default is 30.
offsetOptionalInteger. Default is 1.


A call to the News method will return XML data ordered by date, with the most recent news first. If an id argument is given then only data for that one news story will be returned. Otherwise all news data will be returned up to a maximum of limit stories.

Note: You can access data for more than the 100 maximum by making further calls and using the offset argument. However, the API can only access the most recent 250 stories for any query.

Use t or l to limit the results by topic or location respectiviely. Check the url of a topic or location page from the Index to work out the integer for a topic or location. Note: Your API key may already restrict access to certain topics or locations by default.




Example 1

A call to a specific story id.

http://www.infonews.co.nz/api/news.cfm?key=XXXXXXXX&id=43789

Will return the following xml:

<infonews> <news> <title>Traffic builds up</title> <link>http://www.infonews.co.nz/news.cfm?id=43789</link> <topic>Traffic</topic> <location>Wellington</location> <author>New Zealand Police</author> <brief><![CDATA[ Police are advising that the traffic flows on the State Highway system and other main arterial routes leading back into Wellington City are starting to build up. ]]></brief> <story><![CDATA[ ><p>Police are advising that the traffic flows on the State Highway system and other main arterial routes leading back into Wellington City are starting to build up.</p><p>Police are urging all motorists to take care, show tolerance and display patience toward other drivers.</p><p>All motorists need to be actively aware of the driving conditions that they are confronting.</p><p>There will be delays at different times and points but please be assured everyone is working hard to ensure you get home safe and in a timely manner.&nbsp;</p> ]]></story> <pubDate>{ts '2009-10-26 17:29:25'}</pubDate> </news> </infonews> View the story as it appears on infonews.co.nz here.


Example 2

If you are using Version 2 of the API, the xml returned will include photo data if there are photos linked to the news.

http://www.infonews.co.nz/api/news.cfm?key=XXXXXXXX&id=51581

Will return the following xml:

<infonews> <news> <title>Police search for missing woman</title> <link>http://www.infonews.co.nz/news.cfm?id=51581</link> <topic>Police</topic> <location>Whanganui</location> <author>New Zealand Police</author> <brief><![CDATA[ Police in Whanganui are searching for a woman who is believed to have been missing for 10 days. ]]></brief> <story><![CDATA[ ><p>Police in Whanganui are searching for a woman who is believed to have been missing for 10 days.<br /><br />On Monday, 19 April a bus driver spotted a woman sitting in a red Suzuki Stationwagon on SH4, at the Lismore intersection. He later noticed the same vehicle parked on ... Police search is asked to contact Whanganui Police on 06 349 0600.<br /><br />Media enquiries should be referred to Communications Manager Kim Perks on 06 351 2546 or 027 234 8256.</p> ]]></story> <pubDate>{ts '2010-04-29 20:11:32'}</pubDate> </news> <photo> <img>Mcgregor Marice.jpg</img> <caption>Marice Jane McGregor</caption> <credit>New Zealand Police</credit> <profile>355</profile> </photo> </infonews> View the story as it appears on infonews.co.nz here.

Prefix the image name with http://www.infonews.co.nz/photos/ for the url of the photo. In this example the url would be:

http://www.infonews.co.nz/photos/Mcgregor Marice.jpg

Photos are also available in three other sizes, resized to maximum height or width of 150, 300 and 600 pixels.

http://www.infonews.co.nz/photos/150-Mcgregor Marice.jpg
http://www.infonews.co.nz/photos/300-Mcgregor Marice.jpg
http://www.infonews.co.nz/photos/600-Mcgregor Marice.jpg


Example 3

A call to get traffic stories.

http://www.infonews.co.nz/api/news.cfm?key=XXXXXXXX&t=118

Will return the following xml:

<infonews> <news> <id>43934</id> <title>Caution advised on Coromandel roads this weekend</title> <link>http://www.infonews.co.nz/news.cfm?id=43934</link> <topic>Traffic</topic> <location>Coromandel</location> <author>New Zealand Police</author> <brief><![CDATA[ Police hope motorists in the Coromandel will get as much 'exercise' as cyclists this weekend with over 1,500 riders set to hit roads around the peninsula. ]]></brief> <pubDate>{ts '2009-10-29 14:44:22'}</pubDate> </news> <news> <id>43855</id> <title>Appeal for crash witnesses to come forward</title> <link>http://www.infonews.co.nz/news.cfm?id=43855</link> <topic>Traffic</topic> <location>Huntly</location> <author>New Zealand Police</author> <brief><![CDATA[ Huntly Police are seeking witnesses to a crash that left a male motorcyclist seriously injured and a toddler fighting for his life near Taupiri on Sunday. ]]></brief> <pubDate>{ts '2009-10-28 08:08:06'}</pubDate> </news> ... </infonews>


Events API



http://www.infonews.co.nz/api/events.cfm

Arguments
keyRequiredAPI key which will be supplied to you.
vOptionalVersion of API. Default is 1.
tOptionalInteger. The topic number.
lOptionalInteger. The location number.
idOptionalInteger. The news id number.
limitOptionalInteger (1-100). Default is 30.
offsetOptionalInteger. Default is 1.


A call to the Events method will return XML data ordered by date, with the most current event first. If an id argument is given then only data for that one event will be returned. Otherwise all event data will be returned up to a maximum of limit stories.

Note: You can access data for more than the 100 maximum by making further calls and using the offset argument. However, the API can only access the next 250 upcoming events for any query.

Use t or l to limit the results by topic or location respectiviely. Check the url of a topic or location page from the Index to work out the integer for a topic or location. Note: Your API key may already restrict access to certain topics or locations by default.




Example 1

A call to a specific event id.

http://www.infonews.co.nz/api/events.cfm?key=XXXXXXXX&id=3667

Will return the following xml:

<infonews><event><id>3667</id><title>Nordic Walking Free Trial - Auckland Botanical Gardens</title><date>13/02/2011</date><website></website><venue>Auckland Botanical Gardens</venue><link>http://www.infonews.co.nz/event.cfm?id=3667</link><topic>Sport</topic><location>Auckland</location><author>Kay Livingstone</author><description><![CDATA[ <p>FREE TRIAL<br /><br />This is a great opportunity to try this unique sport, bring a friend and try our free trial with our INWA Coach. Try this taster session and find out why Nordic Walking is one of the most popular fitness programs in Europe, it&#39;s easy and it&#39;s fun. Please bring water bottle, wear a hat and suitable shoes.<br /><br />Location: Botanical Gardens, Manurewa, Auckland<br /><br />Date: Sunday 9.00 am - 10.00 am 13 February 2011<br /><br />&nbsp;</p> ]]></description><photo> <img>capture12.jpg</img> <caption>Nordic Walking</caption> <credit>Kay Livingstone</credit></photo></event></infonews> View the event as it appears on infonews.co.nz here.





Example 2

A call to get cricket events.

http://www.infonews.co.nz/api/events.cfm?key=XXXXXXXX&t=9