ESV_API

An API Wrapper for the ESV API

Installation


    gem 'esv_api'

Usage

For your rails app:


    #Create an initializer:

    ESV.configure do |config|
      config.api_key = YOUR_API_KEY
    end

    @esv_text = ESV.passage_query( params[:passage] || "John 1", { 'include-footnotes' => 'false', 'include-headings' => 'false', 'include-subheadings' => 'false', 'include-audio-link' => 'false' } )

Query Types

The following methods are available as query types:


    passage_query(passage, options={})

    query( q, options={} )

    reading_plan_query( options={} )

    query_info( q, options={} )

    reading_plan_info( options={} )

    verse( options={} )

    daily_verse( options={} )

Query Options

The gem mirrors the API. To pass in options, just use the options hash in any available method, using options of the same name as specified in the ESV API documentation.

For example:


    @esv_text = ESV.passage_query( params[:passage] || "John 1", { 'include-footnotes' => 'false', 'include-headings' => 'false', 'include-subheadings' => 'false', 'include-audio-link' => 'false' } )

Formatting HTML Output

HTML is the default output and will appear unless output-format is specified. To make full use of the text, you will probably want to link a CSS stylesheet to your page, either one you've created or GNP's CSS. This stylesheet contains close to the minimum markup needed to render the text accurately.

Caching

If you have the dalli gem installed, esv_api will cache the data returned from passage_query calls, taking options into account when setting the key.

Credits

With love to the Twitter Gem, from which I borrowed heavily.