sermonindex
A small Python client for the SermonIndex.net API: sermons, speakers, topics and scripture, over 70,000 sermons that are free to listen to. It uses only the standard library and needs Python 3.9 or later.
The API is a set of pre-generated static files. This library only ever makes GET requests, and never adds a query string.
Install
pip install sermonindex
Examples
Sermons on a verse (the file for a famous verse such as John 3:16 is several megabytes, so ask for a smaller one when you can):
from sermonindex import SermonIndex
si = SermonIndex()
verse = si.scripture("Romans", 8, 28) # names, abbreviations and codes all work
print(verse["reference"], verse["sermonCount"])
for s in verse["sermons"][:5]:
print(s["title"], "-", s["speaker"])
A small summary of what is preached on a whole chapter, light enough for a hover card:
cards = si.cards("John", 3) # short keys: v, b, n, c, k, u, w, h, s, t, e, m
Walk a preacher's sermons, one page of fifty at a time:
for sermon in si.speaker_sermons("zac-poonen"):
print(sermon["title"])
if "Prayer" in sermon["title"]:
break # no further pages are fetched
Play audio, with a fallback:
import urllib.request
sermon = si.sermon("OTh0VCDnIG3i6wOj")
for url in si.audio_sources(sermon): # the archive.org copy, then the CDN copy; empty if hasAudio is false
try:
urllib.request.urlretrieve(url, "sermon.mp3")
break
except OSError:
continue
One random sermon that is certain to have audio:
r = si.random()
print(r["title"], r["speaker"], r["mp3Url"])
Speakers and topics:
speakers = si.speakers()["speakers"] # about 1.8 MB
prayer = si.topic("prayer") # several megabytes for the large topics
stats = si.stats()
Search the whole library by title, speaker and topic:
for hit in si.search("revival", speaker="ravenhill", limit=10):
print(hit["title"], hit["url"], hit["hasAudio"])
Things that surprise people
- There are no query parameters. A CDN cannot read them, so every page size is a set of real files. Pages hold 500 sermons for the whole library and 50 for a speaker.
- Follow
next.sermons()andspeaker_sermons()do this for you. A guessed page path is a bare 404. - Only speakers with more than 50 sermons have pages. For the others
speaker_sermons()falls back to the full record, which for them is small. The full record of a large speaker can be 8 MB, which is why pages are preferred. - Audio is Archive first, CDN second.
mp3Urlpoints at the Archive.org mirror when there is one;cdnMp3Urlis our own copy.audio_sources()returns them in that order. - Check
hasAudio. Text-only sermons carry empty strings in every media field. - The book codes are OSIS-style, with
SNGfor Song of Songs andNAMfor Nahum.scripture()andcards()accept names such as "Song of Songs", abbreviations such as "SOS" or "Nah", and the codes themselves. - A 404 comes back with an HTML page labelled as JSON. The library checks the status first and raises
NotFoundError. - Some speaker slugs contain accents or
&. Pass the slug as the API gives it; the library percent-encodes it, and if the file is stored under the other Unicode form (composed or decomposed) it tries that too. topics()is about 38 MB, and some chapter and verse files are very large. Prefertopic(slug),sermons()andcards().
Search
search(query, speaker=None, limit=20) reads a compact file, /v2/search-index.json, once per client and matches in memory. All words must match somewhere in the title, the speaker name or the topic names; a title match ranks above the others. The file is about 3 MB to download and is fetched only when you first search. If it cannot be found, search() raises SearchUnavailableError; everything else works without it. You can point at another copy with SermonIndex(search_index_url=...).
Options
SermonIndex(
base_url="https://api.sermonindex.net/v2",
timeout=30.0, # seconds per request
user_agent="my-app/1.0",
)
A network error is retried once. Errors are SermonIndexError, with NotFoundError and SearchUnavailableError as subclasses. The package carries type hints. Records are returned as plain dictionaries with the API's own field names.
Tests
python3 -m unittest
The live tests make light read-only requests to the real API; a few pull a file of one to two megabytes.
Terms
The sermons are free for personal and ministry use, and not for commercial sale; see the copying permissions. The code is MIT licensed.
Metadata
Release files for sermonindex 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| sermonindex-0.1.0.tar.gz | 15.4 kB | Without provenance | Details for sermonindex-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| sermonindex-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for sermonindex-0.1.0-py3-none-any.whl |
Total release size: 26.9 kB
Release files / sermonindex-0.1.0.tar.gz
| Download URL | sermonindex-0.1.0.tar.gz |
|---|---|
| Size | 15.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
338067abf1914f02935468021aa7fe1b2c084cb8bd4382036eb3352ecea17a34
|
|
BLAKE2b-256 checksum How to use checksums |
6e53d4223c7a45d482034880ff88db970e6bc0f3a6cad75e26caf618717ef582
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.15.2
|
Release files / sermonindex-0.1.0-py3-none-any.whl
| Download URL | sermonindex-0.1.0-py3-none-any.whl |
|---|---|
| Size | 11.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
10455b35569344e16c3ce8f57a2fb44a44167886eee1000d7f15a18a572ad65b
|
|
BLAKE2b-256 checksum How to use checksums |
2e1bfd5c2e04660343fb140711ca70a29447bd56583efc878c8407660c9d19df
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.15.2
|
Security for sermonindex 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.