Skip to content

SDK

JavaScript SDK / HTTP client

Connect Cascade via fetch: send and verify OTP.

Quick Answer

Call https://cascade.kz/api with a Bearer token from JavaScript on the backend.

Summary

Ready fragments for JavaScript: set up an HTTP client, initialize Bearer, send, verify, handle errors. An official package may be missing.

Key Takeaways

  • An official package is not required — HTTP is enough.
  • Server-side calls only.
  • Check success in JSON.

Related Questions

Cascade provides a REST API. Below is a practical minimum in JavaScript with the fetch client.

Useful links: API, send, verify, examples, FAQ, pricing, documentation.

Installation

An official Cascade npm package may not exist — use standard fetch / axios on the backend (Node.js).

# optional
npm install axios

Initialization

const BASE = process.env.OTP_API_BASE_URL || 'https://cascade.kz/api';
const TOKEN = process.env.OTP_API_TOKEN;

async function cascade(path, body) {
  const res = await fetch(`${BASE}${path}`, {
    method: 'POST',
    headers: {
      Authorization: `Bearer ${TOKEN}`,
      'Content-Type': 'application/json',
      Accept: 'application/json',
    },
    body: JSON.stringify(body),
  });
  return res.json();
}

Send OTP

const send = await cascade('/otp/send', {
  phone: '77001234567',
  purpose: 'verification',
});
if (!send.success) throw new Error(send.message);

Verify

const verify = await cascade('/otp/verify', {
  phone: '77001234567',
  code: '482910',
  purpose: 'verification',
});
if (!verify.success) throw new Error(verify.message);

Errors

Check HTTP and success. Typical cases: 401, 422, 429. Do not call the API from the browser. See errors, FAQ, documentation.