Recipe From Ingredients

The 'recipe-from-ingredients' endpoint allows you to generate recipes from an available set of ingredients and additional criterias are available to fine ture the output. Customers have the choice of receiving the response as JSON or as a readable stream.

Introduction

This API route allows you to generate a recipe based on a set of provided ingredients and optional constraints.

Authentication

To access these endpoints, you must include an Authorization header with a valid API key.

Common Request Parameters

Both routes accept the following request parameters:

  • ingredients (array, required): An array of strings representing ingredients.
  • mealType (enum, optional): The type of meal you want to create ['breakfast', 'lunch', 'dinner', 'snack', 'dessert']. Default: No meal restrictions.
  • kitchenTools (array, optional): An array of strings representing kitchen tools available for cooking. Default: No tools restrictions.
  • preparationTime (number, optional): The maximum preparation time in minutes. Default: No time restrictions.
  • servings (number, optional): The amount of servings the recipe should yield. Default: 1 serving.
  • difficulty (enum, optional): The desired difficulty level of the recipe ['novice', 'intermediate', 'expert']. Default: No difficulty restrictions.
  • measurement (string, required): The measurement system used in the output ['imperial', 'metric']. Default: Metric.
  • language (string, optional): The language in which the recipe should be generated. Supported languages ['english', 'spanish', 'portuguese', 'french', 'italian', 'german', 'chinese', 'japanese', 'korean', 'hebrew']. Default: "english".
  • allergies (string, optional): A comma separated list of ingredients to exclude from the recipe.

JSON Route Details

Endpoint

POST /api/generate/recipe-from-ingredients

Request Example

POST /api/generate/recipe-from-ingredients
Headers:
{
  "Authorization": "YOUR_API_KEY"
}
Body:
{
  "ingredients": ["Chicken 500 grams","2 Cups of Rice "],
  "mealType": "dinner",
  "kitchenTools": ["oven", "pot"],
  "preparationTime": 30,
  "servings": 2,
  "difficulty": "intermediate"
}

Response (JSON)

  • Status Code: 200 (OK)
  • Content-Type: application/json
{
  "recipeName": "Delicious Chicken and Rice",
  "ingredients": [
    {
      "name": "Chicken",
      "unit": "grams",
      "amount": 500
    },
    {
      "name": "Rice",
      "unit": "cups",
      "amount": 2
    },
    // ... other ingredients
  ],
  "instructions": [
    "1. Preheat the oven to 350°F.",
    "2. Season the chicken with salt and pepper.",
    // ... other instructions
  ],
  "difficulty": "intermediate",
  "recipeCategory": ["dinner"],
  "recipeCuisine": ["american"],
  "macros": {
    "carbs": {
      "amount": 40,
      "unit": "grams"
    },
    // ... other macros
  },
  "preparationTime": 30,
  "servings": 2,
  "kitchenToolsUsed": ["oven", "pot"]
}

Execution Time

As responses are generated on the fly through AI, response time will vary depending on the lenght of the response. Approximate time for response is 10s for the 'recipe-from-ingredients' endpoint.

Error Responses

Both routes return specific error responses for various scenarios:

  • Missing API Key (Status Code: 403):
    • Response: No API Key in request
  • Invalid API Key (Status Code: 403):
    • Response: Invalid API Key
  • Missing Required Inputs (Status Code: 400):
    • Response: Required inputs not provided
  • Inactive Subscription (Status Code: 403):
    • Response: You don't have an active subscription