Skip to content

Instantly share code, notes, and snippets.

@eykd
Created September 4, 2013 15:30
Show Gist options
  • Select an option

  • Save eykd/6438651 to your computer and use it in GitHub Desktop.

Select an option

Save eykd/6438651 to your computer and use it in GitHub Desktop.
Interacting with reading plans on the ESV v2 API (using HTTPie from the command line).
$ http --verbose --form GET http://www.esvapi.org/v2/rest/readingPlanInfo key==IP reading-plan==bcp
GET /v2/rest/readingPlanInfo?key=IP&reading-plan=bcp HTTP/1.1
Accept: */*
Accept-Encoding: gzip, deflate, compress
Content-Length: 0
Content-Type: application/x-www-form-urlencoded; charset=utf-8
Host: www.esvapi.org
User-Agent: HTTPie/0.4.1
HTTP/1.1 200 OK
Connection: keep-alive
Content-Length: 481
Content-Location: readingPlanInfo.php
Content-Type: text/xml
Date: Wed, 04 Sep 2013 15:15:10 GMT
Expires: Thu, 05 Sep 2013 15:15:10 +0000
Server: nginx/0.7.62
TCN: choice
Vary: negotiate
X-Powered-By: PHP/5.2.10-2ubuntu6.4
<crossway-bible class="reading-plan-info">
<date>20130904</date>
<plan>bcp</plan>
<id>1.319</id>
<url>http://www.gnpcb.org/esv/devotions/bcp/?date=2013-09-04</url>
<info>
<psalm-1>Ps. 38</psalm-1><psalm-2>Ps. 119:25-48</psalm-2><ot>1 Kings 9:24-10:13</ot><nt>James 3:1-12</nt><gospel>Mark 15:1-11</gospel><liturgical><season>Proper</season><week>Proper 17</week></liturgical><raw>Ps. 38; Ps. 119:25-48; 1 Kings 9:24-10:13; James 3:1-12; Mark 15:1-11</raw>
</info>
</crossway-bible>
$ http --verbose --form GET http://www.esvapi.org/v2/rest/passageQuery key==IP passage=="Ps. 119:25-48"
GET /v2/rest/passageQuery?key=IP&passage=Ps.+119%3A25-48 HTTP/1.1
Accept: */*
Accept-Encoding: gzip, deflate, compress
Content-Length: 0
Content-Type: application/x-www-form-urlencoded; charset=utf-8
Host: www.esvapi.orgUser-Agent: HTTPie/0.4.1
HTTP/1.1 200 OK
Connection: keep-alive
Content-Length: 5533Content-Location: passageQuery.php
Content-Type: text/html
Date: Wed, 04 Sep 2013 15:18:11 GMT
Expires: Thu, 05 Sep 2013 15:18:11 +0000
Server: nginx/0.7.62
TCN: choice
Vary: negotiate
X-Powered-By: PHP/5.2.10-2ubuntu6.4
<div class="esv"><h2>Psalm 119:25-48 <object type="application/x-shockwave-flash" data="http://www.esvapi.org/assets/play.swf?myUrl=hw%2F19119025-19119048" width="40" height="12" class="audio"><param name="movie" value="http://www.esvapi.org/assets/play.swf?myUrl=hw%2F19119025-19119048" /><param name="wmode" value="transparent" /></object></h2>
<div class="esv-text"><h4 class="psalm-acrostic-title" id="p19119025.01-1">Daleth</h4>
<div class="block-indent">
<p class="line-group" id="p19119025.02-1"><span class="verse-num" id="v19119025-1">25&nbsp;</span>My soul clings to the dust;<br />
<span class="indent"></span>give me life according to your word!<br />
<span class="verse-num" id="v19119026-1">26&nbsp;</span>When I told of my ways, you answered me;<br />
<span class="indent"></span>teach me your statutes!<br />
<span class="verse-num" id="v19119027-1">27&nbsp;</span>Make me understand the way of your precepts,<br />
<span class="indent"></span>and I will meditate on your wondrous works.<br />
<span class="verse-num" id="v19119028-1">28&nbsp;</span>My soul melts away for sorrow;<br />
<span class="indent"></span>strengthen me according to your word!<br />
<span class="verse-num" id="v19119029-1">29&nbsp;</span>Put false ways far from me<br />
<span class="indent"></span>and graciously teach me your law!<br />
<span class="verse-num" id="v19119030-1">30&nbsp;</span>I have chosen the way of faithfulness;<br />
<span class="indent"></span>I set your rules before me.<br />
<span class="verse-num" id="v19119031-1">31&nbsp;</span>I cling to your testimonies, O <span class="small-caps">Lord</span>;<br />
<span class="indent"></span>let me not be put to shame!<br />
<span class="verse-num" id="v19119032-1">32&nbsp;</span>I will run in the way of your commandments<br />
<span class="indent"></span>when you enlarge my heart!<span class="footnote">&nbsp;<a href="#f1" id="b1" title="Or 'for you set my heart free'">[1]</a></span></p>
</div>
<h4 class="psalm-acrostic-title" id="p19119033.01-1">He</h4>
<div class="block-indent">
<p class="line-group" id="p19119033.02-1"><span class="verse-num" id="v19119033-1">33&nbsp;</span>Teach me, O <span class="small-caps">Lord</span>, the way of your statutes;<br />
<span class="indent"></span>and I will keep it to the end.<span class="footnote">&nbsp;<a href="#f2" id="b2" title="Or 'keep it as my reward'">[2]</a></span><br />
<span class="verse-num" id="v19119034-1">34&nbsp;</span>Give me understanding, that I may keep your law<br />
<span class="indent"></span>and observe it with my whole heart.<br />
<span class="verse-num" id="v19119035-1">35&nbsp;</span>Lead me in the path of your commandments,<br />
<span class="indent"></span>for I delight in it.<br />
<span class="verse-num" id="v19119036-1">36&nbsp;</span>Incline my heart to your testimonies,<br />
<span class="indent"></span>and not to selfish gain!<br />
<span class="verse-num" id="v19119037-1">37&nbsp;</span>Turn my eyes from looking at worthless things;<br />
<span class="indent"></span>and give me life in your ways.<br />
<span class="verse-num" id="v19119038-1">38&nbsp;</span>Confirm to your servant your promise,<br />
<span class="indent"></span>that you may be feared.<br />
<span class="verse-num" id="v19119039-1">39&nbsp;</span>Turn away the reproach that I dread,<br />
<span class="indent"></span>for your rules are good.<br />
<span class="verse-num" id="v19119040-1">40&nbsp;</span>Behold, I long for your precepts;<br />
<span class="indent"></span>in your righteousness give me life!</p>
</div>
<h4 class="psalm-acrostic-title" id="p19119041.01-1">Waw</h4>
<div class="block-indent">
<p class="line-group" id="p19119041.02-1"><span class="verse-num" id="v19119041-1">41&nbsp;</span>Let your steadfast love come to me, O <span class="small-caps">Lord</span>,<br />
<span class="indent"></span>your salvation according to your promise;<br />
<span class="verse-num" id="v19119042-1">42&nbsp;</span>then shall I have an answer for him who taunts me,<br />
<span class="indent"></span>for I trust in your word.<br />
<span class="verse-num" id="v19119043-1">43&nbsp;</span>And take not the word of truth utterly out of my mouth,<br />
<span class="indent"></span>for my hope is in your rules.<br />
<span class="verse-num" id="v19119044-1">44&nbsp;</span>I will keep your law continually,<br />
<span class="indent"></span>forever and ever,<br />
<span class="verse-num" id="v19119045-1">45&nbsp;</span>and I shall walk in a wide place,<br />
<span class="indent"></span>for I have sought your precepts.<br />
<span class="verse-num" id="v19119046-1">46&nbsp;</span>I will also speak of your testimonies before kings<br />
<span class="indent"></span>and shall not be put to shame,<br />
<span class="verse-num" id="v19119047-1">47&nbsp;</span>for I find my delight in your commandments,<br />
<span class="indent"></span>which I love.<br />
<span class="verse-num" id="v19119048-1">48&nbsp;</span>I will lift up my hands toward your commandments, which I love,<br />
<span class="indent"></span>and I will meditate on your statutes. (<a href="http://www.esv.org" class="copyright">ESV</a>)</p>
</div>
</div>
<div class="footnotes">
<h3>Footnotes</h3>
<p><span class="footnote"><a href="#b1" id="f1">[1]</a></span> <span class="footnote-ref">119:32</span> Or <em>for you set my heart free</em>
<br />
<span class="footnote"><a href="#b2" id="f2">[2]</a></span> <span class="footnote-ref">119:33</span> Or <em>keep it as my reward</em>
</p>
</div>
</div>
Reading plan metadata: http://www.esvapi.org/api#readingPlanInfo
Passage queries: http://www.esvapi.org/api (at the top)
Basically, just do the `readingPlanInfo` request, parse the XML, and make one request for the text node of each of `//info/psalm-1|//info/psalm-2|//info/ot|//info/nt|//info/gospel`. It's *that* simple!
OK, so that may be more complicated than it needs to be. :) The alternative of course is to make one request to `readingPlanQuery` (http://www.esvapi.org/api#readingPlanQuery) which gives you all the passages at once.
@pelicanben
Copy link
Copy Markdown

So does this mean that you still have to manually enter in the passages into the passage query?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment