BibleGet-I-O / endpoint

API endpoints for the BibleGet I/O project
https://query.bibleget.io
Apache License 2.0
9 stars 1 forks source link
bible bible-quote bibleget endpoint php quotes scripture verse verses

BibleGet I/O service endpoints

There are 3 API endpoints for the BibleGet I/O project, reachable at the URL https://query.bibleget.io. The first official release on Github was v2.4. Since then, the v2 endpoints (currently at v2.9) have also become reachable at the URL https://query.bibleget.io/v2/.

Starting with the v3 release, the v2 endpoints will ONLY be available at https://query.bibleget.io/v2/, the v3 endpoints will ONLY be available at https://query.bibleget.io/v3/, and NO endpoints will be available at https://query.bibleget.io . This way it will be become clear which version of the endpoint is being used. Any significant changes that would break functionality in a plugin or application will only be applied between major versions, in order to allow plugins or applications to handle the versioning and avoid breaking functionality.

Along with the information provided below, Swaggerhub documentation can be found here (kudos to @MichaelRShelton for generating the docs from the Swagger docker image).

Code quality and Endpoint validity Main branch Development branch OpenAPI validation
CodeFactor CodeFactor OpenAPI

index.php

This is the main API endpoint for all queries for biblical texts and quotes, reachable at the URL https://query.bibleget.io/.

Both GET and POST requests are supported. The endpoint is CORS enabled, which means that ajax requests can be made directly against the endpoint without getting cross-domain restriction errors. HSTS is enforced on the whole BibleGet server, both for the website and the API endpoints, so only the https protocol can be used for requests. Since the certificate used on the server is a Let's Encrypt issued certificate, it should be recognized by most platforms, this is not however the case for many Java runtimes in which the keystore often does not have a copy of the Let's Encrypt CA or Intermediate certificate (see here). In these cases, it may be necessary for the application to ensure that a copy of the Let's Encrypt CA or Intermediate certificate is installed to the keystore in order for valid requests to be made to the BibleGet API endpoint.

For the time being, authorization is not required to access the endpoint. However anyone who intends on using the endpoint is requested to use the appid parameter explained below in order to identify the source of the requests to the endpoint. And especially for web-based tools (apps, plugins), it is very important to use some kind of cache mechanism, in order to avoid unnecessary repeated requests to the API endpoint. Restrictions on the maximum amount of requests permitted daily from any given IP address or web host are enforced.

Think of this scenario: you create a web page that makes an AJAX request for a Bible quote and displays the result. But anyone on the internet can reach this web page. And in just one day, 300 people happen to open that web page for one reason or another. Every time the web page is opened, whether by actual people or by internet crawlers, the page makes an AJAX request to the BibleGet API endpoint just to display the same exact Bible verse every time. So in one day, 300 requests were made to the API endpoint from the same page for the same Bible verse. This is an irresponsible usage of the endpoint. If the web page used a form of local storage, it could store the data retrieved from the API endpoint in local storage. This way when anyone (whether an actual person or a web crawler) accesses the page, the Bible quote will be retrieved from local storage first, and if it not present in local storage it will be retrieved from the API endpoint and saved to local storage. This is not as necessary for desktop applications, where it is usually just one person using the desktop application, it would be very rare for anyone to make 100 requests in one day for the same Bible verse in a desktop application. However this danger does very well exist for web pages.

Types of data that can be returned from the API endpoint are JSON, XML, and HTML.

PARAMETERS

STRUCTURE OF THE RETURNED DATA

I will only take into consideration, for sake of simplicity, the structure of JSON data.

An example of data returned from the query https://query.bibleget.io/v3/?query=Mt1,1-5&version=NABRE:

