Skip to content

Files

Failed to load latest commit information.

Latest commit

 Cannot retrieve latest commit at this time.

History

History

javascript

spoonacular

Spoonacular - JavaScript client for spoonacular The spoonacular Nutrition, Recipe, and Food API allows you to access over thousands of recipes, thousands of ingredients, 800,000 food products, over 100,000 menu items, and restaurants. Our food ontology and semantic recipe search engine makes it possible to search for recipes using natural language queries, such as "gluten free brownies without sugar" or "low fat vegan cupcakes." You can automatically calculate the nutritional information for any recipe, analyze recipe costs, visualize ingredient lists, find recipes for what's in your fridge, find recipes based on special diets, nutritional requirements, or favorite ingredients, classify recipes into types and cuisines, convert ingredient amounts, or even compute an entire meal plan. With our powerful API, you can create many kinds of food and especially nutrition apps.

Special diets/dietary requirements currently available include: vegan, vegetarian, pescetarian, gluten free, grain free, dairy free, high protein, whole 30, low sodium, low carb, Paleo, ketogenic, FODMAP, and Primal. This SDK is automatically generated by the OpenAPI Generator project:

  • API version: 2.0.2
  • Package version: 2.0.2
  • Generator version: 7.8.0-SNAPSHOT
  • Build package: org.openapitools.codegen.languages.JavascriptClientCodegen For more information, please visit https://spoonacular.com/contact

Installation

npm

To publish the library as a npm, please follow the procedure in "Publishing npm packages".

Then install it via:

npm install spoonacular --save

Finally, you need to build the module:

npm run build
Local development

To use the library locally without publishing to a remote npm registry, first install the dependencies by changing into the directory containing package.json (and this README). Let's call this JAVASCRIPT_CLIENT_DIR. Then run:

npm install

Next, link it globally in npm with the following, also from JAVASCRIPT_CLIENT_DIR:

npm link

To use the link you just defined in your project, switch to the directory you want to use your spoonacular from, and run:

npm link /path/to/<JAVASCRIPT_CLIENT_DIR>

Finally, you need to build the module:

npm run build

git

If the library is hosted at a git repository, e.g.https://github.com/ddsky/spoonacular-api-clients/tree/master/javascript/ then install it via:

    npm install ddsky/spoonacular-api-clients/tree/master/javascript/ --save

For browser

The library also works in the browser environment via npm and browserify. After following the above steps with Node.js and installing browserify with npm install -g browserify, perform the following (assuming main.js is your entry file):

browserify main.js > bundle.js

Then include bundle.js in the HTML pages.

Webpack Configuration

Using Webpack you may encounter the following error: "Module not found: Error: Cannot resolve module", most certainly you should disable AMD loader. Add/merge the following section to your webpack config:

module: {
  rules: [
    {
      parser: {
        amd: false
      }
    }
  ]
}

Getting Started

Please follow the installation instruction and execute the following JS code:

var Spoonacular = require('spoonacular');

var defaultClient = Spoonacular.ApiClient.instance;
// Configure API key authorization: apiKeyScheme
var apiKeyScheme = defaultClient.authentications['apiKeyScheme'];
apiKeyScheme.apiKey = "YOUR API KEY"
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//apiKeyScheme.apiKeyPrefix['x-api-key'] = "Token"

var api = new Spoonacular.DefaultApi()
var analyzeRecipeRequest = {"title":"Spaghetti Carbonara","servings":2,"ingredients":["1 lb spaghetti","3.5 oz pancetta","2 Tbsps olive oil","1  egg","0.5 cup parmesan cheese"],"instructions":"Bring a large pot of water to a boil and season generously with salt. Add the pasta to the water once boiling and cook until al dente. Reserve 2 cups of cooking water and drain the pasta. "}; // {AnalyzeRecipeRequest} Example request body.
var opts = {
  'language': "en", // {String} The input language, either \"en\" or \"de\".
  'includeNutrition': false, // {Boolean} Whether nutrition data should be added to correctly parsed ingredients.
  'includeTaste': false // {Boolean} Whether taste data should be added to correctly parsed ingredients.
};
var callback = function(error, data, response) {
  if (error) {
    console.error(error);
  } else {
    console.log('API called successfully. Returned data: ' + data);
  }
};
api.analyzeRecipe(analyzeRecipeRequest, opts, callback);

