Skip to content

Instantly share code, notes, and snippets.

@BrianHicks
Created February 10, 2012 03:17
Show Gist options
  • Save BrianHicks/1786063 to your computer and use it in GitHub Desktop.
Save BrianHicks/1786063 to your computer and use it in GitHub Desktop.
Bible.org NET Bible wrapper
# Wrapper for bible.org NET Bible API
# Use must follow copyright statement at http://bible.org/netbiblecopyright
# Code released into the public domain, without warranty
http = require 'http'
get_passage = (passage, callback) ->
passage = encodeURIComponent passage
options =
host: 'labs.bible.org'
port: 80
path: "/api/?passage=" + passage + "&type=json"
buffers = []
request = http.get options, (res) ->
console.log 'fulfilling request for', options.path
res.on 'data', (chunk) ->
buffers.push chunk
res.on 'end', ->
callback JSON.parse buffers.join ''
request.on 'error', (error) ->
console.log 'problem with request:', error.message
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment