NET Bible Web Service (API)

If you want to use the NET Bible text in your web application, service, etc
Note: this API is still in development.

The base URL for all GET requests is: http://labs.bible.org/api/xml/verse.php?passage=
What comes after the = can be in many different forms:

  • John 3:16 - Single verse
  • John 3:16-17 - Range of verses
  • John 3:16-17;John 1:1 - Multiple single verses and/or ranges, all seperated by semi-colons

Formatting Options
use the GET param formatting= to specfy the type of formatting you would like your text to have (example http://labs.bible.org/api/xml/verse.php?passage=Lk%202:1;%204:4&formatti...)

  • formatting=full - this has all paragraph, bold, italics, and note tags
  • formatting=para - this returns text with just paragraph and bold tags
  • formatting=plain this returns just text, not html or html entities.
  • Not setting the formatting var will result in the text being returned with just bold tags

This call will return an xml document. An example can be seen by click the above link.


Language Specific Examples

PHP 5


<?
$versesRefrences = 'John 1:1-2; John 3:16; Matthew 28:18-20';

$quoted_verses = '';    // holder for our verse text.
$filename = "http://labs.bible.org/api/xml/verse.php?passage=".str_replace(" ""+"$versesRefrences); // It's good practice to replace spaces with +


try // in case we have an error, we'll catch it and handle it
{
    $content = @file_get_contents($filename); // get the xml doc

    $xml = new SimpleXMLElement($content);    // create an xml object from our xml document


    for($i=0$i<count($xml->item); $i++)     //loop through all verses

    {
        $quoted_verses .= " <b>".$xml->item[$i]->verse."</b> ";  // this is the verse number

        $quoted_verses .= $xml->item[$i]->text;                  // this is the verse text
        $quoted_verses = str_replace("</p>"''$quoted_verses);// we need to get rid or paragraphs, unless your application needs them.

        $quoted_verses = preg_replace("/<p class=\"(.*?)\">/"""$quoted_verses);
    }

    $quoted_verses .= " <a href=\"http://net.bible.org/?".$versesRefrences."\" target=\"_blank\"><b>Context (NET)</b></a> "// append a this link back to us - this is not optional

}
catch (Exception $e)  // catch errors
{
    // Do something with the error message: $e->getMessage();

}

?>