0.2.40 • Published 8 months ago

@flexbe/sdk v0.2.40

Weekly downloads
-
License
MIT
Repository
github
Last release
8 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

8 months ago

0.2.39

8 months ago

0.2.38

8 months ago

0.2.37

8 months ago

0.2.35

9 months ago

0.2.33

9 months ago

0.2.34

9 months ago

0.2.32

9 months ago

0.2.31

9 months ago

0.2.30

9 months ago

0.2.29

9 months ago

0.2.28

9 months ago

0.2.27

9 months ago

0.2.26

9 months ago

0.2.25

9 months ago

0.2.24

9 months ago

0.2.23

9 months ago

0.2.22

10 months ago

0.2.21

10 months ago

0.2.20

10 months ago

0.2.19

10 months ago

0.2.18

10 months ago

0.2.17

10 months ago

0.2.16

10 months ago

0.2.15

10 months ago

0.2.14

10 months ago

0.2.13

10 months ago

0.2.12

10 months ago

0.2.11

10 months ago

0.2.10

10 months ago

0.2.9

10 months ago

0.2.8

10 months ago

0.2.7

10 months ago

0.2.6

10 months ago

0.2.5

10 months ago

0.2.4

10 months ago

0.2.3

10 months ago

0.2.2

10 months ago

0.2.1

10 months ago

0.2.0

10 months ago

0.1.4

10 months ago

0.1.3

10 months ago

0.1.2

10 months ago

0.1.1

10 months ago

0.1.0

10 months ago