Servicios Web

Koha provides a number of APIs allowing access to it’s data and functions.


Para el Open Archives Initiative-Protocol for Metadata Harvesting (OAI-PMH) hay dos grupos de “participantes”: Proveedores de datos y Proveedores de servicios. Los Proveedores de datos (archivos abiertos, repositorios) proveen acceso libre a metadatos, y muchos, aunque no necesariamente, ofrecen acceso libre a textos completos y otros recursos. OAI-PMH provee una solución fácil de implementar y sencilla para Proveedores de datos. Los Proveedores de servicios utilizan la interfaz OAI de los Proveedores de datos para cosechar y almacenar metadatos. Note que esto significa que no hay pedidos de búsqueda directas a los Proveedores de datos; mas bien los servicios se basan en los datos cosechados via OAI-PMH.

Koha at present can only act as a Data Provider. It can not harvest from other repositories. The biggest stumbling block to having Koha harvest from other repositories is that MARC is the only metadata format that Koha indexes natively. Visit for diagrams of how OAI-PMH works.

By default Koha won’t include item information in OAI-PMH result sets, but they can be added by using the include_items option in the a configuration file linked from OAI-PMH:ConfFile.

Learn more about OAI-PMH at:

To enable OAI-PMH in Koha edit the OAI-PMH preference. Once enabled you can visit http://YOURKOHACATALOG/cgi-bin/koha/ to see your file.

Muestra de archivo de configuración OAI

    metadataPrefix: vs
    xsl_file: /usr/local/koha/xslt/vs.xsl
     metadataPrefix: marxml
     include_items: 1
     metadataPrefix: oai_dc
     xsl_file: /usr/local/koha/koha-tmpl/intranet-tmpl/xslt/UNIMARCslim2OAIDC.xsl

SRU server

Koha implements the Search/Retrieve via URL (SRU) protocol. More information about the protocol itself can be found at The version implemented is version 1.1.


If you want to have information about the implementation of SRU on a given server, you should have access to the Explain file using a request to the server without any parameter. Like The response from the server is an XML file that should look like the following and will give you information about the default settings of the SRU server.

                 <explain xml:base="zebradb/explain-biblios.xml">
                 try stylesheet url: http://./?stylesheet=docpath/sru2.xsl
            <serverInfo protocol="SRW/SRU/Z39.50">
                 <title lang="en" primary="true">Koha 3 Bibliographic SRU/SRW/Z39.50 server</title>
                 <description lang="en" primary="true">Koha 3 Bibliographic Server</description>
                 <set name="cql" identifier="info:srw/cql-context-set/1/cql-v1.1">
                      <title>CQL Standard Set</title>
                 <index search="true" scan="true" sort="false">
                 <title lang="en">CQL Server Choice</title>
                      <name set="cql">serverChoice</name>
               <attr type="1" set="bib1">text</attr>
      <index search="true" scan="true" sort="false">
         <title lang="en">CQL All</title>
<name set="cql">all</name>
<attr type="1" set="bib1">text</attr>
<!-- Record ID index -->
<index search="true" scan="true" sort="false">
<title lang="en">Record ID</title>
<name set="rec">id</name>
<attr type="1" set="bib1">rec:id</attr>
<attr type="4" set="bib1">3</attr>


My search for reefs&maximumRecords=1 retrieves just on record. The response looks like this:

