0.2.40 • Published 7 months ago

@flexbe/sdk v0.2.40

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

7 months ago

0.2.39

7 months ago

0.2.38

7 months ago

0.2.37

7 months ago

0.2.35

7 months ago

0.2.33

7 months ago

0.2.34

8 months ago

0.2.32

8 months ago

0.2.31

8 months ago

0.2.30

8 months ago

0.2.29

8 months ago

0.2.28

8 months ago

0.2.27

8 months ago

0.2.26

8 months ago

0.2.25

8 months ago

0.2.24

8 months ago

0.2.23

8 months ago

0.2.22

8 months ago

0.2.21

8 months ago

0.2.20

8 months ago

0.2.19

8 months ago

0.2.18

8 months ago

0.2.17

8 months ago

0.2.16

8 months ago

0.2.15

8 months ago

0.2.14

8 months ago

0.2.13

9 months ago

0.2.12

9 months ago

0.2.11

9 months ago

0.2.10

9 months ago

0.2.9

9 months ago

0.2.8

9 months ago

0.2.7

9 months ago

0.2.6

9 months ago

0.2.5

9 months ago

0.2.4

9 months ago

0.2.3

9 months ago

0.2.2

9 months ago

0.2.1

9 months ago

0.2.0

9 months ago

0.1.4

9 months ago

0.1.3

9 months ago

0.1.2

9 months ago

0.1.1

9 months ago

0.1.0

9 months ago