Bot for Too good to go and Foodsi
This project helps me to no longer miss my favorite offers at Too good to go and Foodsi.
"Too good to go" and "Foodsi" are platforms, where stores can offer bags of leftover food, that they otherwise need to throw away. The stores save a little bit of money, we get goods, that already have a few quirks, but are still consumable. Most importantly, this reduces food waste and thereby is good for the planet. In my neighborhood, e.g. a supermarket offers fruits & vegetables and a bakery offer their leftover bread at the end of the day.
However, the Too good to go and Foodsi apps does often not notify me in time when my favorite goods are in stock. Since the offers are popular and limited, I regularly miss the time to click and collect the items. There are no settings for notifications in the apps.
This application scrapes info from the Too good to go and Foodsi and sends me a notification via a Telegram bot as soon as some items in my area are available. Here is a screenshot:
There is a library wrapped around the API of the tgtg-app. You can find the library and a short documentation here.
I used Telegram as the service to notify me, because they are quite supportive for adding your own bots to the platform and provide a rich API. This article provides a quick introduction into sending Telegram messages with python.
pip install -r requirements.txt
cp config.example.json config.json
- Insert your bot token (you can get it from @BotFather)
- Insert your location info (i use latlong.net)
- Insert notification range (in kilometers)
python3 watch_script.py
On the first run the script will ask for your tgtg email address to get the needed API keys, and it will ask you to authorize your Telegram account by sending 6 digit pin to the bot.