{"results":[{"testament":2,"section":5,"book":"Matthew","chapter":1,"versedescr":null,"verse":"1","verseequiv":null,"verseorigin":null,"text":" The book of the genealogy of Jesus Christ, the son of David, the son of Abraham.","title1":"","title2":"","title3":"","version":"NABRE","bookabbrev":"Mt","booknum":46,"univbooknum":"47","originalquery":"Mt1,1-5"},{"testament":2,"section":5,"book":"Matthew","chapter":1,"versedescr":null,"verse":"2","verseequiv":null,"verseorigin":null,"text":" Abraham became the father of Isaac, Isaac the father of Jacob, Jacob the father of Judah and his brothers. ","title1":"","title2":"","title3":"","version":"NABRE","bookabbrev":"Mt","booknum":46,"univbooknum":"47","originalquery":"Mt1,1-5"},{"testament":2,"section":5,"book":"Matthew","chapter":1,"versedescr":null,"verse":"3","verseequiv":null,"verseorigin":null,"text":"Judah became the father of Perez and Zerah, whose mother was Tamar. Perez became the father of Hezron, Hezron the father of Ram, ","title1":"","title2":"","title3":"","version":"NABRE","bookabbrev":"Mt","booknum":46,"univbooknum":"47","originalquery":"Mt1,1-5"},{"testament":2,"section":5,"book":"Matthew","chapter":1,"versedescr":null,"verse":"4","verseequiv":null,"verseorigin":null,"text":" Ram the father of Amminadab. Amminadab became the father of Nahshon, Nahshon the father of Salmon, ","title1":"","title2":"","title3":"","version":"NABRE","bookabbrev":"Mt","booknum":46,"univbooknum":"47","originalquery":"Mt1,1-5"},{"testament":2,"section":5,"book":"Matthew","chapter":1,"versedescr":null,"verse":"5","verseequiv":null,"verseorigin":null,"text":" Salmon the father of Boaz, whose mother was Rahab. Boaz became the father of Obed, whose mother was Ruth. Obed became the father of Jesse, ","title1":"","title2":"","title3":"","version":"NABRE","bookabbrev":"Mt","booknum":46,"univbooknum":"47","originalquery":"Mt1,1-5"}],"errors":[],"info":{"ENDPOINT_VERSION":"3.0","detectedNotation":"EUROPEAN","bibleVersionsInfo":{"NABRE":"New American Bible - Revised Edition|2011|en|1|CATHOLIC|United States Conference of Catholic Bishops|"}}}

metadata.php

An API endpoint for querying metadata such as Bible versions that are available and their book/chapter/verse indexes, reachable at https://query.bibleget.io/metadata.php.

Both GET and POST requests are supported. The endpoint is CORS enabled, which means that ajax requests can be made directly against the endpoint without getting cross-domain restriction errors. HSTS is enforced on the whole BibleGet server, both for the website and the API endpoints, so only the https protocol can be used for requests. Since the certificate used on the server is a Let's Encrypt issued certificate, it should be recognized by most platforms, this is not however the case for many Java runtimes in which the keystore often does not have a copy of the Let's Encrypt CA or Intermediate certificate (see here). In these cases, it may be necessary for the application to ensure that a copy of the Let's Encrypt CA or Intermediate certificate is installed to the keystore in order for valid requests to be made to the BibleGet API endpoint.

PARAMETERS

STRUCTURE OF THE RETURNED DATA

