As I only made a soft-release of the url on last Friday evening, and nobody seems to be using the daily service yet I thought I'd make a last minute change after I read 10 common mistakes made by API providers (especially #4, #comments: I agree #10 should be the top one too, but this is not a REST service, but at least I know why)
The node (or endpoint?) for the JobsGoLocal API is now using the api. subdomain so:
The samples and examples have been updated to show this change.
I will leave the old node in place for a week or so to see if anyone had bookmarked it.
www.jobsgolocal.org.uk remains the public site, with introductory documentation, map of offices etc and the blog at jobsgolocal.posterous.com contains API documentation, other supporting documentation and announcements such as this.
If you are planning using the API, then I'd encourage you to subscribe to this blogs' RSS feed so I keep you up to date with changes such as:
The JobsGoLocal API is very simple.
You tell it which offices you would like to see the latest vacancies for, and how you would like the results formatted.
THE NODE
http://api.JobsGoLocal.org.uk/
equivalent to:
http://api.JobsGoLocal.org.uk/index.htm
THE CALL
It accepts a number of GET arguments, only the first one, offices is mandatory.
offices=
Up to 10 pipe ( | ) delineated three letter "Jobcentre Plus" office codes. The codes can be collected up from the map.
format=
[optional] One of either json [default], php, xml or yaml.
callback=
[optional] The Javascript function to be called when it arrives back at the client. When set the payload will be the same as json, but contained within a callback so it will become jsonp.
url=
[optional] Let me know which site you using url=yoursite.com or use url=testing if you are playing around and will be hitting the site more than once per day and I will cut you some slack.
See documentation for each format option to see example calls, code samples, error codes and headers information.
Sample GET call for 2 offices, Guildford [GUF] and Woking [WOA] - returns json by default.
http://api.JobsGoLocal.org.uk/?offices=GUF|WOA
Sample GET call for 1 office, Guildford [GUF] - returning xml;
http://api.JobsGoLocal.org.uk/?offices=GUF&format=xml
FREQUENCY
The data is only updated once a day, at midnight (GMT) from the zois ftp service, so make your call to the API in wee the small hours. Leave it till after 1am and then you don't need worry about daylight saving time changes on any of the servers involved.
You are best leaving out calls on Sunday and Monday morning as there are very few jobs added on the preceding days.
CACHING
As the data is only updated once a day you are strongly advised, like really, I insist, to cache the results on your own servers and do any post-production assembly, filtering or formatting there. I will give you a bit of leeway about testing, just append &url=testing to your call.
HOW TO PROGRAMME A CALL TO THE API
This is going to depend very much on your programming language and/or the o/s of your server.
For those with *nix servers you can just add the single line to your crontab file:
15 2 * * 1-5 WGET -q -O /var/cache/ourjobvacancies.json http://api.JobsGoLocal.org.uk/?offices=WOA|GUF
The url shown is the shorthand equivalent of:
http://api.JobsGoLocal.co.uk/index.htm?offices=WOA|GUF&format=json
json is served by default and index.htm is the default doc.
The WGET example tells the server : On Mondays to Fridays [1-5] at 02:15 go and get the output from that url and put it in a folder called /var/cache and save the file as ourjobvacancies.json
If anyone knows the Win32 equivalent AT and DOS commands to go out then please post it below.
CURL
Called similarly from a crontab entry:
15 2 * * 1-5 curl -s -o /var/cache/ourjobvacancies.json http://api.JobsGoLocal.org.uk/?offices=WOA|GUF
*TODO add an example CURL call from a script
GET STARTED
Go to the map page on the main site and pick the Jobcentre Plus Offices in your locality to assemble your API call.
If you have any questions or comments then post them below, thanks!
The data is extracted from Martin Sullivan of Zois Limited's scrape of all the latest vacancies at the jobseekers.direct.gov.uk website.
Read more about his motivations for making this available from his page The Unofficial National Jobcentre Plus Mirror.
You are free to get the entire csv file of all job vacancies in the UK from his ftp site.
Martin announced the availability of this data on the Apps section of the data.gov.uk website on 12th July 2010.
So, let me spell it out again for you, this raw data stream is totally unofficial - contains no warranties for fitness of purpose whatsoever and you should bear in mind that it can be withdrawn by the data owners at any time.
The data is a csv file containing 14 columns, they are:
title,reference,location,hours,wage,work_pattern,employer,employer_ref,
pension,duration,closing_date,description,apply,added,office_code
For a fuller explanation of the contents of the original csv file then grab Martin's readme.txt.
Even a quick rummage through the raw data will expose that you will likely want to do some post-processing in order to make it palatable for the public.
It is possible to do some simple post-processing and here is a page that shows what can be achieved. This example also demonstrates how the JCP offices are dereferenced and how they can mashed up with Google static maps along with thier contact details.
www.godalming-tc.gov.uk/localjobs.htm
If you want me to prepare a similar page-stream which you can just slot into your website daily, then get in touch on twitter @paulgeraghty or email me directly using the name foofoonet and my provider is gmail.com (so you should be able to put the @ in the right place, yeah?)
With JobsGoLocal XML Webservice Option php sent the return value is a string containing XML formatted list of jobs from the offices you stipulated.
Example call:
/?offices=GUF|WOA&format=xml
This service is ideal for use either following some kind of transformation or reformatting on your server, but can also be used directly on the client perhaps with a Javascript library like jQuery.
You should only call this service once a day and cache the file locally.
Format:
Sample code (using PHP and its simpleXML class)
<?php
$xml = file_get_contents( 'yourcache.xml' );
$jobs = new SimpleXMLElement($xml);
if( $jobs->zero ){
echo $jobs->zero ;
}else{
foreach ($jobs->job as $j) {
echo $j->title. ' at ' . $j->officecode . '</p>'; // NB underscore removed in xml feeds!
echo '<p>' . $j->reference . '</p>' ;
echo '<p>' . $j->location . '</p>' ;
}
}
?>
Errors:
If you make a fundamental mistake in the call, when testing for example, you will get a simple string telling you what was wrong.
"You failed to submit any jobcentreplus office codes"
If there are no jobs at all matching the call you submitted either because the office code(s) were not found in the parent .csv file or because there were simply no jobs (which can happen on Sunday and Monday mornings) you will get an array whose first element is named "zero", and you should check for its existence in order to be able to at least degrade to a reasonable message, and carry on.
Otherwise any other error will cause this XML formatted string to appear:
Headers:
The headers accompanying the response for this format will be:
Cache-Control: no-cache, must-revalidate
Expires: Mon, 26 Jul 1997 05:00:00 GMT
Content-Type:text/xml; charset=utf=8
With JobsGoLocal JSON Webservice Option submitted the return value is a string containing a JSON formatted array of jobs from the offices you stipulated. JSON is the default return format which means it can be ommitted if you just want JSON back.
Example calls:
/?offices=GUF|WOA&format=json
Equivalent to:
/?office=GUF|WOA
This format can be used directly on the client perhaps with a Javascript library like jQuery, but can be used to do some kind of transformation or reformatting on your server.
You should only call this service once a day and cache the file locally.
Format:
{"title":"Field Sales Executive","reference":"GUF\/31253","location":"Guildford, Surrey GU1", ... etc
Sample code (using the jQuery library)
<div class='result'></div>
<script type='text/javascript'>
$.getJSON( 'cached_file.json', function(data) {
$.each(data, function( key, val ){
$('.result').append('<p>' + val.title + ' at ' + val.office_code + '</p>');
});
Errors:
If you make an elementary mistake in the call you will get a simple string telling you what was wrong.
"You failed to submit any jobcentre plus office codes"
If there are no jobs at all matching the call you submitted either because the office code(s) were not found in the parent .csv file or because there were simply no jobs (which can happen on Sunday and Monday mornings) you will get an array whose first element is named "zero", and you should check for its existence in order to be able to at least degrade to a reasonable message, and carry on.
{"zero":"Sorry, no job vacancies were found today.","offices":"No jobs were found matching the jobcentreplus offices you specified: ABC","date":"16 Aug 2010"}Any other errors will cause this JSON array to be returned:
Headers:
The headers accompanying the response for this format will be:
Cache-Control: no-cache, must-revalidate
Expires: Mon, 26 Jul 1997 05:00:00 GMT
Content-type: application/json
With JobsGoLocal JSONP Webservice Option submitted the return value is a string containing a JSON formatted array of jobs from the offices you stipulated and a callback for your Javascript to call in order to get round the same-origin policy rule.
The appearance of the callback argument in the query string and the absence of format=json, or the implicit call for format=json return the same thing.
Example calls:
JobsGoLocal.co.uk/api/?offices=GUF|WOA&format=json&callback=MyCallback
Equivalent to:
JobsGoLocal.co.uk/api/?office=GUF|WOA&callback=MyCallback
This format can be used directly on the client perhaps with a Javascript library like jQuery.
You should can call this service as often as you like within reason, but it would be better if you called it once a day and cached the file locally.
Format:
MyCallback([{"title":"Field Sales Executive","reference":"GUF\/31253","location":"Guildford, Surrey GU1", ... etc
Sample code (using the jQuery library, and showing how the callback can be kept anonymous)
<div class="result"></div>
<script type="text/javascript">Errors:
If you make a fundamental mistake in the call, for example when testing, you will get a simple string telling you what was wrong.
"You failed to submit any jobcentre plus office codes"
If there are no jobs at all matching the call you submitted either because the office code(s) were not found in the parent .csv file or because there were simply no jobs (which can happen on Sunday and Monday mornings) you will get an array whose first element is named "zero", and you should check for its existence in order to be able to at least degrade to a reasonable message, and carry on.
mycallback({"zero":"Sorry, no job vacancies were found today.","offices":"No jobs were found matching the jobcentreplus offices you specified: ABC","date":"16 Aug 2010"});Aside from messages about incorrect service calls, the error message associated with this format will be the JSON array:
Headers:
The headers accompanying the response for this format will be:
Content-Type: text/javascript; charset=utf8
Access-Control-Allow-Origin: http://www.JobsGoLocal.co.uk/
Access-Control-Max-Age: 100000
Access-Control-Allow-Methods: GET, POST, PUT, DELETE
With JobsGoLocal PHP Webservice Option php sent the return value is a string containing a PHP serialized array of jobs from the offices you stipulated. This is probably only any use to you if you have access to PHP on one of your servers.
Example call:
/?offices=GUF|WOA&format=php
You should only call this service once a day and cache the file locally.
Format:
The return value is a serialized PHP array as a string.
a:7:{i:0;a:15:{s:5:"title";s:27:"ENERGY SALES REPRESENTATIVE";s:9:"reference";s:9:"ELY/26247"; etc
You will need to run the PHP unserialize() function over the string to extract the array of jobs.
The jobs will contain associated arrays of elements which can then be looped through.
Sample code:
<?php
$jobs = file_get_contents( 'yourcache.txt' );Errors:
If you make a fundamental mistake in the call, say when testing, you will get a simple string telling you what was wrong.
"You failed to submit any jobcentreplus office codes"
If there are no jobs at all matching the call you submitted either because the office code(s) were not found in the parent .csv file or because there were simply no jobs (which can happen on Sunday and Monday mornings) you will get an array whose first element is named "zero", and you should check for its existence in order to be able to at least degrade to a reasonable message, and carry on.
Example of the serialized PHP array as a string :
a:3:{s:4:"zero";s:41:"Sorry, no job vacancies were found today.";s:7:"offices";s:72:"No jobs were found matching the jobcentreplus offices you specified: ABC";s:4:"date";s:11:"16 Aug 2010";}
Aside from messages about incorrect service calls, the error message associated with this format will be an array with one element containing the serialized PHP array as a string:
a:3{s:4:"fail"};
Headers:
The headers accompanying the response for this format will be:
Cache-Control: no-cache, must-revalidate;
Expires: Mon, 26 Jul 1997 05:00:00 GMT;
Content-Type:text/plain; charset=utf-8;
With JobsGoLocal YAML Webservice Option php sent the return value is a string containing a YAML formatted array of jobs from the offices you stipulated. Important: YAML consumption has not been tested.
Example call:
/?offices=GUF|WOA&format=yaml
I've never used YAML before so I guess it is something you use on your backend scripts and format output as you see fit. If you have any problem with the YAML file, please let me know - I am especially interested in whether the nesting setting I have (0) is correct or not.
You should only call this service once a day and cache the file locally.
Format:
[{ title: 'ENERGY SALES REPRESENTATIVE', reference: ELY/26247, location: 'Ely and surrounding areas CB7', hours: '37 HOURS OVER 5 DAYS' etcSample code
[please suggest some below and tell me what language it is written in ;) ]
Errors:
If you make a simple mistake in the call you will get a simple string telling you what was wrong.
"You failed to submit any jobcentre plus office codes"
If there are no jobs at all matching the call you submitted either because the office code(s) were not found in the parent .csv file or because there were simply no jobs (which can happen on Sunday and Monday mornings) you will get an array whose first element is named "zero", and you should check for its existence in order to be able to at least degrade to a reasonable message, and carry on.
Any other unknown error not handled above will cause this YAML formatted string:
Headers:
The headers accompanying the response for this format will be: (again, if this header causes you a problem please notify me)
Cache-Control: no-cache, must-revalidate
Expires: Mon, 26 Jul 1997 05:00:00 GMT
Content-Type:text/yaml; charset=utf=8