REST Services

This page shows how to include data such as league tables and fixtures from the South Lacrosse site within your own web pages, or use it for any other kind of processing.

If you have any trouble using these services please email Dave Slaughter at webmaster@southlacrosse.org.uk. And thanks to Dan Scott for suggesting the idea.

Background

Data from the South Lacrosse site is made available via REST services. If you don't know what REST is, don't worry - you don't need to be familiar with it to use these services. REST is an architectural style, not a standard, and is based on standard Web technologies. This means it should be relatively simple to use, even for novice web programmers. If you want to read up on it you might want to see the Rest page at Wikipedia.

How it Works

We publish resources at specified URLs, for example the Men's tables are at www.southlacrosse.org.uk/rest/tables/mens/. This contains the data in XML format, e.g.

<?xml version="1.0" encoding="UTF-8"?>
<league-tables>
  <division>
    <division-name short="Prem">Premier Division</division-name>
    <team>
      <team-name>Hitchin</team-name>
      <won>14</won>
      <drawn>0</drawn>
      <lost>2</lost>
      <points>44</points>
      <for>216</for>
      <against>79</against>
    </team>
    <team>
      <team-name>Hillcroft</team-name>
      <won>13</won>
      <drawn>2</drawn>
      <lost>1</lost>
      <points>44</points>
      <for>180</for>
      <against>120</against>
    </team>
    ...(more teams)
  </division>
  ... (more divisions)
</league-tables>  
  

XML is used because it can be easily read by computer systems, but can also be understood by humans. All modern computer languages have routines for dealing easily with XML, e.g. PHP, Perl, Python, ASP, Java, .NET etc.

For a full list of resources available see the list of services below.

These resources can now be used by any client - the most typical is to use it to build part of a web page on a different site, using some kind of scripting language. For example, you could include the league tables within your club's website, using data from South Lacrosse. The diagram below shows how.

  1. The user requests a page from your site
  2. Your server requests the league table data from the South Lacrosse server
  3. The South Lacrosse server returns the data in XML format
  4. Your page processes the XML data, and formats a web page in your own site's style, and returns this to the user

In order to speed up access to your web page, the XML data is usually cached on your own server, and only retrieved if the local copy is over a predefined age - say 2 hours. This means most times only actions 1. and 4. occur. Additionally it makes you a good neighbour, by cutting down on the processing and bandwidth used by the South Lacrosse site.

Examples

The examples use PHP, and require the curl extension (this is usually compiled in, so if your site has PHP it is very unlikely not to have curl).

All the examples use utilities in the rest.inc file which contains code to simplify access to REST services. It has routines for fetching the data from the South Lacrosse server, and parsing the returned XML files into more useable data structures. It will also cache the XML data on your own server, and enables cacheing pages in the browser, so providing fast response times.

The complete examples are also available as a zip file.

Men's tables for all divisions Source code Syntax highlighted source Example web page
Men's table for a division Source code Syntax highlighted source Example web page
Men's fixtures (Purley) Source code Syntax highlighted source Example web page
Women's tables for all divisions Source code Syntax highlighted source Example web page
Women's table for a division Source code Syntax highlighted source Example web page
Women's fixtures (Purley) Source code Syntax highlighted source Example web page
Utilities Source code Syntax highlighted source

Services Available

If you use these services please credit where you got the data from with a link back to the South Lacrosse site, for example

Data provided by southlacrosse.org.uk

The HTML markup is as follows:

    <p><small>Data provided by <a href="http://www.southlacrosse.org.uk/">southlacrosse.org.uk</a></small></p>

Please note: URLs are case specific, so /Prem is not the same as /prem.

Service URL
Fixtures Men's complete www.southlacrosse.org.uk/rest/fixtures/mens/
for a team Use the above URL, but add your team name (see note below) at the end e.g
www.southlacrosse.org.uk/rest/fixtures/mens/Purley
Women's complete www.southlacrosse.org.uk/rest/fixtures/womens/
for a team Use the above URL, but add your team name (see note below) at the end e.g
www.southlacrosse.org.uk/rest/fixtures/womens/Purley
League Tables Men's complete www.southlacrosse.org.uk/rest/tables/mens/
for a division Use the above URL, but add Prem, East1, East2, West1, West2 or Mids at the end e.g
www.southlacrosse.org.uk/rest/tables/mens/Prem
Women's complete www.southlacrosse.org.uk/rest/tables/womens/
for a division Use the above URL, but add Prem or D1 at the end e.g
www.southlacrosse.org.uk/rest/tables/womens/Prem

Team Names

To find the team name to use in the URL go to the Men's fixtures or Women's fixtures page and select your team. The address of the page will include the team name you need to use, for example if you wanted fixtures for Bath University:

  • For the Bath University fixtures the address is http://www.southlacrosse.org.uk/fixtures.html?team=Bath+Univ.
  • The team name is after ?team=, so in this case Bath+Univ.
  • The URL you need for the fixtures will be http://www.southlacrosse.org.uk/rest/fixtures/mens/Bath+Univ.