Pick recipes that fit a daily calorie and carb budget using the Keto Recipe API.
Subscribe to the free BASIC plan on the RapidAPI listing, then copy your key from the RapidAPI dashboard. Requests go to keto-diet.p.rapidapi.com.
The recipes endpoint accepts these filters:
calories__lt: maximum calories per servingcarbohydrates_in_grams__lt: maximum net carbs per servingcategory: a category id; each recipe includes its category object (for example {'id': 1, 'category': 'Breakfast Recipes'})const res = await fetch(
'https://keto-diet.p.rapidapi.com/?calories__lt=500&carbohydrates_in_grams__lt=10',
{ headers: { 'x-rapidapi-key': 'YOUR_KEY', 'x-rapidapi-host': 'keto-diet.p.rapidapi.com' } }
);
const recipes = await res.json();
recipes.forEach(r => console.log(r.recipe, r.calories));
import requests
resp = requests.get(
'https://keto-diet.p.rapidapi.com/',
params={'calories__lt': 500, 'carbohydrates_in_grams__lt': 10},
headers={'x-rapidapi-key': 'YOUR_KEY', 'x-rapidapi-host': 'keto-diet.p.rapidapi.com'},
timeout=10,
)
for recipe in resp.json():
print(recipe['recipe'], recipe['calories'])
Every recipe carries its category, so one low-carb query gives you the category ids. Then request one recipe per meal with category:
headers = {'x-rapidapi-key': 'YOUR_KEY', 'x-rapidapi-host': 'keto-diet.p.rapidapi.com'}
url = 'https://keto-diet.p.rapidapi.com/'
recipes = requests.get(url, params={'carbohydrates_in_grams__lt': 10}, headers=headers, timeout=10).json()
categories = {r['category']['id']: r['category']['category'] for r in recipes if r.get('category')}
plan = {}
for cat_id, name in categories.items():
picks = requests.get(url, params={'category': cat_id, 'calories__lt': 600}, headers=headers, timeout=10).json()
plan[name] = picks[0]['recipe'] if picks else None
print(plan)