Umlaut full API
WARNING: This is Outdated Documentation!!!!
THIS IS OUTDATED DOCUMENTATION See new Umlaut documentation at http://github.com/team-umlaut/umlaut/wiki
Accessing the API
The api can be accessed at the resolve/api action. For instance, if your umlaut is at umlaut.somewhere.edu/, http://umlaut.somewhere.edu/resolve/api?
Append an OpenURL context object to that URL. POST is also supported, including XML formatted context objects. You can also include the usual umlaut directive parameters.
This is exactly what you'd send to the ordinary Umlaut link resolver base url for link resolver service in html; you are just replacing /resolve? with /resolve/api?
By default, the API returns XML. To return json instead, include:
Umlaut's internal request id. API clients usually don't need this, but can be useful if you want a unique identifier for this OpenURL request. May also be useful if you want to call other Umlaut actions on this same OpenURL request, ensuring that Umlaut matches to the same request, by including ¨aut.request_id in your request.
Contains an OpenURL context object in XML serialization. May include enhanced citation metadata from Umlaut.
When accessing Umlaut over an API, it's important to realize that the initial response from Umlaut may not include all Umlaut information. Umlaut continues to run services in the background that can generate responses and enhance metadata. <complete> will contain 'true' or 'false' depending on whether background services are still executing. Further elements in the response provide information on what is still executing, and how to retrieve further information.
<in_progress> <refresh_url>http://findit.library.jhu.edu/resolve/api?umlaut.request_id=701544&.....</refresh_url> <refresh_url_path>/resolve/api?umlaut.request_id=701544&.....</refresh_url_path> <requested_wait_seconds>4</requested_wait_seconds> <services_in_progress> <service name="fulltext" /> <service name="holding" /> <service name="table_of_contents" /> <service name="highlighted_link" /> <service name="audio" /> <service name="holding_search" /> </services_in_progress> </in_progress>
This block will only be present when <complete> is 'false'.
<refresh_url> provides a url the client can request again to see further results. If the client user agent does not support cookies, then this refresh_url must be used to continue retrieving results from the same Umlaut request, instead of accidentally creating a new request. Even if your client does support cookies, using the <refresh_url> is safest--simply refreshing the URL you loaded initially may accidentally create a new request. (The refresh_url given includes an umlaut.request_id parameter to ensure connection to the proper request). note well: The URL, like any other data in XML, is XML-escaped, and needs to be un-escaped before using.
<requested_wait_seconds> is a request from Umlaut for the client to wait this many seconds before asking for more results. Umlaut has no way to enforce this, it's only a request. Please wait a reasonable amount of time to avoid overloading Umlaut however.
<services_in_progress> lists the ServiceTypeValues that may still have responses coming, that may not be complete. A list of all possible ServiceTypeValues in a default Umlaut installation can be found in the [Umlaut code].
This block provides information on the internal service plug-ins involved in this Umlaut request, and what their status is. In most cases, an API client will not need this information.
<status> can be one of:
- in_progress : Currently executing
- queued : Background service which is queued up, but not yet running.
- succesful : completed succesfully (may or may not have generated any responses)
- failed_fatal: A fatal error condition was encountered, for instance a bug in Umlaut code.
- failed_temporary: An error condition was encountered, but Umlaut may try to run the service again, the error was not fatal, for instance an external service timed out.
These constants are defined in dispatched_service.rb
If the <status> is failed_fatal or failed_temporary, there may be error information in an <exception_info> block.
The meat, the actual response or 'target' data generated by Umlaut. These responses are grouped by ServiceTypeValues. A given ServiceTypeValue identifies a certain type of service, like full text, or library holdings. The list of possible ServiceTypeValues in a default Umlaut installation can be found in the relevant Umlaut distribution data file service_type_values.yml
The <responses> block contains 0 or more <type_group> blocks. Each type_group has a name attribute identifiying the ServiceTypeValue, also provides you with user-displayable label for this type, and tells you if all services that generate this type are complete or not. A type_group will only be present if it contains responses.
<type_group name="abstract"> <display_name>Abstract</display_name> <display_name_plural>Abstracts</display_name_plural> <complete>true</complete> [...] </type>
Each type_group will have one or more <response> blocks in it. A <response> represents an individual piece of data generated by umlaut. This is what most clients will be most interested in, but it's tricky to deal with because the contents of a <response> are quite variable. They can vary between responses for different ServiceTypeValues, and there can even be specialized data only in responses belong to a particular Service plug-in. All the data that Umlaut has is included here, including some really intended for internal use only.
However, don't despair, there are a few things you can count on. The <display_text> element will always include the label or heading that is to be used for the response. A <notes> element may be present with additional explanatory text. These alone, plus a linking url, will be enough for many clients.
Standard internal metadata includes a <service> element which will contain the name of the service plug-in that generated this response. (Match to services listed in <service_statuses> above).
Linking url: <umlaut_passthrough_url>
You may see the <url> element in the response and be tempted to use it to send the user to this response. You are strongly cautioned not to do so. In the Umlaut architecture, urls can be generated on-demand when the user clicks on an element, not at time of original response (this is because even generating the url is sometimes an expensive operation). This means that the <url> element is not guaranteed to be there, and when it is there is not guaranteed to be accurate. On top of all that, the application of a proxy pass through won't be applied yet to the url found here.
You should instead use the <umlaut_passthrough_url> element. This will contain a URL pointing to your umlaut installation, of the form: http://umlaut.university.edu/link_router/index/7447333
When this URL is accessed, Umlaut will redirect the user to the actual destination--after calculating that destination, and applying any proxy or other filters, etc. In some cases it may end up redirecting to the same destination as <url>, but in other cases it may be somewhat different, or may work even if <url> was not present.
Please use the umlaut_passthrough_url for linking.
Each ServiceTypeValue has other conventions for elements that will be present in that ServiceTypeValue. These are documented in ServiceResponse in the Conventional Keys section.
<response id="7447899"> <service>JH_SFX</service> <!-- Attributes really vary depending on particular service, this makes it kind of tricky to deal with in an API. See documentation in ServiceResponse for conventions. Reccommend that you use umlaut_passthrough_url for url. Final destination url isis calculated on-demand by umlaut. --> <display_text>Free E- Journals</display_text> <url>http://dl.lib.brown.edu/radicalamerica/shelf.html</url> <notes></notes> <coverage> Available from 1967 volume: 1 issue: 2 until 1987 volume: 21 issue: 6. </coverage> <sfx_target_name>MISCELLANEOUS_FREE_EJOURNALS</sfx_target_name> <sfx_base_url>http://sfx.library.jhu.edu:8000/sfxlcl3</sfx_base_url> <sfx_obj_index>1</sfx_obj_index> <sfx_target_index>1</sfx_target_index> <source>SFX/FT::NO_FILL_IN</source> <sfx_request_id>2688845</sfx_request_id> <sfx_target_service_id> 110976638852341 </sfx_target_service_id> <umlaut_passthrough_url>http://findit.library.jhu.edu/link_router/index/7447899</umlaut_passthrough_url> </response>