Skip to content

refuel-ai/refuel-sdk

Repository files navigation

Refuel JavaScript SDK

The Refuel JavaScript SDK is a lightweight and easy-to-use client library for interacting with the Refuel API. It enables you to label data, manage application responses, and collect feedback seamlessly within your JavaScript or TypeScript applications.

Note: We also have a SDK for Python.

📦 Installation

To install the SDK, use npm or yarn:

npm install refuel-sdk

or

yarn add refuel-sdk

🧑‍💻 Usage

To get started, you'll need a Refuel API key. You can find this in your account settings or contact your team administrator.

Import the SDK into your application and start interacting with the Refuel API:

Example: Label Data

import { Refuel } from "refuel-sdk";

const refuel = new Refuel("your_access_token");

const applicationLabels = await refuel.applications.label(
    "your_application_id",
    [
        // Data to label
        {
            menu_text:
                "Grilled chicken sandwich with avocado and chipotle mayo",
        },
    ]
);

Example: Update Label with Feedback

import { Refuel } from "refuel-sdk";

const refuel = new Refuel("your_access_token");

await refuel.applications.feedback(
    "your_application_id",
    "your_labeled_item_id",
    // Correct label
    {
        vegetarian: "no",
    }
);

🔨 Developing the SDK

These steps are intended for developers of the refuel-sdk. If you are just installing refuel-sdk to use in your application then you can ignore this section.

Local development

After making changes, use the following steps to test your changes locally:

  1. From the refuel-sdk directory run npm run build
  2. cd to the directory of your application (for example, cd ~/Development/refuel-cloud-web)
  3. Run npm install /local/path/to/refuel-sdk

Publishing new versions

After merging your changes to main, complete the following steps to publish a new version of the SDK:

  1. Edit package.json and increase the version number (follow semver starting with v1.0.0, for versions prior to v1.0.0 always increase the minor version by one)
  2. Run npm run build
  3. Create a new commit called "build vX.X.X" using the version number you saved to package.json in step 1
  4. Create a new PR with this commit and get that approved and merged to the main branch
  5. Checkout the latest main branch locally
  6. Ensure that the latest commit is "build vX.X.X"
  7. Run git tag vX.X.X
  8. Run git push origin --tags
  9. Run npm publish

Questions?

Reach out to us at [email protected] with any questions!