<record xsi:schemaLocation=" standards/marcxml/schema/MARC21slim.xsd">
<leader> cam a22 4500</leader>
<datafield tag="010" ind1=" " ind2=" ">
<subfield code="a">2-603-01193-6</subfield>
<subfield code="b">rel.</subfield>
<subfield code="d">159 F</subfield>
<datafield tag="020" ind1=" " ind2=" ">
<subfield code="a">FR</subfield>
<subfield code="b">00065351</subfield>
<datafield tag="101" ind1="1" ind2=" ">
<subfield code="c">ita</subfield>
<datafield tag="105" ind1=" " ind2=" ">
<subfield code="a">a z 00|y|</subfield>
<datafield tag="106" ind1=" " ind2=" ">
<subfield code="a">r</subfield>
<datafield tag="100" ind1=" " ind2=" ">
<subfield code="a">20091130 frey50 </subfield>
<datafield tag="200" ind1="1" ind2=" ">
<subfield code="a">Guide des récifs coralliens / A Guide to Coral Reefs</subfield>
<subfield code="b">Texte imprimé</subfield>
<subfield code="e">la faune sous-marine des coraux</subfield>
<subfield code="f">A. et A. Ferrari</subfield>
<datafield tag="210" ind1=" " ind2=" ">
<subfield code="a">Lausanne</subfield>
<subfield code="a">Paris</subfield>
<subfield code="c">Delachaux et Niestlé</subfield>
<subfield code="d">cop. 2000</subfield>
<subfield code="e">impr. en Espagne</subfield>
<datafield tag="215" ind1=" " ind2=" ">
<subfield code="a">287 p.</subfield>
<subfield code="c">ill. en coul., couv. ill. en coul.</subfield>
<subfield code="d">20 cm</subfield>


As of writing, the self documenting ILS-DI is the most complete interface and after it has been enabled as described in the ILS-DI system preferences section the documentation should be available at https://YOURKOHACATALOG/cgi-bin/koha/

JSON reports services

Koha implements a JSON reports service for every report saved using the Guided Reports Wizard or Report from SQL features.

By default reports will be non-public and only accessible by authenticated users. If a report is explicitly set to public it will be accessible without authentication by anyone. This feature should only be used when the data can be shared safely not containing any patron information.

The reports can be accessed using the following URLs:

  • Public reports

    • OpacBaseURL/cgi-bin/koha/svc/report?id=REPORTID

  • Non-public reports

    • StaffBaseURL/cgi-bin/koha/svc/report?id=REPORTID

There are also some additional parameters available:

  • Instead of accessing the report by REPORTID you can also use the report’s name:

    • …/cgi-bin/koha/svc/report?name=REPORTNAME

  • For easier development there is also an option to generate an annotated output of the data. It will generate an array of hashes that include the field names as keys.

    • …/cgi-bin/koha/svc/report?name=REPORTNAME&annotated=1

Versioned RESTful API Effort

There is an ongoing effort to converge the APIs above into a single versioned set of modern RESTful endpoints documented using the OpenAPI standard and available by default under https://YOURKOHACATALOG/api/v1/

OAuth2 client credentials grant

Koha supports the OAuth2 client credentials grant as a means to secure the API for using it from other systems to adhere to current industry standards. More information on the OAuth2 client credentials grant standard can be found here.

API key management interface for patrons

In order for API keys to be create for patrons, the system preference RESTOAuth2ClientCredentials must be enabled for the option to appear in a patron record.

  1. Navigate to a patron record and select More > Manage API keys


  1. If no API keys exist for a patron there will be a message prompting to generate a client id/secret pair


  1. Enter a description for the client id/secret pair and click Save


  1. Koha will generate a client id/secret pair for use to connect to Koha from other third-party systems as an authenticated client


  2. Clicking the Revoke button next to an API credential pair will render the specific credential pair inactive until reactivated

Barcode image generator

Koha provides a barcode image generator on both the staff interface and the public interface. Both require a user to be logged in to use the service, to prevent abuse by third parties.

For example::


The URL above will generate a barcode image for the barcode «123456789», using the UPCE barcode format.

The available barcode types are: * Code39 * UPCE * UPCA * QRcode * NW7 * Matrix2of5 * ITF * Industrial2of5 * IATA2of5 * EAN8 * EAN13 * COOP2of5

If no type is specified, Code39 will be used.

By default, the barcode image will contain the text of the barcode as well. If this is not desired, the parameter «notext» may be passed to supress this behavior.

For example:


will generate a barcode image 123456789 without the text «123456789» below it.

This service can be used to embed barcode images into slips and notices printed from the browser, and to embed a patron cardnumber into the OPAC, among other possibilities.