I will only take into consideration, for sake of simplicity, the structure of JSON data.

  1. Keys returned when query=biblebooks are: languages, results, errors, and info.
  1. Keys returned when query=bibleversions are: validversions, validversions_fullname, copyrightversions, errors, info (if the results key is present it will be an empty array, it is not useful here). Example data returned:

    {"results":[],"errors":[],"info":{"ENDPOINT_VERSION":"3.0"},"validversions":["CEI2008","DRB","LUZZI","NABRE","NVBSE","VGCL","BLPD"],"validversions_fullname":{"CEI2008":"Conferenza Episcopale Italiana|2008|it|1|CATHOLIC|Fondazione di Religione “Santi Francesco d’Assisi e Caterina da Siena”|source: https:\/\/www.bibbiaedu.it","DRB":"Douay–Rheims Challoner Revision|1752|en|1|CATHOLIC||The Douay–Rheims is a translation of the Bible from the Latin Vulgate into English made by members of the English College, Douai, in the service of the Catholic Church. The New Testament portion was published in Reims, France, in 1582, in one volume with extensive commentary and notes. The Old Testament portion was published in two volumes twenty-seven years later in 1609 and 1610 by the University of Douai. The Whole Revised and Diligently Compared with the Latin Vulgate by Bishop Richard Challoner 1749-1752\r\nsource: http:\/\/www.gutenberg.org\/ebooks\/1581\r\nsource: http:\/\/catholicbible.online\/","LUZZI":"Riveduta - Luzzi|1924|it|0|PROTESTANT||","NABRE":"New American Bible - Revised Edition|2011|en|1|CATHOLIC|United States Conference of Catholic Bishops|","NVBSE":"Nova Vulgata - Bibliorum Sacrorum Editio|1979|la|1|CATHOLIC||source: http:\/\/www.vatican.va\/archive\/bible\/nova_vulgata\/documents\/nova-vulgata_index_lt.html","VGCL":"Vulgata Clementina|1592|la|1|CATHOLIC||There is a single, definitive Clementine text, namely the Editio Typica published by the Typographus Vaticanus in 1598 under the title \"Biblia Sacra Vulgatæ editionis, Sixti V Pontificis Maximi jussu recognita et edita\". However, the text here has necessarily been derived from later sources, principally that edited by A. Colunga and L. Turrado (La Editorial Católica, Madrid, 1946). For dubious readings, the editions of C. Vercellone (Typis S. Congregationis de Propaganda Fide, Rome, 1861) and M. Hetzenauer (Pustet & Co, 1914) were also consulted. Only the canonical books are included (many printed versions include an appendix with the apocryphal books Oratio Manassæ and Esdræ III and IV).","BLPD":"Libro del Pueblo de Dios|2015|es|1|CATHOLIC|Fundación Palabra de Vida y Editorial Verbo Divino|La Fundación Palabra de Vida se creó para la difusión de “El Libro del Pueblo de Dios. La Biblia”, una traducción que llevó a dos de sus  miembros, los Padres Alfredo Bernardo Trusso y Armando Jorge Levoratti, veintidos años de intenso trabajo. Lógicamente en un tiempo en el cual no había computadoras y las imprentas no tenían la tecnología que tienen hoy en día.\r\nEsta traducción fue aceptada inmediatamente en nuestro país y fue así que la Conferencia Episcopal Argentina la reconoció como texto oficial de la Iglesia. Y no sólo nuestro país, sino también las Conferencias Episcopales de Chile, Paraguay y Uruguay.\r\nAños más tarde del fallecimiento del Padre Trusso, el Padre Levoratti se dedicó a actualizar varias introducciones y notas de este Libro. Y a raíz de esta nueva  versión se puso en contacto con la Editorial Verbo Divino y le cedió sus derechos de la traducción. Por su parte el Padre Trusso había cedido sus derechos a la Fundación.\r\nEl P. Levoratti junto con los otros miembros de la Fundación reunidos con la Editorial Verbo Divino decidieron titularla “La Biblia. Libro del Pueblo de Dios”, para seguir la continuidad de la traducción original. El Padre Levoratti falleció hace ya unos años.\r\nLa edición “El Libro del Pueblo de Dios. La Biblia”, que nos edita la Editorial San Pablo, sigue teniendo vigencia  con las introducciones parciales a los principales capítulos, mientras que en la posterior fueron agregadas a las notas."},"copyrightversions":["CEI2008","NABRE","BLPD"]}
  1. Keys returned when query=versionindex and assuming usage of the second required parameter (for example versions=NABRE) are: indexes, info, errors (if the results key is present it will be an empty array, it is not useful here). Example data returned:

    {"indexes":{"NABRE":{"abbreviations":[...],"biblebooks":[...],"chapter_limit":[...],"verse_limit":[...],"book_num":[..]}},"results":[],"errors":[],"info":{"ENDPOINT_VERSION":"3.0"}}

N.B. Applications or plugins that wish to use the main API endpoint should CACHE the information returned by the METADATA endpoint. This data does not change often, there is no need to request it for every Bible quote. It can be a good idea to refresh this information about, let's say once a month, or create a user interface with a button that will allow the end user to refresh the information from the server if they think the cached information might be old.

search.php

An API endpoint for issuing search requests using keywords or search by topic, reachable at https://query.bibleget.io/search.php.

Both GET and POST requests are supported. The endpoint is CORS enabled, which means that ajax requests can be made directly against the endpoint without getting cross-domain restriction errors. HSTS is enforced on the whole BibleGet server, both for the website and the API endpoints, so only the https protocol can be used for requests. Since the certificate used on the server is a Let's Encrypt issued certificate, it should be recognized by most platforms, this is not however the case for many Java runtimes in which the keystore often does not have a copy of the Let's Encrypt CA or Intermediate certificate (see here). In these cases, it may be necessary for the application to ensure that a copy of the Let's Encrypt CA or Intermediate certificate is installed to the keystore in order for valid requests to be made to the BibleGet API endpoint.

PARAMETERS

STRUCTURE OF THE RETURNED DATA

The data is structured in a similar manner to the main API endpoint (index.php).