BibleReader includes Search on iOS and Android. Use useSearch from @youversion/platform-react-native-expo-core when you build your own results.
BibleReader
Search opens from the reader toolbar.
showToolbar={false} hides Search with the rest of the toolbar.
A verse result opens that chapter and focuses the verse. On initial load, the other verses are dimmed. A chapter result opens the chapter.
useSearch
Code
Each method returns { ok: true, value } or { ok: false, error }. An HTTP failure does not throw. These calls go to the Platform API. They do not read or write the on-device Bible content cache.
| Method | Parameters | Value |
|---|---|---|
suggestedQueries | query, languageRanges | { queries }. A query includes text. |
trendingQueries | languageRanges | { queries }. A query includes text. |
verses | query, bibleId, and optional userIntent, pageSize, pageToken | verses, userIntent, didYouMean, searchInsteadFor, and nextPageToken. Each verse id is a passage id such as JHN.3.16. |
topics | query, languageRanges | Topics with id (a number, or null), text, and subtopics. |
languageRanges is a nonempty array of BCP 47 language tags, such as ["en"] or ["en-US", "en"]. Do not pass a bare *. The Search API rejects an unsupported language range set that includes only *. bibleId is the Bible version id.
For verses and topics, query must be 1–100 characters. Optional pageSize on verses must be 1–99. When the response includes nextPageToken, pass that value back as pageToken on the next verses call, and keep the same query, bibleId, userIntent, and pageSize.
SEARCH_USER_INTENT is { reference, text, topical, unknown }. userIntent is a string. The SDK keeps a value it does not recognize.
A 204 from suggestedQueries or trendingQueries is success with { queries: [] }.
Errors. error.kind is one of these.
kind | When |
|---|---|
auth | HTTP 401 or 403. status is set. |
invalid-parameter | The request input failed client validation before the SDK fetches (empty or overlong query, invalid bibleId, invalid pageSize, or invalid languageRanges). |
transient | Any other failure, including a malformed response body. status is set when the server returned one. |
Parse a passage id
A verse result id is a passage id. An example is JHN.3.16.
Call biblePassageAnchorFromPassageId(passageId, versionId) to turn that id into { versionId, bookId, chapter, verse? }.
The function returns null when the string is not a chapter, a single verse, or a verse range.
A range returns only the start verse. JHN.3.16-17 returns verse 16.
Pass the original passage id as passageId on focusReference when the reader should keep the full range.
Accepted shapes are PSA.23, JHN.3.16, and JHN.3.16-17. The book id is three characters from A-Z and 0-9.