Australia's Leading Digital Marketing Experts. T. 1300 235 433  |  Aggregation Enquires Welcome

State Library of Western Australia Photograph Collection API

State Library of Western Australia Photograph Collection API

The State Library of Western Australia made a collection of around 32,000 copyright-expired images and drawings created between 1818 and 1950 available on the Data.gov website. We've taken the collection and, as part of an ongoing project that'll eventuate in a single data source, we've created an API to search and browse the data. This article provides a very brief outline of the functionality that the Western Australia image API provides.

The Result

The endpoint for all requests: https://api.beliefmedia.com/australia/wa/wa.json. To return specific image details (the image itemid is returned in search and browsing results), use wa.json?id=slwa_qj20. The returned JSON data decode as follows:

1
Array
2
(
3
    [code] => 200
4
    [status] => 200
5
    [message] => OK
6
    [source] => State Library of Western Australia
7
    [data] => Array
8
        (
9
            [itemid] => slwa_qj20
10
            [title] => Miss V. Davis, first lady to finish the Swim Through Fremantle, 1927 Miss V. Davis, 1927
11
            [date] => 1927
12
            [creator] => Orloff, Izzy, 1891-1983
13
            [subject] => Davies, Tiger
14
            [description] => Written on back of photo: "Tiger" Davies, first lady to finish in Swim Through Ftle 1927, A. Orloff, Ftle. The Western Mail of 3 March 1927 publish a photograph of Miss V. Davis on p.III of the photographs and a short story on page 23. She finished 19th overall and the first lady.
15
            [image] => Array
16
                (
17
                    [nlwa] => http://www.slwa.wa.gov.au/images/women/006551t.jpg
18
                    [local] => slwa/1927/slwa_qj20.jpg
19
                )
20
 
21
            [reference] => Array
22
                (
23
                    [type] => Image
24
                    [format] => Davies, Tiger
25
                    [identifier] => http://www.slwa.wa.gov.au/images/women/006551d.jpg
26
                )
27
 
28
            [rights] => State Library of Western Australia
29
        )
30
 
31
)

searching and browsing

To search the database, use wa.json?apikey=xxx&pg=1&number=10&search=australia. The resulting JSON data will unfold as follows:

1
Array
2
(
3
    [code] => 200
4
    [status] => 200
5
    [message] => OK
6
    [source] => State Library of Western Australia
7
    [page] => 1
8
    [number] => 10
9
    [pages] => 131
10
    [total] => 1312
11
    [search] => Array
12
        (
13
            [type] => search
14
            [term] => australia
15
        )
16
 
17
    [results] => Array
18
        (
19
            [0] => Array
20
                (
21
                    [itemid] => slwa_Ev
22
                    [title] => Papers, 013971D: Sugar Loaf Mountain, Rio de Janeiro from the logbook of J.S. Roe en route to Australia in 1819 (ACC 301A)
23
                    [date] => 1797-1928
24
                    [subject] => Roe, John Septimus
25
                    [description] => Acts and statutes; Certificates 1797-1838; Circulars 1878; Constitutions; Correspondence 1813-60; Deeds 1839; Diaries 1860-62; Indentures 1813; Letters 1807-29; Logbooks 1813-29; Miscellaneous; Newspaper cuttings; Notebooks; Publications 1840; Sketchbooks 1823-27; Treatise 1813.
26
                    [image] => Array
27
                        (
28
                            [nlwa] => http://www.slwa.wa.gov.au/images/misc15/013971d.png
29
                            [local] => slwa/1797/slwa_Ev.png
30
                        )
31
 
32
                )
33
 
34
            [1] => Array
35
                (
36
                    [itemid] => slwa_j2R
37
                    [title] => Miss Nellie Peters, Western Australia, ca. Christmas 1904 Miss Nellie Peters, 1904
38
                    [date] => 1904
39
                    [subject] => Peters, Eleanor
40
                    [description] =>
41
                    [image] => Array
42
                        (
43
                            [nlwa] => http://www.slwa.wa.gov.au/images/pd009/009828PD.png
44
                            [local] => slwa/1904/slwa_j2R.png
45
                        )
46
 
47
                )
48
 
49
            [.. SNIP ..]
50
 
51
            [9] => Array
52
                (
53
                    [itemid] => slwa_Pjz
54
                    [title] => Railway exhibit at the Western Australian Exhibition of Manufacture, Arts and Products, Perth, 5 December 1906 010007PD: Railway exhibit at the Western Australian Exhibition of Manufacture, Arts and Products, Perth, 5 December 1906
55
                    [date] => 1906
56
                    [subject] =>
57
                    [description] => The Western Australian Exhibition was held in the Exhibition Building built for this event in Hay Street east and opened by the Governor Sir Frederick Bedford at 11am 5 December 1906. (See the West Australian 6 Dec. 1906, p.6-7)
58
                    [image] => Array
59
                        (
60
                            [nlwa] => http://www.slwa.wa.gov.au/images/pd010/010007PD.png
61
                            [local] => slwa/1906/slwa_Pjz.png
62
                        )
63
 
64
                )
65
 
66
        )
67
 
68
)