Documentation for API Endpoints

All URIs are relative to https://api.spoonacular.com

Class Method HTTP request Description
Spoonacular.DefaultApi analyzeRecipe POST /recipes/analyze Analyze Recipe
Spoonacular.DefaultApi createRecipeCardGet GET /recipes/{id}/card Create Recipe Card
Spoonacular.DefaultApi searchRestaurants GET /food/restaurants/search Search Restaurants
Spoonacular.IngredientsApi autocompleteIngredientSearch GET /food/ingredients/autocomplete Autocomplete Ingredient Search
Spoonacular.IngredientsApi computeIngredientAmount GET /food/ingredients/{id}/amount Compute Ingredient Amount
Spoonacular.IngredientsApi getIngredientInformation GET /food/ingredients/{id}/information Get Ingredient Information
Spoonacular.IngredientsApi getIngredientSubstitutes GET /food/ingredients/substitutes Get Ingredient Substitutes
Spoonacular.IngredientsApi getIngredientSubstitutesByID GET /food/ingredients/{id}/substitutes Get Ingredient Substitutes by ID
Spoonacular.IngredientsApi ingredientSearch GET /food/ingredients/search Ingredient Search
Spoonacular.IngredientsApi ingredientsByIDImage GET /recipes/{id}/ingredientWidget.png Ingredients by ID Image
Spoonacular.IngredientsApi mapIngredientsToGroceryProducts POST /food/ingredients/map Map Ingredients to Grocery Products
Spoonacular.IngredientsApi visualizeIngredients POST /recipes/visualizeIngredients Ingredients Widget
Spoonacular.MealPlanningApi addMealPlanTemplate POST /mealplanner/{username}/templates Add Meal Plan Template
Spoonacular.MealPlanningApi addToMealPlan POST /mealplanner/{username}/items Add to Meal Plan
Spoonacular.MealPlanningApi addToShoppingList POST /mealplanner/{username}/shopping-list/items Add to Shopping List
Spoonacular.MealPlanningApi clearMealPlanDay DELETE /mealplanner/{username}/day/{date} Clear Meal Plan Day
Spoonacular.MealPlanningApi connectUser POST /users/connect Connect User
Spoonacular.MealPlanningApi deleteFromMealPlan DELETE /mealplanner/{username}/items/{id} Delete from Meal Plan
Spoonacular.MealPlanningApi deleteFromShoppingList DELETE /mealplanner/{username}/shopping-list/items/{id} Delete from Shopping List
Spoonacular.MealPlanningApi deleteMealPlanTemplate DELETE /mealplanner/{username}/templates/{id} Delete Meal Plan Template
Spoonacular.MealPlanningApi generateMealPlan GET /mealplanner/generate Generate Meal Plan
Spoonacular.MealPlanningApi generateShoppingList POST /mealplanner/{username}/shopping-list/{start_date}/{end_date} Generate Shopping List
Spoonacular.MealPlanningApi getMealPlanTemplate GET /mealplanner/{username}/templates/{id} Get Meal Plan Template
Spoonacular.MealPlanningApi getMealPlanTemplates GET /mealplanner/{username}/templates Get Meal Plan Templates
Spoonacular.MealPlanningApi getMealPlanWeek GET /mealplanner/{username}/week/{start_date} Get Meal Plan Week
Spoonacular.MealPlanningApi getShoppingList GET /mealplanner/{username}/shopping-list Get Shopping List
Spoonacular.MenuItemsApi autocompleteMenuItemSearch GET /food/menuItems/suggest Autocomplete Menu Item Search
Spoonacular.MenuItemsApi getMenuItemInformation GET /food/menuItems/{id} Get Menu Item Information
Spoonacular.MenuItemsApi menuItemNutritionByIDImage GET /food/menuItems/{id}/nutritionWidget.png Menu Item Nutrition by ID Image
Spoonacular.MenuItemsApi menuItemNutritionLabelImage GET /food/menuItems/{id}/nutritionLabel.png Menu Item Nutrition Label Image
Spoonacular.MenuItemsApi menuItemNutritionLabelWidget GET /food/menuItems/{id}/nutritionLabel Menu Item Nutrition Label Widget
Spoonacular.MenuItemsApi searchMenuItems GET /food/menuItems/search Search Menu Items
Spoonacular.MenuItemsApi visualizeMenuItemNutritionByID GET /food/menuItems/{id}/nutritionWidget Menu Item Nutrition by ID Widget
Spoonacular.MiscApi detectFoodInText POST /food/detect Detect Food in Text
Spoonacular.MiscApi getARandomFoodJoke GET /food/jokes/random Random Food Joke
Spoonacular.MiscApi getConversationSuggests GET /food/converse/suggest Conversation Suggests
Spoonacular.MiscApi getRandomFoodTrivia GET /food/trivia/random Random Food Trivia
Spoonacular.MiscApi imageAnalysisByURL GET /food/images/analyze Image Analysis by URL
Spoonacular.MiscApi imageClassificationByURL GET /food/images/classify Image Classification by URL
Spoonacular.MiscApi searchAllFood GET /food/search Search All Food
Spoonacular.MiscApi searchCustomFoods GET /food/customFoods/search Search Custom Foods
Spoonacular.MiscApi searchFoodVideos GET /food/videos/search Search Food Videos
Spoonacular.MiscApi searchSiteContent GET /food/site/search Search Site Content
Spoonacular.MiscApi talkToChatbot GET /food/converse Talk to Chatbot
Spoonacular.ProductsApi autocompleteProductSearch GET /food/products/suggest Autocomplete Product Search
Spoonacular.ProductsApi classifyGroceryProduct POST /food/products/classify Classify Grocery Product
Spoonacular.ProductsApi classifyGroceryProductBulk POST /food/products/classifyBatch Classify Grocery Product Bulk
Spoonacular.ProductsApi getComparableProducts GET /food/products/upc/{upc}/comparable Get Comparable Products
Spoonacular.ProductsApi getProductInformation GET /food/products/{id} Get Product Information
Spoonacular.ProductsApi productNutritionByIDImage GET /food/products/{id}/nutritionWidget.png Product Nutrition by ID Image
Spoonacular.ProductsApi productNutritionLabelImage GET /food/products/{id}/nutritionLabel.png Product Nutrition Label Image
Spoonacular.ProductsApi productNutritionLabelWidget GET /food/products/{id}/nutritionLabel Product Nutrition Label Widget
Spoonacular.ProductsApi searchGroceryProducts GET /food/products/search Search Grocery Products
Spoonacular.ProductsApi searchGroceryProductsByUPC GET /food/products/upc/{upc} Search Grocery Products by UPC
Spoonacular.ProductsApi visualizeProductNutritionByID GET /food/products/{id}/nutritionWidget Product Nutrition by ID Widget
Spoonacular.RecipesApi analyzeARecipeSearchQuery GET /recipes/queries/analyze Analyze a Recipe Search Query
Spoonacular.RecipesApi analyzeRecipeInstructions POST /recipes/analyzeInstructions Analyze Recipe Instructions
Spoonacular.RecipesApi autocompleteRecipeSearch GET /recipes/autocomplete Autocomplete Recipe Search
Spoonacular.RecipesApi classifyCuisine POST /recipes/cuisine Classify Cuisine
Spoonacular.RecipesApi computeGlycemicLoad POST /food/ingredients/glycemicLoad Compute Glycemic Load
Spoonacular.RecipesApi convertAmounts GET /recipes/convert Convert Amounts
Spoonacular.RecipesApi createRecipeCard POST /recipes/visualizeRecipe Create Recipe Card
Spoonacular.RecipesApi equipmentByIDImage GET /recipes/{id}/equipmentWidget.png Equipment by ID Image
Spoonacular.RecipesApi extractRecipeFromWebsite GET /recipes/extract Extract Recipe from Website
Spoonacular.RecipesApi getAnalyzedRecipeInstructions GET /recipes/{id}/analyzedInstructions Get Analyzed Recipe Instructions
Spoonacular.RecipesApi getRandomRecipes GET /recipes/random Get Random Recipes
Spoonacular.RecipesApi getRecipeEquipmentByID GET /recipes/{id}/equipmentWidget.json Equipment by ID
Spoonacular.RecipesApi getRecipeInformation GET /recipes/{id}/information Get Recipe Information
Spoonacular.RecipesApi getRecipeInformationBulk GET /recipes/informationBulk Get Recipe Information Bulk
Spoonacular.RecipesApi getRecipeIngredientsByID GET /recipes/{id}/ingredientWidget.json Ingredients by ID
Spoonacular.RecipesApi getRecipeNutritionWidgetByID GET /recipes/{id}/nutritionWidget.json Nutrition by ID
Spoonacular.RecipesApi getRecipePriceBreakdownByID GET /recipes/{id}/priceBreakdownWidget.json Price Breakdown by ID
Spoonacular.RecipesApi getRecipeTasteByID GET /recipes/{id}/tasteWidget.json Taste by ID
Spoonacular.RecipesApi getSimilarRecipes GET /recipes/{id}/similar Get Similar Recipes
Spoonacular.RecipesApi guessNutritionByDishName GET /recipes/guessNutrition Guess Nutrition by Dish Name
Spoonacular.RecipesApi parseIngredients POST /recipes/parseIngredients Parse Ingredients
Spoonacular.RecipesApi priceBreakdownByIDImage GET /recipes/{id}/priceBreakdownWidget.png Price Breakdown by ID Image
Spoonacular.RecipesApi quickAnswer GET /recipes/quickAnswer Quick Answer
Spoonacular.RecipesApi recipeNutritionByIDImage GET /recipes/{id}/nutritionWidget.png Recipe Nutrition by ID Image
Spoonacular.RecipesApi recipeNutritionLabelImage GET /recipes/{id}/nutritionLabel.png Recipe Nutrition Label Image
Spoonacular.RecipesApi recipeNutritionLabelWidget GET /recipes/{id}/nutritionLabel Recipe Nutrition Label Widget
Spoonacular.RecipesApi recipeTasteByIDImage GET /recipes/{id}/tasteWidget.png Recipe Taste by ID Image
Spoonacular.RecipesApi searchRecipes GET /recipes/complexSearch Search Recipes
Spoonacular.RecipesApi searchRecipesByIngredients GET /recipes/findByIngredients Search Recipes by Ingredients
Spoonacular.RecipesApi searchRecipesByNutrients GET /recipes/findByNutrients Search Recipes by Nutrients
Spoonacular.RecipesApi summarizeRecipe GET /recipes/{id}/summary Summarize Recipe
Spoonacular.RecipesApi visualizeEquipment POST /recipes/visualizeEquipment Equipment Widget
Spoonacular.RecipesApi visualizePriceBreakdown POST /recipes/visualizePriceEstimator Price Breakdown Widget
Spoonacular.RecipesApi visualizeRecipeEquipmentByID GET /recipes/{id}/equipmentWidget Equipment by ID Widget
Spoonacular.RecipesApi visualizeRecipeIngredientsByID GET /recipes/{id}/ingredientWidget Ingredients by ID Widget
Spoonacular.RecipesApi visualizeRecipeNutrition POST /recipes/visualizeNutrition Recipe Nutrition Widget
Spoonacular.RecipesApi visualizeRecipeNutritionByID GET /recipes/{id}/nutritionWidget Recipe Nutrition by ID Widget
Spoonacular.RecipesApi visualizeRecipePriceBreakdownByID GET /recipes/{id}/priceBreakdownWidget Price Breakdown by ID Widget
Spoonacular.RecipesApi visualizeRecipeTaste POST /recipes/visualizeTaste Recipe Taste Widget
Spoonacular.RecipesApi visualizeRecipeTasteByID GET /recipes/{id}/tasteWidget Recipe Taste by ID Widget
Spoonacular.WineApi getDishPairingForWine GET /food/wine/dishes Dish Pairing for Wine
Spoonacular.WineApi getWineDescription GET /food/wine/description Wine Description
Spoonacular.WineApi getWinePairing GET /food/wine/pairing Wine Pairing
Spoonacular.WineApi getWineRecommendation GET /food/wine/recommendation Wine Recommendation

Documentation for Models

Documentation for Authorization

Authentication schemes defined for the API:

apiKeyScheme

  • Type: API key
  • API key parameter name: x-api-key
  • Location: HTTP header