Z39.50

Z39.50 is an international standard client–server, application layer communications protocol for searching and retrieving information from a database over a TCP/IP computer network, developed and maintained by the Library of Congress. It is covered by ANSI/NISO standard Z39.50, and ISO standard 23950.

Z39.50 is widely used in library environments, for interlibrary catalogue search and loan, often incorporated into integrated library systems and personal bibliographic reference software, and social media such as LibraryThing.

Work on the Z39.50 protocol began in the 1970s, and led to successive versions in 1988, 1992, 1995 and 2003. The Contextual Query Language (formerly called the Common Query Language) is based on Z39.50 semantics.

Search syntax
The protocol supports search, retrieval, sort, and browse. Search queries contain attributes, typically from the bib-1 attribute set which defines six attributes to specify information searches on the server computer: use, relation, position, structure, truncation, completeness. The syntax of Z39.50 allows for very complex queries.

In practice, the functional complexity is limited by the uneven implementations by developers and commercial vendors. The syntax of Z39.50 is abstracted from the underlying database structure. For example, if the client specifies an author search using attribute 1003, the server must determine how to map that search to the indexes it contains. This allows Z39.50 queries to be formulated without knowing anything about the target database, but it also means that results for the same query can vary widely among different servers. One server may have an author index and another may use its index of personal names, whether they are authors or not. A third may have no name index and fall back on its keyword index, and yet another may have no suitable index and return an error.

An attempt to remedy the inconsistency is the Bath Profile (named after Bath, England, where the working group first met in 1999). This document rigidly specifies the search syntax to employ for common bibliographic searches, and the expected response of Bath-compliant servers. Implementation of the Bath Profile has been slow but is gradually improving the Z39.50 landscape. The Bath Profile is maintained by Library and Archives Canada.

Modernization efforts
Z39.50 is a pre-Web technology, and various working groups are attempting to update it to fit better into the modern environment. These attempts fall under the designation ZING (Z39.50 International: Next Generation), and pursue various strategies.

The successors to Z39.50 are the twin protocols SRU/SRW (Search/Retrieve via URL/Search/Retrieve Web service), which drop the Z39.50 communications protocol (replacing it with HTTP) while still attempting to preserve the benefits of the query syntax. SRU is REST-based, and enables queries to be expressed in URL query strings; SRW uses SOAP. Both expect search results to be returned as XML.

These projects have a much lower barrier to entry for developers than the original Z39.50 protocol, allowing the relatively small market for library software to benefit from the web service tools developed for much larger markets.

Alternatives include the following.
 * Open Archives Initiative Protocol for Metadata Harvesting (OAI-PMH)
 * SPARQL

Firewall information
The registered network port number for Z39.50 is 210. Although the majority of servers use this port, there are dozens of other port numbers used worldwide by Z39.50 (e.g. 2100, 2200, 2210, 2213, 3520, or in one case, ports 2101 and higher for different databases).