Skip to content

Latest commit

 

History

History
335 lines (236 loc) · 22.6 KB

README.md

File metadata and controls

335 lines (236 loc) · 22.6 KB

Passages

(passages)

Overview

Available Operations

getHtml

Returns Bible passage text with HTML formatting

Esv.org API Docs for /v3/passages/html https://api.esv.org/docs/passage-html/

Example Usage

import { Esv } from "esv-sdk";

const esv = new Esv({
  apiKey: process.env["ESV_API_KEY"] ?? "",
});

async function run() {
  const result = await esv.passages.getHtml({
    query: "John 1:1",
  });

  // Handle the result
  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { EsvCore } from "esv-sdk/core.js";
import { passagesGetHtml } from "esv-sdk/funcs/passagesGetHtml.js";

// Use `EsvCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const esv = new EsvCore({
  apiKey: process.env["ESV_API_KEY"] ?? "",
});

async function run() {
  const res = await passagesGetHtml(esv, {
    query: "John 1:1",
  });

  if (!res.ok) {
    throw res.error;
  }

  const { value: result } = res;

  // Handle the result
  console.log(result);
}

run();

Parameters

Parameter Type Required Description
request operations.GetPassageHtmlRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.

Response

Promise<components.PassageResponse>

Errors

Error Type Status Code Content Type
errors.ErrorT 400, 401 application/json
errors.APIError 4XX, 5XX */*

search

Returns search results for Bible passages based on the provided query

Esv.org API Docs for /v3/passage/search https://api.esv.org/docs/passage-search/

Example Usage

import { Esv } from "esv-sdk";

const esv = new Esv({
  apiKey: process.env["ESV_API_KEY"] ?? "",
});

async function run() {
  const result = await esv.passages.search({
    query: "<value>",
  });

  for await (const page of result) {
    // Handle the page
    console.log(page);
  }
}

run();

Standalone function

The standalone function version of this method:

import { EsvCore } from "esv-sdk/core.js";
import { passagesSearch } from "esv-sdk/funcs/passagesSearch.js";

// Use `EsvCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const esv = new EsvCore({
  apiKey: process.env["ESV_API_KEY"] ?? "",
});

async function run() {
  const res = await passagesSearch(esv, {
    query: "<value>",
  });

  if (!res.ok) {
    throw res.error;
  }

  const { value: result } = res;

  for await (const page of result) {
    // Handle the page
    console.log(page);
  }
}

run();

Parameters

Parameter Type Required Description
request operations.SearchPassagesRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.

Response

Promise<operations.SearchPassagesResponse>

Errors

Error Type Status Code Content Type
errors.ErrorT 400, 401 application/json
errors.APIError 4XX, 5XX */*

getAudio

Returns audio file for Bible passages based on the provided query

Esv.org API Docs for /v3/passage/audio https://api.esv.org/docs/passage-audio/

Example Usage

import { Esv } from "esv-sdk";

const esv = new Esv({
  apiKey: process.env["ESV_API_KEY"] ?? "",
});

async function run() {
  const result = await esv.passages.getAudio({
    query: "John 1:1",
  });

  // Handle the result
  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { EsvCore } from "esv-sdk/core.js";
import { passagesGetAudio } from "esv-sdk/funcs/passagesGetAudio.js";

// Use `EsvCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const esv = new EsvCore({
  apiKey: process.env["ESV_API_KEY"] ?? "",
});

async function run() {
  const res = await passagesGetAudio(esv, {
    query: "John 1:1",
  });

  if (!res.ok) {
    throw res.error;
  }

  const { value: result } = res;

  // Handle the result
  console.log(result);
}

run();

Parameters

Parameter Type Required Description
request operations.GetPassageAudioRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.

Response

Promise<ReadableStream>

Errors

Error Type Status Code Content Type
errors.ErrorT 400, 401 application/json
errors.APIError 4XX, 5XX */*

getText

Returns Bible passage text based on the provided query parameters

Esv.org API Docs for /v3/passages/text https://api.esv.org/docs/passage-text/

Example Usage

import { Esv } from "esv-sdk";

const esv = new Esv({
  apiKey: process.env["ESV_API_KEY"] ?? "",
});

async function run() {
  const result = await esv.passages.getText({
    query: "John 1:1",
  });

  // Handle the result
  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { EsvCore } from "esv-sdk/core.js";
import { passagesGetText } from "esv-sdk/funcs/passagesGetText.js";

// Use `EsvCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const esv = new EsvCore({
  apiKey: process.env["ESV_API_KEY"] ?? "",
});

async function run() {
  const res = await passagesGetText(esv, {
    query: "John 1:1",
  });

  if (!res.ok) {
    throw res.error;
  }

  const { value: result } = res;

  // Handle the result
  console.log(result);
}

run();

Parameters

Parameter Type Required Description
request operations.GetPassageTextRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.

Response

Promise<components.PassageResponse>

Errors

Error Type Status Code Content Type
errors.ErrorT 400, 401 application/json
errors.APIError 4XX, 5XX */*