0.0.31 • Published 12 months ago

bubbleio-sdk v0.0.31

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

bubble-sdk

A TypeScript wrapper around the Bubble Data API.

Usage

First, you will need to provide your app and apiKey from Bubble.

Make sure to follow Bubble's documentation for "Activating the API" and "Setting up the GET/DATA API".

import BubbleSDK from "bubble-sdk";

BubbleSDK.init({
  app: "your-app-name",
  apiKey: "your-bubble-api-key",
});

Define your types

Then you can create a class for each Data type in Bubble. You must define the type. This type is the name of the type as it appears in the URL when making requests to Bubble.

class User extends BubbleSDK.DataType {
  // The name of the type in Bubble.
  type = "user";

  // Define your custom fields with their types.
  email: string;
  first_name: string;
}

Fetching data

To fetch by ID:

const user: User = await User.getByID("123");

To search:

const res: SearchResponse<User> = await User.search({
  constraints: [
    { key: "first_name", constraint_type: "contains", values: ["asdf"] },
  ],
  sort: {
    sort_field: "Created Date",
    descending: true,
  },
});

To get one item by searching:

const user: User | null = await User.getFirst(/** Accepts search options */);

To get all data matching search: Use with caution as this will make unlimited API requests to Bubble in order to page through all results

const users: User[] = await User.getAll(/** Accepts search options */);

Create and update

Creating a new object returns the ID of the created object.

const userID: string = await User.create({ email: "..." });

Update an object by calling .save()

const user: User = await User.getByID("123");
user.email = "new@email.com";
await user.save();
0.0.30

12 months ago

0.0.31

12 months ago

0.0.26

2 years ago

0.0.27

2 years ago

0.0.28

2 years ago

0.0.29

2 years ago

0.0.20

2 years ago

0.0.21

2 years ago

0.0.22

2 years ago

0.0.23

2 years ago

0.0.24

2 years ago

0.0.25

2 years ago

0.0.19

2 years ago

0.0.16

3 years ago

0.0.17

3 years ago

0.0.18

3 years ago

0.0.10

3 years ago

0.0.11

3 years ago

0.0.12

3 years ago

0.0.13

3 years ago

0.0.14

3 years ago

0.0.15

3 years ago

0.0.9

3 years ago

0.0.8

3 years ago

0.0.5

3 years ago

0.0.7

3 years ago

0.0.6

3 years ago

0.0.3

3 years ago

0.0.4

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago