{"id":26658253,"url":"https://github.com/ltbringer/swiggy-order","last_synced_at":"2025-04-11T13:07:58.904Z","repository":{"id":99060980,"uuid":"324575649","full_name":"ltbringer/swiggy-order","owner":"ltbringer","description":"Order food via terminal.","archived":false,"fork":false,"pushed_at":"2020-12-29T07:29:45.000Z","size":925,"stargazers_count":15,"open_issues_count":0,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-25T09:19:03.948Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ltbringer.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2020-12-26T14:50:02.000Z","updated_at":"2025-01-29T04:15:35.000Z","dependencies_parsed_at":null,"dependency_job_id":"1d3b69f5-d3e9-478f-8238-f231d2806299","html_url":"https://github.com/ltbringer/swiggy-order","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ltbringer%2Fswiggy-order","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ltbringer%2Fswiggy-order/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ltbringer%2Fswiggy-order/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ltbringer%2Fswiggy-order/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ltbringer","download_url":"https://codeload.github.com/ltbringer/swiggy-order/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248404590,"owners_count":21097779,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-03-25T09:19:08.146Z","updated_at":"2025-04-11T13:07:58.889Z","avatar_url":"https://github.com/ltbringer.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# swiggy-order\n\nI can't cook. It is a craft that needs patience, creativity and time. I am very short on time and no amount of youtube training yields the same taste that money can buy. That clears a part of this project's goal - _buying food_. \n\n_but why write code? aren't there apps already working hard for it?_\nYes, they are working too hard and they are damn good at their job. I am trying to keep myself fit since 2nd November 2019, a day when I woke up with a pain so sharp in my back that I felt I wouldn't stand up again. Luckily, it wasn't that bad but it hurt for weeks. I promised myself never again. That meant quitting a lifestyle of having desserts 3X a day and not working out at all. \n\nI started training for MMA and that somehow took care of my sugar cravings. I could easily avoid desserts and feel nothing, no cravings, no regrets. 23rd March 2020, India annouced a lockdown to prevent the spread of covid19. This meant I had to train at home and that wasn't supposed to work (No sparring no fun). I noticed I was getting tempted every once in a while and ordering slices of cakes with ice creams and shakes. I knew where this was headed.\n\nI have tried uninstalling swiggy and in no more than 3 days I install it back. If I could tell the app to not recommend certain items, I could make that work too. Since that isn't the case. I made this. If this helps you; continue using it, you owe me nothing. It is just a bunch of API integrations.\n\n## Thought Process\n- I decided to keep a list of my healthy buys and set this project to protect myself from my gluttony. \n- Integrate apis so that ordering food can happen via terminal and I don't have to browse. An additional plus is browsing can take 10 - 15 minutes without bringing any difference in my choices.\n- Set up Swiggy money with a monthly quota so that I don't burn through my pocket.\n\n## Installation and Usage\n```\npip install swiggy-order\norder-food --config=/path/to/config.json [--coupon-code=\u003c?\u003e] [--log-level=DEBUG]\n```\n\n## Config\nA very minimal `config.json` example:\n```python\n{\n  \"registered_phone\":\"\u003c10-digit-phone-number\u003e\",\n  \"address_id\":\"\u003caddress-id\u003e\",\n  \"menu\":[\n    {\n      \"name\":\"\u003cHowever you want to remember a dish\u003e\",\n      \"payload\":{...}\n    }]\n}\n```\nThere is a [config.json](./config.json) provided with this code for reference, and if you live near me you can get that cheesecake delivered 😄.\n\n### Payload\nAn example payload looks like this:\n```python\n{\n    \"flushFirst\":0,\n    \"cart\":{\n        \"restaurantId\":\"\u003cint\u003e\",\n        \"address_id\":\"\u003cstr\u003e\",\n        \"couponCode\": \"\u003cstr\u003e\",\n        \"cartItems\":[\n        {\n            \"addons\":[\n            \n            ],\n            \"variants\":[\n            \n            ],\n            \"menu_item_id\":\"\u003cint\u003e\",\n            \"quantity\":\"\u003cint\u003e\"\n        }\n        ],\n        \"mealItems\":[\n        \n        ],\n        \"subscriptionItems\":[\n        \n        ]\n    },\n    \"_csrf\": \"\u003cstr\u003e\" # this is managed by this project, you can leave it empty or let it have its value when copied. The project will set it right.\n    }\n}\n```\nThis can be obtained via opening the network tab and monitoring the response for the `POST` requests on `https://www.swiggy.com/dapi/cart` API, when an item is selected from the menu and it shows up in the cart. The reason for copying the payload is to prevent code changes if the API structure / restaurant-ids / menu-item-ids / ??? were to change. The open sourced nature of this tool means fixing such issues is a matter of PRs but it didn't occur to me as time well spent. None of the changes I can forsee would be frequent, so changing the `config.json` seems to be much more time efficient than changing the code.\n\n![Payload appears after clicking the ADD button](./images/click_add_button.png)\n\nPayload appears after clicking the ADD button\n\n![payload for behrouz biryani](./images/payload_behrouz_biryani.png)\nPayload for adding this dish from behrouz biryani to your cart 🍛. You can add an entry in `config.json` as:\n\n```json\n{\n    \"menu\": [{\n        \"name\": \"biryani boneless\",\n        \"payload\": \"\u003cPASTE_HERE\u003e\"\n    }]\n}\n```\nOnce added you can retain the items in a list.\n\n### Address\n`address_id` can be found through the web-interface, monitor the response for the `POST` requests on `https://www.swiggy.com/dapi/cart` API when trying to click the \"DELIVER HERE\" button, post the checkout phase. 🗺\n\n![Address updates after clicking the DELIVER HERE button](./images/deliver_here.png)\n\nAddress updates after clicking the DELIVER HERE button 👆\n\n![Look at updated address_id](./images/payload_behrouz_biryani.png)\nNotice the updated value of `address_id`. This can be kept within `config.json`, should be a one time addition.\n\n### Payment Method\nCurrently, this project assumes that payments are made via swiggy money only. I didn't want to solve for every payment method, those would anyway require callbacks to ensure safety. That is a lot of work and somehow there is a server someone needs to maintain. 💳💸\n\n## Demo\n![Demo](./images/demo.png)\n\n- Run the script with a coupon code.\n- Select item(s) to order. Do note I haven't written any code to exclude items from different outlets.\n- Provide the OTP from your registered mobile number. You would have to do this everytime, as long as this runs as a script.\n\n![Result](./images/result.png)\n\n## Fin\nEat well my friends. It will show as you age, I can already feel the difference from my 20s and I am not even 30 yet.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fltbringer%2Fswiggy-order","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fltbringer%2Fswiggy-order","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fltbringer%2Fswiggy-order/lists"}