|
| 1 | +# clifood |
| 2 | + |
| 3 | +API-first CLI for iFood. It uses your authenticated browser session to call iFood’s internal APIs directly (search, catalog, cart, discovery) and only opens pages for login/address setup and checkout review. No UI scraping is required. |
| 4 | + |
| 5 | +## Quick start |
| 6 | + |
| 7 | +```bash |
| 8 | +bun install |
| 9 | +# Optional: install Playwright's bundled browser |
| 10 | +bunx playwright install chromium |
| 11 | + |
| 12 | +# Run a quick restaurant search (API) |
| 13 | +bun src/cli.ts restaurants --query "pizza" --limit 5 --json |
| 14 | +``` |
| 15 | + |
| 16 | +## Use your existing logged-in browser (recommended) |
| 17 | + |
| 18 | +Start Chrome with remote debugging enabled, then point the CLI to it: |
| 19 | + |
| 20 | +```bash |
| 21 | +/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome \ |
| 22 | + --remote-debugging-port=9222 \ |
| 23 | + --user-data-dir="$HOME/.clifood/chrome-profile" |
| 24 | + |
| 25 | +# Then run |
| 26 | +bun src/cli.ts restaurants --query "japonesa" --cdp-url http://127.0.0.1:9222 |
| 27 | +``` |
| 28 | + |
| 29 | +This keeps your existing iFood login and address selection. All API calls are executed from your authenticated browser context to avoid bot blocks. |
| 30 | + |
| 31 | +## Commands |
| 32 | + |
| 33 | +### Open iFood (manual setup) |
| 34 | + |
| 35 | +```bash |
| 36 | +bun src/cli.ts open --wait |
| 37 | +``` |
| 38 | + |
| 39 | +Use this to log in or set your delivery address in the connected browser profile. |
| 40 | + |
| 41 | +### Search restaurants |
| 42 | + |
| 43 | +```bash |
| 44 | +bun src/cli.ts restaurants --query "sushi" --limit 10 |
| 45 | +``` |
| 46 | + |
| 47 | +Exclude categories or names: |
| 48 | + |
| 49 | +```bash |
| 50 | +bun src/cli.ts restaurants --query "a" --exclude pizza --exclude hamburguer --exclude doces --limit 10 |
| 51 | +``` |
| 52 | + |
| 53 | +Shortcut: |
| 54 | + |
| 55 | +```bash |
| 56 | +bun src/cli.ts restaurants --query "a" --exclude-defaults --limit 10 |
| 57 | +``` |
| 58 | + |
| 59 | +Top restaurants (discovery feed, no search term): |
| 60 | + |
| 61 | +```bash |
| 62 | +bun src/cli.ts restaurants --top --exclude-defaults --limit 10 |
| 63 | +``` |
| 64 | + |
| 65 | +### Search items in a restaurant |
| 66 | + |
| 67 | +```bash |
| 68 | +bun src/cli.ts items --restaurant "Restaurante X" --query "temaki" --limit 10 |
| 69 | +``` |
| 70 | + |
| 71 | +You can also pass a full iFood restaurant URL with `--restaurant`. |
| 72 | + |
| 73 | +### Place an order |
| 74 | + |
| 75 | +```bash |
| 76 | +bun src/cli.ts order \ |
| 77 | + --restaurant "Restaurante X" \ |
| 78 | + --item "Temaki de salmão:2" \ |
| 79 | + --item "Guioza" \ |
| 80 | + --confirm |
| 81 | +``` |
| 82 | + |
| 83 | +Safety: without `--confirm`, the CLI opens checkout but does **not** submit the order. |
| 84 | + |
| 85 | +## Configuration |
| 86 | + |
| 87 | +Config lives at `~/.clifood/config.json`. You can also override via CLI flags or environment variables. |
| 88 | + |
| 89 | +```bash |
| 90 | +bun src/cli.ts config show |
| 91 | +bun src/cli.ts config set cdpUrl http://127.0.0.1:9222 |
| 92 | +bun src/cli.ts config set headless false |
| 93 | +``` |
| 94 | + |
| 95 | +Supported keys: `cdpUrl`, `profileDir`, `headless`, `slowMo`, `locale`, `timeoutMs`. |
| 96 | + |
| 97 | +Environment overrides: |
| 98 | + |
| 99 | +- `IFOOD_CDP_URL` |
| 100 | +- `IFOOD_PROFILE_DIR` |
| 101 | +- `IFOOD_HEADLESS` |
| 102 | +- `IFOOD_SLOW_MO` |
| 103 | +- `IFOOD_LOCALE` |
| 104 | +- `IFOOD_TIMEOUT_MS` |
| 105 | + |
| 106 | +## Notes |
| 107 | + |
| 108 | +- The CLI is API-first and depends on a valid logged-in browser session. |
| 109 | +- Some menu items require mandatory option choices; the CLI auto-selects minimum required options from the catalog data. |
| 110 | +- Read `docs/architecture.md` for the exact API flow and data dependencies. |
| 111 | +- Read `docs/troubleshooting.md` if you hit auth or anti-bot issues. |
0 commit comments