Unoffical python client for TooGoodToGo API
Project description
tgtg-python
Python client that help you to talk with TooGoodToGo API.
Python version: 3.6, 3.7, 3.8, 3.9
Handle:
- login (
/api/auth/v1/loginByEmail) - list stores (
/api/item/) - get a store (
/api/item/:id) - set favorite (
/api/item/:id/setFavorite) - create an account (
auth/v2/signUpByEmail)
Used by:
Install
pip install tgtg
Use it
Build the client
from tgtg import TgtgClient
client = TgtgClient(email="<your_email>", password="<your_password>")
Get items
# You can then get some items, by default it will *only* get your favorites
client.get_items()
# To get items (not only your favorites) you need to provide location informations
client.get_items(
favorites_only=False,
latitude=48.126,
longitude=-1.723,
radius=10,
)
Example response
[
{
"item": {
"item_id": "64346",
"price": {"code": "EUR", "minor_units": 499, "decimals": 2},
"sales_taxes": [],
"tax_amount": {"code": "EUR", "minor_units": 0, "decimals": 2},
"price_excluding_taxes": {"code": "EUR", "minor_units": 499, "decimals": 2},
"price_including_taxes": {"code": "EUR", "minor_units": 499, "decimals": 2},
"value_excluding_taxes": {
"code": "EUR",
"minor_units": 1500,
"decimals": 2,
},
"value_including_taxes": {
"code": "EUR",
"minor_units": 1500,
"decimals": 2,
},
"taxation_policy": "PRICE_INCLUDES_TAXES",
"show_sales_taxes": False,
"value": {"code": "EUR", "minor_units": 1500, "decimals": 2},
"cover_picture": {
"picture_id": "110628",
"current_url": "https://images.tgtg.ninja/item/cover/2b69cbdd-43d3-4ade-bd51-50e338260859.jpg",
},
"logo_picture": {
"picture_id": "110618",
"current_url": "https://images.tgtg.ninja/store/fb893813-a775-4dec-ac7b-d4a7dd326fa8.png",
},
"name": "",
"description": "Salva comida en Ecofamily Bufé y tu pack podrá contener: comidas caseras.",
"can_user_supply_packaging": False,
"packaging_option": "MUST_BRING_BAG",
"collection_info": "",
"diet_categories": [],
"item_category": "MEAL",
"badges": [
{
"badge_type": "SERVICE_RATING_SCORE",
"rating_group": "LIKED",
"percentage": 93,
"user_count": 178,
"month_count": 5,
}
],
"favorite_count": 0,
"buffet": False,
},
"store": {
"store_id": "59949s",
"store_name": "Ecofamily Bufé - Centro",
"branch": "",
"description": "",
"tax_identifier": "",
"website": "",
"store_location": {
"address": {
"country": {"iso_code": "ES", "name": "Spain"},
"address_line": "Av. de los Piconeros, S/N, 14001 Córdoba, España",
"city": "",
"postal_code": "",
},
"location": {"longitude": -4.776045, "latitude": 37.894249},
},
"logo_picture": {
"picture_id": "110618",
"current_url": "https://images.tgtg.ninja/store/fb893813-a775-4dec-ac7b-d4a7dd326fa8.png",
},
"store_time_zone": "Europe/Madrid",
"hidden": False,
"favorite_count": 0,
"we_care": False,
},
"display_name": "Ecofamily Bufé - Centro",
"pickup_location": {
"address": {
"country": {"iso_code": "ES", "name": "Spain"},
"address_line": "Av. de los Piconeros, S/N, 14001 Córdoba, España",
"city": "",
"postal_code": "",
},
"location": {"longitude": -4.776045, "latitude": 37.894249},
},
"items_available": 0,
"distance": 4241.995584076078,
"favorite": True,
"in_sales_window": False,
"new_item": False,
},
]
Get an item
(Using item_id from get_items response)
client.get_item(item_id=64346)
Example response
{
"item": {
"item_id": "64346",
"price": {"code": "EUR", "minor_units": 499, "decimals": 2},
"sales_taxes": [],
"tax_amount": {"code": "EUR", "minor_units": 0, "decimals": 2},
"price_excluding_taxes": {"code": "EUR", "minor_units": 499, "decimals": 2},
"price_including_taxes": {"code": "EUR", "minor_units": 499, "decimals": 2},
"value_excluding_taxes": {"code": "EUR", "minor_units": 1500, "decimals": 2},
"value_including_taxes": {"code": "EUR", "minor_units": 1500, "decimals": 2},
"taxation_policy": "PRICE_INCLUDES_TAXES",
"show_sales_taxes": False,
"value": {"code": "EUR", "minor_units": 1500, "decimals": 2},
"cover_picture": {
"picture_id": "110628",
"current_url": "https://images.tgtg.ninja/item/cover/2b69cbdd-43d3-4ade-bd51-50e338260859.jpg",
},
"logo_picture": {
"picture_id": "110618",
"current_url": "https://images.tgtg.ninja/store/fb893813-a775-4dec-ac7b-d4a7dd326fa8.png",
},
"name": "",
"description": "Salva comida en Ecofamily Buf\xc3\xa9 y tu pack podr\xc3\xa1 contener: comidas caseras.",
"can_user_supply_packaging": False,
"packaging_option": "MUST_BRING_BAG",
"collection_info": "",
"diet_categories": [],
"item_category": "MEAL",
"badges": [
{
"badge_type": "SERVICE_RATING_SCORE",
"rating_group": "LIKED",
"percentage": 93,
"user_count": 178,
"month_count": 5,
}
],
"favorite_count": 0,
"buffet": False,
},
"store": {
"store_id": "59949s",
"store_name": "Ecofamily Buf\xc3\xa9 - Centro",
"branch": "",
"description": "",
"tax_identifier": "",
"website": "",
"store_location": {
"address": {
"country": {"iso_code": "ES", "name": "Spain"},
"address_line": "Av. de los Piconeros, S/N, 14001 C\xc3\xb3rdoba, Espa\xc3\xb1a",
"city": "",
"postal_code": "",
},
"location": {"longitude": -4.776045, "latitude": 37.894249},
},
"logo_picture": {
"picture_id": "110618",
"current_url": "https://images.tgtg.ninja/store/fb893813-a775-4dec-ac7b-d4a7dd326fa8.png",
},
"store_time_zone": "Europe/Madrid",
"hidden": False,
"favorite_count": 0,
"items": [
{
"item": {
"item_id": "64346",
"price": {"code": "EUR", "minor_units": 499, "decimals": 2},
"sales_taxes": [],
"tax_amount": {"code": "EUR", "minor_units": 0, "decimals": 2},
"price_excluding_taxes": {
"code": "EUR",
"minor_units": 499,
"decimals": 2,
},
"price_including_taxes": {
"code": "EUR",
"minor_units": 499,
"decimals": 2,
},
"value_excluding_taxes": {
"code": "EUR",
"minor_units": 1500,
"decimals": 2,
},
"value_including_taxes": {
"code": "EUR",
"minor_units": 1500,
"decimals": 2,
},
"taxation_policy": "PRICE_INCLUDES_TAXES",
"show_sales_taxes": False,
"value": {"code": "EUR", "minor_units": 1500, "decimals": 2},
"cover_picture": {
"picture_id": "110628",
"current_url": "https://images.tgtg.ninja/item/cover/2b69cbdd-43d3-4ade-bd51-50e338260859.jpg",
},
"logo_picture": {
"picture_id": "110618",
"current_url": "https://images.tgtg.ninja/store/fb893813-a775-4dec-ac7b-d4a7dd326fa8.png",
},
"name": "",
"description": "Salva comida en Ecofamily Buf\xc3\xa9 y tu pack podr\xc3\xa1 contener: comidas caseras.",
"can_user_supply_packaging": False,
"packaging_option": "MUST_BRING_BAG",
"collection_info": "",
"diet_categories": [],
"item_category": "MEAL",
"badges": [
{
"badge_type": "SERVICE_RATING_SCORE",
"rating_group": "LIKED",
"percentage": 93,
"user_count": 178,
"month_count": 5,
}
],
"favorite_count": 0,
"buffet": False,
},
"display_name": "Ecofamily Buf\xc3\xa9 - Centro",
"pickup_location": {
"address": {
"country": {"iso_code": "ES", "name": "Spain"},
"address_line": "Av. de los Piconeros, S/N, 14001 C\xc3\xb3rdoba, Espa\xc3\xb1a",
"city": "",
"postal_code": "",
},
"location": {"longitude": -4.776045, "latitude": 37.894249},
},
"items_available": 0,
"distance": 0.0,
"favorite": True,
"in_sales_window": False,
"new_item": False,
}
],
"milestones": [
{"type": "MEALS_SAVED", "value": "500"},
{"type": "MONTHS_ON_PLATFORM", "value": "6"},
],
"we_care": False,
},
"display_name": "Ecofamily Buf\xc3\xa9 - Centro",
"pickup_location": {
"address": {
"country": {"iso_code": "ES", "name": "Spain"},
"address_line": "Av. de los Piconeros, S/N, 14001 C\xc3\xb3rdoba, Espa\xc3\xb1a",
"city": "",
"postal_code": "",
},
"location": {"longitude": -4.776045, "latitude": 37.894249},
},
"items_available": 0,
"distance": 0.0,
"favorite": True,
"in_sales_window": False,
"new_item": False,
}
Set favorite
(Using item_id from get_items response)
# add favorite
client.set_favorite(item_id=64346, is_favorite=True)
# remove favorite
client.set_favorite(item_id=64346, is_favorite=False)
Create an account
from tgtg import TgtgClient
client = TgtgClient(email="test@test.com", password="password", name="name")
# client is now ready to be used
Developers
This project uses poetry so you will need to install poetry locally to use following commands.
pip install poetry --user
poetry install
This project uses pre-commit to format/check all the code before each commit automatically.
pip install pre-commit --user
pre-commit install
Run this command to run all tests:
make test
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tgtg-0.6.0.tar.gz.
File metadata
- Download URL: tgtg-0.6.0.tar.gz
- Upload date:
- Size: 7.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.7 CPython/3.9.5 Linux/5.13.0-7614-generic
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6cb0a94b8095e0e222c552ff996cde5d21229964202e6a12fcc83e50f9559047
|
|
| MD5 |
24e67495f56494c287e6315c480bab0f
|
|
| BLAKE2b-256 |
82b7af1c43c0f7aa6ca51fe6e11634975ab523b5439a679a2ea70eb0d0a19164
|
File details
Details for the file tgtg-0.6.0-py3-none-any.whl.
File metadata
- Download URL: tgtg-0.6.0-py3-none-any.whl
- Upload date:
- Size: 5.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.7 CPython/3.9.5 Linux/5.13.0-7614-generic
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
558dc753ae41dfbcd5acbe46719162979510218f0b62dd74a8072874445c51d9
|
|
| MD5 |
f0eed8eece51e4db97554b55f66c0b39
|
|
| BLAKE2b-256 |
265a75ffc2572779a0af04326c2f1ee7941b95bbef3830e59d6af51f66a93905
|