To browse, include an optional page and number parameters (defaulting to browse and 30 results). The returned data is not entirely dissimilar to the search data above.

Download Images

The entire (2.6GB) collection of images is available for download. All follow the format of {year}/{itemid}.{jpg|png} (as provided in the JSON data). We've made attempts to determine the highest quality image without success; we'll revisit this in the future.

Sample PHP Functions

The following sample functions are might be used. They show the minimum necessary code to retrieve results.

Show Image Details

1
<?php 
2
/*
3
 State Library of Western Australia Photograph Collection API
4
 https://www.beliefmedia.com.au/slwa-photograph-api
5
*/
6
 
7
function beliefmedia_slwa_photos_detail($id, $apikey = 'xxxxx') {
8
 
9
  $data = @file_get_contents('http://api.beliefmedia.com/australia/wa/wa.json?apikey=' . $apikey . '&id=' . $id);
10
  if ($data === false) return false;
11
 
12
  $data = json_decode($data, true);
13
  if ($data === false) return false;
14
 
15
  /* Likely return array of errors with code & message */
16
  if ($data['code'] != '200') return $data['message'];
17
 
18
 /* Do something with data */
19
 return (array) $data;
20
}

Searching and Browsing

1
<?php 
2
/*
3
 State Library of Western Australia Photograph Collection API
4
 https://www.beliefmedia.com.au/slwa-photograph-api
5
*/
6
 
7
function beliefmedia_slwa_photos($page = '', $number = '', $type = false, $search = false, $apikey = 'xxxxx') {
8
 
9
  if ($page == '') $page = '1';
10
  if ($number == '') $number = '20';
11
  if ($type === false) $type = 'browse';
12
 
13
  $type = ($type == 'browse') ? 'browse' : 'type=' . $type . '&search=' . str_replace(' ', '+', $search);
14
 
15
  $data = @file_get_contents('http://api.beliefmedia.com/australia/wa/wa.json?apikey=' . $apikey . '&pg=' . $page . '&number=' . $number . '&' . $type);
16
  if ($data === false) return false;
17
 
18
  $data = json_decode($data, true);
19
  if ($data === false) return false;
20
 
21
  /* Likely return array of errors with code & message */
22
  if ($data['code'] != '200') return $data['message'];
23
 
24
 return (array) $data;
25
}

Considerations

  • Other search functions are available (year, exact, partial, etc) but we'll refrain from details until the data is consolidated into a single source.
  • A WordPress plugin is available that will show paginated image results in your WordPress website.

Download our 650-page guide on Finance Marketing. We'll show you exactly how we generate Billions in volume for our clients.

  AUS Eastern Standard Time (Virginia)

  Want to have a chat?
 

Like this article?

Share on facebook
Share on Facebook
Share on twitter
Share on Twitter
Share on linkedin
Share on Linkdin
Share on pinterest
Share on Pinterest

Leave a comment