Getting started
Quickstart
From npm install to your first parsed meal in under five minutes.
1. Install the SDK
terminal
npm install @forkbit/js2. Initialize the client
src/forkbit.ts
import { Forkbit } from "@forkbit/js";
export const forkbit = new Forkbit({
apiKey: process.env.FORKBIT_API_KEY!,
});3. Search for a food
search.ts
const { data } = await forkbit.foods.search("chicken breast", { limit: 5 });
console.log(data[0]);
// { id: "3f2a1b9c-...", name: "Chicken breast, grilled",
// category: { slug: "poultry", name: "Poultry" },
// energyKcal: 165, proteinG: 31, carbsG: 0, fatG: 3.6 }4. Parse a free-text meal
parse.ts
const { data } = await forkbit.parse.nutrition("2 eggs and a slice of sourdough");
for (const item of data.matched) {
console.log(item.foodName, item.nutrition.calories);
}
// Egg, whole 144
// Sourdough bread 120That's it. From here, head to Endpoints for the full reference, or read Rate limits to understand how credits and request limits work.