Skip to content

Repository files navigation

Calorie API examples

Runnable Python and Node scripts for the Calorie API food database: search, barcode lookup, and macros per 100g.

Works three ways:

  1. Public demo — no key, rate-limited (/api/v1/public/...)
  2. DirectX-API-Key against https://calorieapiadmin.com
  3. RapidAPI HubX-RapidAPI-Key + X-RapidAPI-Host after you subscribe to the listing

No packages required. Python 3.9+ or Node 18+.

Run

git clone https://github.com/Busybody1/calorie-api-examples.git
cd calorie-api-examples

python3 search_foods.py "chicken breast"
node search_foods.mjs "chicken breast"

With a key from the site:

export CALORIE_API_KEY="your_key"
python3 search_foods.py apple

Via RapidAPI (copy Host from the Hub Code Snippets panel):

export RAPIDAPI_KEY="your_rapidapi_key"
export RAPIDAPI_HOST="your-api.p.rapidapi.com"
python3 search_foods.py apple

curl

Direct:

curl "https://calorieapiadmin.com/api/v1/search/foods?q=apple&limit=5" \
  -H "X-API-Key: your_key"

RapidAPI:

curl "https://your-api.p.rapidapi.com/api/v1/search/foods?q=apple&limit=5" \
  -H "X-RapidAPI-Key: your_rapidapi_key" \
  -H "X-RapidAPI-Host: your-api.p.rapidapi.com"

Public demo (30 requests/hour/IP):

curl "https://calorieapiadmin.com/api/v1/public/search/foods?q=apple&limit=5"

RapidAPI Hub

Paste this repository URL into the listing GitHub field so Hub subscribers land here. Paste the curl/Python/Node snippets above into endpoint examples. Backend base URL for the listing is https://calorieapiadmin.com (authenticated /api/v1/... routes, not /api/v1/public/...).

Tests

python3 -m unittest test_calorieapi.py -v
node --test calorieapi.test.mjs

License

MIT. Product and API: BusyBody FIT LTD.

About

Example scripts for Calorie API: food search via API key, RapidAPI Hub, or the public demo.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages