Bible Web Services 101

New internet technology is making it possible to interact with God's Word in ways we've never conceived of before. This article, first in a series, introduces web services and what you can do with them for accessing Scripture.

What's a Web Service?

When you use a browser to visit a web site, the site's designer is responsible for what you see. The content is prepared and presented (in technical parlance, "served") to your browser, based on the choices of the designer. Your browser is a tool that provides the capabilities to show graphics, play audio files, and so forth: but that only happens because the site's creator intends it. Even if you can't stand tiny green text, that's what you get, if that's what the author wants you to see.

Web services are focused on data, rather than display, and you get the opportunity to have it your way. Instead of using a visually-oriented browser, a software program on your computer contacts another computer over the Internet to request information. The data is returned in a structured format: you're responsible for what you do with it. You might want to display it in your own format, or only use part of it, or connect it to other web services to do things the provider of the web service never thought of. Here's an example that connects book listings on Amazon to the my library catalog.

The key to a web service is the service provider: in the case of Scripture, the creators of the English Standard Version have provided a web service interface to their translation. There's two catches:

  1. you need software to access the web service
  2. you have to ask them for an access key (see this)

So here's a really simple Bible web service in Perl that requests the text of Matthew 5. Assuming you have Perl and know what to do with it (if not, i can recommend Active State Perl), type this into a file like

use LWP::Simple; 
my $key = "TEST";
my $passage = "2 Tim 3:16";
my $options = "action=doPassageQuery&include-verse-numbers=false";
my $output = get("$key&passage=$passage&$options");
print $output;

Since this uses a test key, you get back slightly garbled text, but it illustrates the point: here's the output, in XML (with a few line breaks added for clarity).

<div class="esv"><h2>2 Tpaothy 3:16</h2>
<div class="esv-text"><p>Acc Scripture is breathed out by God and profitable for teaching,
for reproof, for correction, and for training in righteousness,
(<a href="" class="copyright">ESV</a>)</p>

A fuller example of the format for Mark 5 is here. If this doesn't seem too exciting yet, come back for Bible Web Services 102 and you'll start to see why this is more revolutionary that it may appear.

More about ESV's web service from Christianity Today.