0.2.40 • Published 12 months ago

@flexbe/sdk v0.2.40

Weekly downloads
-
License
MIT
Repository
github
Last release
12 months ago

Flexbe TypeScript SDK

A TypeScript SDK for interacting with the Flexbe API. Works in both Node.js and browser environments.

Installation

npm install @flexbe/sdk

Usage

import { FlexbeClient } from '@flexbe/sdk';

// Initialize the client with API Key authentication
const client = new FlexbeClient({
    apiKey: 'your-api-key',
    baseUrl: 'https://api.flexbe.com', // optional
    timeout: 30000, // optional, defaults to 30 seconds
});
const siteApi = client.getSiteApi(SITE_ID);

// Using the Pages API for a specific site
try {
    // Get list of pages for site
    const pages = await siteApi.pages.getPages({
        limit: 10,
        offset: 0,
        type: 'page',
        status: 'published',
    });
    console.log(pages.pages);

    // Get a single page from site
    const page = await siteApi.pages.getPage(123);
    console.log(page);
}
catch (error) {
    console.error(error.message);
}

Features

  • TypeScript support with full type definitions
  • Multiple authentication methods:
    • API Key authentication
    • JWT Bearer token authentication with automatic token refresh (uses cookie-based authentication)
  • Automatic error handling
  • Configurable timeout and base URL
  • Native fetch API support (works in both Node.js and browser)
  • Multi-site support with site-specific API instances
  • Query parameter handling
  • Request timeout handling
  • Token sharing between browser tabs (for JWT authentication)

Environment Variables

The SDK supports the following environment variables:

  • FLEXBE_API_KEY: Your API key (required for API Key authentication)
  • FLEXBE_API_URL: Base URL (defaults to 'https://api.flexbe.com')

Development

# Install dependencies
npm install

# Build the SDK
npm run build

# Run tests
npm test

# Lint code
npm run lint

License

MIT

0.2.40

12 months ago

0.2.39

12 months ago

0.2.38

12 months ago

0.2.37

12 months ago

0.2.35

1 year ago

0.2.33

1 year ago

0.2.34

1 year ago

0.2.32

1 year ago

0.2.31

1 year ago

0.2.30

1 year ago

0.2.29

1 year ago

0.2.28

1 year ago

0.2.27

1 year ago

0.2.26

1 year ago

0.2.25

1 year ago

0.2.24

1 year ago

0.2.23

1 year ago

0.2.22

1 year ago

0.2.21

1 year ago

0.2.20

1 year ago

0.2.19

1 year ago

0.2.18

1 year ago

0.2.17

1 year ago

0.2.16

1 year ago

0.2.15

1 year ago

0.2.14

1 year ago

0.2.13

1 year ago

0.2.12

1 year ago

0.2.11

1 year ago

0.2.10

1 year ago

0.2.9

1 year ago

0.2.8

1 year ago

0.2.7

1 year ago

0.2.6

1 year ago

0.2.5

1 year ago

0.2.4

1 year ago

0.2.3

1 year ago

0.2.2

1 year ago

0.2.1

1 year ago

0.2.0

1 year ago

0.1.4

1 year ago

0.1.3

1 year ago

0.1.2

1 year ago

0.1.1

1 year ago

0.1.0

1 year ago