Documentation / SDKs

JavaScript SDK

Official JavaScript SDK for WebinOne API

The official WebinOne JavaScript SDK provides a convenient way to interact with the API from Node.js or browser environments.

Installation

npm install @webinone/api-client

Basic Usage

Initialize the client with your credentials:

const { WebinOneClient } = require('@webinone/api-client');

const client = new WebinOneClient({
  siteUrl: 'https://your-site.webinone.com',
  clientId: 'YOUR_CLIENT_ID',
  clientSecret: 'YOUR_CLIENT_SECRET'
});

Features

  • Automatic token management and refresh
  • Type-safe API methods
  • Built-in error handling
  • Request/response interceptors
  • Retry logic with exponential backoff
  • TypeScript support

Common Operations

List Resources

const snippets = await client.snippets.list({
  limit: 50,
  orderBy: '-Id'
});

Get Single Resource

const snippet = await client.snippets.get(123);

Create Resource

const newSnippet = await client.snippets.create({
  Name: 'Header',
  Alias: 'header',
  Content: '
...
', Enabled: true });

Update Resource

const updated = await client.snippets.update(123, {
  ...existingSnippet,
  Content: '
Updated
' });

Error Handling

try {
  const result = await client.snippets.create(data);
} catch (error) {
  if (error.code === 'RATE_LIMIT_EXCEEDED') {
    // Handle rate limit
  } else {
    console.error(error.message);
  }
}

Code Examples

// Full Example: Creating a Page
const { WebinOneClient } = require('@webinone/api-client');

const client = new WebinOneClient({
  siteUrl: 'https://your-site.webinone.com',
  clientId: process.env.CLIENT_ID,
  clientSecret: process.env.CLIENT_SECRET
});

async function createPage() {
  try {
    const page = await client.pages.create({
      ModuleId: 1522,
      Name: 'About Us',
      UrlSlug: 'about',
      Description: '

About Us

Welcome...

', Enabled: true, ReleaseDate: new Date().toISOString(), ExpiryDate: '2099-12-31T00:00:00', TemplateId: 1, LayoutId: 6 }); console.log('Page created:', page.Url); } catch (error) { console.error('Failed:', error.message); } } createPage();