Whenever there's data available that provides content we consider suitable for our social media and marketing platform, we jump on it. One such collection of images (and one of many made available via our platform) is a database of NSW photographs taken prior to 1955, and made available by the State Library of NSW (via a Creative Commons Attribution 3.0 Australia licence ).
The quality of data provided by the State Library is a little appalling (as opposed to the content, which is excellent) and, not unlike their other data sources, there's no consistency in the way they make open data available. Dates aren't in a defined format and there's freehand notes throughout that makes parsing the data challenging. That said, we've ported the information over to a relational database and built an API that provides access to all data. This article describes rudimentary use of the the feature.
The Result
All data requests require an API key and a data type
of either browse
or search
. When searching and browsing, a pg
and number
(of results) may also be passed as URL parameters to return the appropriate paginated result. In cases where a search is conducted, the search
parameter should also be used.
http://api.beliefmedia.com/australia/nsw1955/nsw.json?apikey=xxx&pg=255
will return a JSON file that unfolds as follows. Only minimal data is returned in browsing and search results.
To return full details for a particular image, use the following: http://api.beliefmedia.com/australia/nsw1955/{api-key}/nsw-{itemid}.json
. The JSON unfolds to a more detailed array.
Much of the URL data provided by the SLNSW is no longer valid. For that reason, the reference
data returns just the relevant ID rather than the full URL. The ID is more likely to be retained when the catalogue is rebuilt.
Searches
Searches may be made by text, topic, location, or name. Generally speaking, the data returned is virtually identical to the array returned via a browsing request. Documentation related to searches is found in our client area.
Images
In the images array there's a reference to local
. The value of yes
or no
indicates whether we've cached a copy of the image on our server. If yes, the image may be returned with the following structure: {collectionitemlink}/{year}/{itemid}-{full|thumb}.jpg
. If the local value is no
it generally means that the image reference returned a 404 error.
You may download the complete image library from our client area (11.8GB, zip file). The directory structure for images is as described above.
Errors
If there's an error, the returned JSON data will return a code of something other than 200
with a descriptive message.
Sample PHP Function
The following example function will return an array of data.
Too see the returned array, use echo print_r(beliefmedia_slnsw_nsw_photos(), true)
wrapped in pre tags.
Considerations
- We've made a simply little WordPress plugin that provides paginated results of photographs. This provides a nice little magnet for those clients where this style of information is appropriate. If you're a client (or former client) and would like it for your existing website, or a standalone website, please make contact with us.
- The database is integrated into our social platform so any of the images and captions may be curated and sent to social. We've created a
description
field that morphs some of the data into a 'starting point' for captions. - If you're not a client and would like access, please make contact with us.