Published on One Big Library. (http://onebiglibrary.net)
OPA-0.2 (now with json-wrapped all-formats bundle)
By dchud
Created 2006-02-28 22:15

[Updated 2008-02-27, while (drinking late at night) at code4lib 2008, after realizing that these links don't work because unAPI v1 [1] included a change from "uri" as the parameter name to "id". So I'm changing the links to make them work!]

Attached is OPA-0.2. The big new feature is an implicit "wrap" format for all providers, which sucks down all available object formats at once and wraps them all into a JSON structure that looks like the one I described a few days ago [2].

To make it easier to try out, I've installed OPA at http://opa.onebiglibrary.net/. Pass it a URI and formats to see it in action for yourself.

For Pubmed records:

  • ?id=info:pmid/12345678 [3]
  • ?id=info:pmid/12345678&format=pubmed [4]
  • ?id=info:pmid/12345678&format=text [5]
  • ?id=info:pmid/12345678&format=asn1 [6]
  • ?id=info:pmid/12345678&format=wrap [7]

For books:

  • ?id=urn:isbn:0596002815 [8]
  • ?id=urn:isbn:0596002815&format=dc [9]
  • ?id=urn:isbn:0596002815&format=mods [10]
  • ?id=urn:isbn:0596002815&format=amazon [11]
  • ?id=urn:isbn:0596002815&format=wrap [12]

For CiteSeer articles:

  • ?id=oai:CiteSeerPSU:1234 [13]
  • ?id=oai:CiteSeerPSU:1234&format=oai_dc [14]
  • ?id=oai:CiteSeerPSU:1234&format=oai_citeseer [15]
  • ?id=oai:CiteSeerPSU:1234&format=wrap [16]

For flickr photos (notice that format=wrap will base64.encode() the data and leave the base64=True flag set; also there's a delay built into the flickr calls to ensure the API responds and doesn't get angry, so please be patient :):

  • ?id=http://flickr.com/photos/dchud/100544935/ [17]
  • ?id=http://flickr.com/photos/dchud/100544935/&format=dc [18]
  • ?id=http://flickr.com/photos/dchud/100544935/&format=mods [19]
  • ?id=http://flickr.com/photos/dchud/100544935/&format=jpeg_Original [20]
  • ?id=http://flickr.com/photos/dchud/100544935/&format=wrap [21]

If you want to see why the json-wrapping is useful, copy the text output of any of those format=wrap calls into a string in your favorite language and eval it into proper data using a json parser. It's a little nesty, but under the item and then under the item's resources ('res') you'll see all the data, right there, iterable and renderable. The whole blob could be easily up-cast into a MPEG21 DIDL or METS bundle, or you could serve images or other binary data right out of it by base64.decode()ing the data value.

AttachmentSize
opa-0.2.tar.gz [22]31.03 KB

Trackback URL for this post:

http://onebiglibrary.net/trackback/38

Source URL (retrieved on 2008-09-07 01:47): http://onebiglibrary.net/project/opa/opa-0.2-release-with-json-wrapper

Links:
[1] http://unapi.info/specs/
[2] http://onebiglibrary.net/project/mpeg21-didl-in-json-sorta
[3] http://opa.onebiglibrary.net/?id=info:pmid/12345678
[4] http://opa.onebiglibrary.net/?id=info:pmid/12345678&format=pubmed
[5] http://opa.onebiglibrary.net/?id=info:pmid/12345678&format=text
[6] http://opa.onebiglibrary.net/?id=info:pmid/12345678&format=asn1
[7] http://opa.onebiglibrary.net/?id=info:pmid/12345678&format=wrap
[8] http://opa.onebiglibrary.net/?id=urn:isbn:0596002815
[9] http://opa.onebiglibrary.net/?id=urn:isbn:0596002815&format=dc
[10] http://opa.onebiglibrary.net/?id=urn:isbn:0596002815&format=mods
[11] http://opa.onebiglibrary.net/?id=urn:isbn:0596002815&format=amazon
[12] http://opa.onebiglibrary.net/?id=urn:isbn:0596002815&format=wrap
[13] http://opa.onebiglibrary.net/?id=oai:CiteSeerPSU:1234
[14] http://opa.onebiglibrary.net/?id=oai:CiteSeerPSU:1234&format=oai_dc
[15] http://opa.onebiglibrary.net/?id=oai:CiteSeerPSU:1234&format=oai_citeseer
[16] http://opa.onebiglibrary.net/?id=oai:CiteSeerPSU:1234&format=wrap
[17] http://opa.onebiglibrary.net/?id=http://flickr.com/photos/dchud/100544935/
[18] http://opa.onebiglibrary.net/?id=http://flickr.com/photos/dchud/100544935/&format=dc
[19] http://opa.onebiglibrary.net/?id=http://flickr.com/photos/dchud/100544935/&format=mods
[20] http://opa.onebiglibrary.net/?id=http://flickr.com/photos/dchud/100544935/&format=jpeg_Original
[21] http://opa.onebiglibrary.net/?id=http://flickr.com/photos/dchud/100544935/&format=wrap
[22] http://onebiglibrary.net/files/opa-0.2.tar.gz