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.
To install the SDK, use npm or yarn:
npm install refuel-sdk
or
yarn add refuel-sdk
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:
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",
},
]
);
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",
}
);
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.
After making changes, use the following steps to test your changes locally:
- From the refuel-sdk directory run
npm run build
- cd to the directory of your application (for example,
cd ~/Development/refuel-cloud-web
) - Run
npm install /local/path/to/refuel-sdk
After merging your changes to main, complete the following steps to publish a new version of the SDK:
- 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) - Run
npm run build
- Create a new commit called "build vX.X.X" using the version number you saved to
package.json
in step 1 - Create a new PR with this commit and get that approved and merged to the main branch
- Checkout the latest main branch locally
- Ensure that the latest commit is "build vX.X.X"
- Run
git tag vX.X.X
- Run
git push origin --tags
- Run
npm publish
Reach out to us at [email protected] with any questions!