JavaScript Client Library (CDN SDK)

Browser-first JavaScript client for the Orthodox Calendar API.

CDN usage

<script src="https://api.ispovednik.org/cdn/orthodox-calendar-api.min.js"></script>
<script type="module">
  const client = OrthodoxCalendarApi.createClient({
    baseUrl: 'https://api.ispovednik.org/api/v1',
    defaultLang: 'ru',
  });

  async function run() {
    const res = await client.calendar.day('2027-06-19');
    console.log(res.data['2027-06-19']);
  }

  run().catch(console.error);
</script>

Construction

type Lang = 'ru' | 'en' | 'cu'; // 'cu' (Church Slavonic) applies to the canons/akathists content endpoints

type ClientOptions = {
  baseUrl?: string;          // default: https://api.ispovednik.org/api/v1
  defaultLang?: Lang;        // default: 'ru'
  defaultType?: number;      // optional default saints type filter
  timeoutMs?: number;        // default: 15000
  fetchImpl?: typeof fetch;  // override for tests / SSR
  onRequest?: (ctx: { url: string; init: RequestInit }) => void;
  onResponse?: (ctx: { url: string; status: number }) => void;
  normalize?: boolean;       // default: false (see “Normalization”)
  dedupe?: boolean;          // default: true (in-flight request memoization)
  cacheTtlMs?: number;       // default: 0 (disabled)
  maxCacheEntries?: number;  // default: 200
};

client = OrthodoxCalendarApi.createClient(options);

All endpoint methods accept:

type RequestOptions = {
  lang?: Lang;
  type?: number;        // only where API supports it
  signal?: AbortSignal;
  timeoutMs?: number;
  raw?: boolean;        // bypass normalization (if enabled)
};

Endpoint coverage (v1)

Calendar day objects include weekAfterPentecost as an always-present numeric field.

Calendar and saints response saint entries include liturgicalRank. The value is either null when the rank is not confirmed, or an object with code, group, and localized label. Use this field for feast sign and order-of-service rank data; type / typeId remain legacy filtering classifications.

Content endpoints return a found/notFound envelope per id (HymnographyEnvelope / CanonsEnvelope / AkathistsEnvelope). canons/akathists take ContentRequestOptions ({ lang?, number?, signal?, timeoutMs? }); hymnography takes HymnographyRequestOptions ({ lang?, signal?, timeoutMs? }, lang is ru|en). A documented language with no data returns found: false; unknown lang values normalize to ru.

Errors

SDK throws ApiError:

Normalization

By default, SDK returns responses as-is (“raw”).

If you enable normalize: true, /saints/* responses are converted to camelCase:

You can also call helpers directly:

const raw = await client.saints.day('2026-01-01', { raw: true });
const normalized = OrthodoxCalendarApi.normalizeSaintsEnvelope(raw);

Convenience helpers

CalendarEvent.kind supports: feast, event, saint, icon_of_mother_of_god, memorial, week.

Saint.liturgicalRank is always present on calendar and saints responses, with null for unknown ranks.

CalendarEvent.icons is now typed as optional IconApiItem[] for id-backed feast / event / saint / icon_of_mother_of_god entries. This is especially relevant for /movable/*, where week and memorial stay iconless.

The SDK also exports IconApiItem, IconText, IconTextBlock, and LiturgicalRank.