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';

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.

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.