SDKs overview

Edamam offers a suite of APIs for food and nutrition data, including the Nutrition Analysis API, Recipe Search API, Food Database API, and Meal Planner API. To facilitate integration, Edamam provides developer resources that include example code snippets in various languages such as cURL, JavaScript, and Python. While Edamam's developer portal emphasizes direct API calls, these examples function as de facto SDKs, providing structured ways to interact with the API endpoints without requiring developers to build request logic from scratch for each interaction method. The Edamam developer documentation outlines the parameters and responses for each API, aiding in client library development and direct HTTP requests.

Integrating with Edamam's APIs typically involves making HTTP requests to specific endpoints and authenticating with an Application ID and Application Key, which are obtained through the developer portal. The API responses are generally formatted in JSON, a common data interchange format for web APIs, as described by the JSON data interchange standard. Developers can parse these responses using standard library functions in their chosen programming language.

Official SDKs by language

Edamam primarily supports direct API consumption through RESTful HTTP requests, providing extensive documentation and code examples in several languages rather than distributing traditional, compiled SDKs. The examples act as guides for constructing requests and parsing responses, covering the core functionalities of the Edamam APIs. The table below summarizes the officially supported methods and example availability.

Language/Method Package/Tool Install/Usage Command Maturity
cURL Command-line tool curl -X GET "https://api.edamam.com/..." Stable (CLI utility)
JavaScript Fetch API / Axios npm install axios (for Axios) Examples provided for direct integration
Python Requests library pip install requests Examples provided for direct integration

Installation

For Edamam's API, installation typically refers to setting up the environment to make HTTP requests and handle responses, rather than installing a dedicated SDK package. The primary requirements are an HTTP client library for your chosen programming language and your Edamam Application ID and Application Key, which are available on the Edamam developer portal.

Python

To use Python for interacting with Edamam APIs, the requests library is commonly used for making HTTP requests.

pip install requests

JavaScript (Node.js/Browser)

For JavaScript environments, the built-in Fetch API is available in modern browsers and Node.js (with a polyfill or specific version). Alternatively, the axios library is a popular choice for both browser and Node.js environments.

npm install axios

cURL

cURL is usually pre-installed on most Unix-like operating systems. For Windows, it can be downloaded and installed as part of developer tools or Git for Windows. No specific installation is typically required beyond system checks for its presence.

These tools facilitate the interaction with RESTful APIs as described by the W3C's architectural styles for the Web, which Edamam's APIs adhere to.

Quickstart example

This quickstart demonstrates how to search for recipes using the Edamam Recipe Search API with Python and JavaScript. Replace YOUR_APP_ID and YOUR_APP_KEY with your actual credentials from the Edamam developer dashboard.

Python Example (Recipe Search)

This Python example uses the requests library to query the Recipe Search API for recipes containing 'chicken'.

import requests

APP_ID = "YOUR_APP_ID"
APP_KEY = "YOUR_APP_KEY"
QUERY = "chicken"

url = f"https://api.edamam.com/api/recipes/v2?type=public&q={QUERY}&app_id={APP_ID}&app_key={APP_KEY}"

try:
    response = requests.get(url)
    response.raise_for_status() # Raise an HTTPError for bad responses (4xx or 5xx)
    data = response.json()

    print(f"Found {data['count']} recipes for '{QUERY}':\n")
    for hit in data.get('hits', [])[:5]: # Print first 5 recipes
        recipe = hit['recipe']
        print(f"- {recipe['label']} ({recipe['url']})")
        print(f"  Calories: {int(recipe['calories'])}, Ingredients: {len(recipe['ingredients'])}")

except requests.exceptions.HTTPError as http_err:
    print(f"HTTP error occurred: {http_err}")
except Exception as err:
    print(f"Other error occurred: {err}")

JavaScript Example (Recipe Search - Node.js using Axios)

This Node.js example uses the axios library to perform a similar recipe search.

const axios = require('axios');

const APP_ID = "YOUR_APP_ID";
const APP_KEY = "YOUR_APP_KEY";
const QUERY = "chicken";

const url = `https://api.edamam.com/api/recipes/v2?type=public&q=${QUERY}&app_id=${APP_ID}&app_key=${APP_KEY}`;

async function searchRecipes() {
  try {
    const response = await axios.get(url);
    const data = response.data;

    console.log(`Found ${data.count} recipes for '${QUERY}':\n`);
    data.hits.slice(0, 5).forEach(hit => { // Print first 5 recipes
      const recipe = hit.recipe;
      console.log(`- ${recipe.label} (${recipe.url})`);
      console.log(`  Calories: ${Math.floor(recipe.calories)}, Ingredients: ${recipe.ingredients.length}`);
    });
  } catch (error) {
    if (error.response) {
      // The request was made and the server responded with a status code
      // that falls out of the range of 2xx
      console.error(`HTTP error: ${error.response.status} - ${error.response.data}`);
    } else if (error.request) {
      // The request was made but no response was received
      console.error("No response received:", error.request);
    } else {
      // Something happened in setting up the request that triggered an Error
      console.error('Error', error.message);
    }
  }
}

searchRecipes();

Community libraries

While Edamam emphasizes direct API integration with its extensive documentation and code examples, the open-source community often develops wrapper libraries or client SDKs to further simplify API consumption. These community-contributed libraries can abstract away repetitive tasks like constructing URLs, handling authentication headers, and parsing JSON responses, potentially speeding up development.

Developers looking for community-maintained libraries for Edamam's APIs typically search public code repositories like GitHub or package managers specific to their language (e.g., PyPI for Python, npm for JavaScript). These resources often host projects that wrap Edamam's API functionality. Before using a community library, it is advisable to check its maintenance status, documentation, and community support, as these are not officially endorsed or maintained by Edamam. Searching for terms like "edamam python client" or "edamam node.js wrapper" on these platforms can yield relevant projects.

For example, a search on GitHub might reveal projects that provide a more object-oriented interface to the Edamam API, allowing developers to interact with food and recipe data using method calls specific to ingredients, recipes, or nutritional facts. The stability and feature completeness of such libraries vary and depend on their individual development cycles and community contributions. As a general practice for working with third-party APIs, many developers choose to build their own client code based on official documentation to maintain full control and minimize external dependencies, as discussed in best practices for Google API client library guidelines.