As the new Copac beta test interface is now storing users’Â search history in a database we needed Copac search urls to be stateless (or RESTful.) If you look at the current Copac urls, you will notice as you navigate through a result set, just how much saved state is encoded in the url. There are references to the session ID and the number of your query within your session.
In the new scheme of things, that is all gone and I believe our search urls are now stateless â€” that is, all the information needed to display a search result is now encoded in the url. The CGI script serving the url does not have to go delving into a database to work out what to do.
I’ll attempt here to explain the new url scheme and hopefully you will see how it can be used as a machine to machine interface to Copac. I should point out though, that this is describing the beta version and things may change in the future.
So, to perform an author query against the Copac database, all you need is a url like this:
The above url will perform an author search for “sutter” and will display an HTML rendered page showing the first page of brief records. If you would like the results sorted, then you can add a “sort-order” element to the url as follows:
The above url will sort the query by the record title field. If the result set is too large to sort, then you will be redirected back to the same query without the sort-order.
If you want to view the first full record in a result set, then add an “rn” element to the url:
Similarly, to view the second page of brief records:
All the above urls return an HTML displayÂ â€” not what you want for machine to machine communication. So, to get some programmer friendly XML you can add the “format” element to the url:
The above url returns a page of MODS XML records. A page, by default, is 25 records. If you’d prefer more or less records in a page, then you can set the page size by sending a “Page-size” header with the HTTP request. And, so that you know how large the result is, a “Result-set-size” header is returned with the HTTP response when a “format” is specified in the url.
You can, of course, specify a “sort-order” along with a “format”. You’ll be able to discover the various query fields, sort and format options by delving around the user interface and performing a few queries. I’m not going to document them here and now as it is all still beta and they may change before we go live.