If you have ever tried building a health, diet, or nutrition app for Bangladesh, you have probably run into the same problem: reliable local nutrition data is mostly locked inside PDFs and spreadsheets.
The Food Composition Table for Bangladesh (FCTB) — published by the Institute of Nutrition and Food Science (INFS), University of Dhaka, in collaboration with FAO/INFOODS — is the standard reference for local foods. To make it easy for developers, researchers, and students to use in modern apps, I turned the dataset into two open-source tools:
-
fctb-bd— A zero-dependency TypeScript/JavaScript package (published on npm, JSR, and jsDelivr CDN) with offline JSON, CSV, and SQLite access. -
fctb-api— A free, edge-cached public REST API powered by Hono, Cloudflare Workers, and Cloudflare D1.
What's Inside the Dataset?
- 381 Bangladeshi foods across 15 categories
- Bilingual search supporting English names, Bangla script, transliterated Bangla, scientific names, and FCTB codes
- 6 cooking methods (
Boiled,Fried,Roasted,Toasted,Raw,Others) - 19 nutrient retention factor rules & 20 category mappings so raw-to-cooked nutrient adjustments are calculated automatically
1. Using the Offline Package (fctb-bd)
Install it from npm or JSR:
# npm npm install fctb-bd # JSR (Node / Deno / Bun) npx jsr add @fctb/bd Quick Example
import { searchFoods, getFoodByCode, calculateNutrition, } from "fctb-bd"; // Search in English or Bangla const riceResults = searchFoods("rice"); const banglaResults = searchFoods("যব"); // Look up a specific food by FCTB code const barley = getFoodByCode("01_0001"); // Calculate nutrition for 150g of raw barley when boiled (retention factors applied) const nutrition = calculateNutrition("01_0001", 150, "Boiled"); console.log(nutrition?.nutrients.enerc_kcal); console.log(nutrition?.nutrients.thia_mg); Direct JSON, CSV & SQLite via jsDelivr CDN
Building with Python, Flutter, Kotlin, or PHP? You don't even need npm—fetch the raw files directly from jsDelivr:
- Foods (JSON):
https://cdn.jsdelivr.net/npm/fctb-bd@1/data/json/foods.json - Foods (CSV):
https://cdn.jsdelivr.net/npm/fctb-bd@1/data/csv/foods.csv - Full SQLite Database (
fctb.db):https://cdn.jsdelivr.net/npm/fctb-bd@1/data/fctb.db
MD-ELIUS / fctb-bd
Zero-dependency TypeScript/JavaScript package for the Food Composition Table for Bangladesh (FCTB) — 381 foods, bilingual search, nutrition calculator, plus raw JSON, CSV & SQLite.
fctb-bd
Offline Food Composition Table for Bangladesh (FCTB) dataset packaged as a zero-runtime-dependency TypeScript/JavaScript library for npm and JSR, with direct access to TypeScript helpers, JSON, CSV, and SQLite.
Installation
npm
npm install fctb-bd JSR (Deno / Node / Bun)
npx jsr add @fctb/bd # or with Deno: deno add jsr:@fctb/bd Usage
Helper Functions
import { getAllFoods, getFoodByCode, searchFoods, getCategories, getFoodsByCategory, getCookingMethods, getRetentionFactors, getRetentionFactor, calculateNutrition, } from "fctb-bd"; // Search in English or Bangla const riceResults = searchFoods("rice"); const banglaResults = searchFoods("যব"); // Look up by FCTB code const barley = getFoodByCode("01_0001"); // Browse categories const categories = getCategories(); const cereals = getFoodsByCategory(1); // Calculate nutrition for 150g of raw barley when boiled const nutrition = calculateNutrition("01_0001",… 2. Using the Free Public REST API (fctb-api)
If you prefer calling an API directly from your frontend or mobile app, the public REST API is live with CORS enabled and edge caching (Cache-Control + Cloudflare Cache API):
Live Base URL: https://fctb-api.elius.workers.dev
Try It Right Now
Search foods (English or Bangla):
curl "[https://fctb-api.elius.workers.dev/api/foods?q=rice](https://fctb-api.elius.workers.dev/api/foods?q=rice)" Calculate single-food nutrition with cooking method:
curl "[https://fctb-api.elius.workers.dev/api/calculate?food_code=01_0001&grams=150&cooking_method=Boiled](https://fctb-api.elius.workers.dev/api/calculate?food_code=01_0001&grams=150&cooking_method=Boiled)" Calculate a full multi-item meal:
curl -X POST "[https://fctb-api.elius.workers.dev/api/calculate/meal](https://fctb-api.elius.workers.dev/api/calculate/meal)" \ -H "Content-Type: application/json" \ -d '{ "items": [ { "food_code": "01_0001", "grams": 100, "cooking_method": "Boiled" }, { "food_code": "01_0002", "grams": 150 } ] }' Key Endpoints
| Method | Endpoint | Description |
|---|---|---|
GET | /api/foods?q=rice | Search & filter foods (q, category, is_cooked, limit, offset) |
GET | /api/foods/:code | Get full nutrient profile by FCTB code or ID |
GET | /api/categories | List all 15 food categories with counts |
GET | /api/cooking-methods | List all 6 cooking methods |
GET | /api/retention-factors | List all 19 nutrient retention factor rules |
POST | /api/calculate | Single-food scaled nutrition calculation |
POST | `/api/calculate/meal |
