Express Rest API for getting verses and such from YouVersion.
Note I use
pnpm
in these examples.NPM
will also work if you don't have or want to installpnpm
First step is of course installing the modules
pnpm i
To build I think you can just use the tsc
command.
tsc
If you cannot use tsc
try
npx tsc
And to run use
pnpm run start
Query | Default | Required | Example |
---|---|---|---|
book | None | true | John or JHN |
chapter | 1 | false | 7 or 10 |
verses | 1 | false | 1-3 or 7-10 |
version | NIV | false | KJV or NLT |
Gets John 1:1 NIV
https://serverAddress.com/api/v1/verse?book=John
Gets John 3:16 NLT
https://serverAddress.com/api/v1/verse?book=John&chapter=3&verses=16&version=NLT
Requests return a JSON object and a status code.
A good API call responds with a 200 OK
and the requested verse(s).
{
"citation": "John 3:16 NLT",
"passage": "For God so loved the world, that he gave his only begotten Son, that whosoever believeth in him should not perish, but have everlasting life."
}
Checking the API status is pretty simple, just make a request to the following route and if everything is fine it'll respond with a 200 OK
and no JSON object.
https://serverAddress.com/api/v1/status
If no book is specified in the query, it will prompt a 400 Bad Response
and an error message
{
"code": 400,
"message": "Missing field 'book'"
}
Trying to access a book that does not exist will prompt a similar 400 Bad Response
but with a different error message
{
"code": 400,
"message": "Could not find book 'Coffee' by name or alias."
}