Created
March 1, 2025 21:00
-
-
Save wsargent/01b3a42cb9370d0c2bcc74c56471966d to your computer and use it in GitHub Desktop.
Letta function to add recipe to Mealie.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import os | |
def add_recipe_to_mealie_from_url(recipe_url: str, include_tags: bool=False): | |
""" | |
Adds a recipe to Mealie from a URL of a cooking website containing the recipe. | |
Use this function when you have found a recipe using Tavily and have the URL or the user has | |
shared a recipe URL. | |
Parameters | |
---------- | |
recipe_url: str | |
The URL of the recipe to add to Mealie. | |
include_tags: bool, optional | |
Whether to include tags in the recipe. Defaults to False. | |
Returns: | |
str: | |
The recipe slug of the added recipe. This can be used to update the recipe later. | |
""" | |
endpoint = os.getenv("MEALIE_ENDPOINT") | |
api_key = os.getenv("MEALIE_API_KEY") | |
headers = { | |
"accept": "application/json", | |
"Authorization": "Bearer " + api_key | |
} | |
body = { | |
"include_tags": include_tags, | |
"url": recipe_url, | |
} | |
response = requests.post( | |
f"{endpoint}/api/recipes/create/url", | |
json=body, | |
headers = headers | |
) | |
return response.text.strip('\"') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment