A free, chapter-level (2-digit HS) view of India's merchandise exports and imports from the official Export-Import Data Bank, plus World Bank, NIRYAT and UN Comtrade collectors, stored in DuckDB.
Open-Source Tools · How-To · Agri & trade trackers
How to use india-trade-tracker: India chapter-wise exports and imports from official DGFT data
Revised
· v1.0.0 · what changed
Code: github.com/herrrickshaw/india-trade-tracker
Watch the walkthrough
Watch on YouTube: youtu.be/NY4CgXgSsT0
Why it is useful
- Exporters, policy students and analysts who want India's trade by product group without a paid vendor get a chapter-by-chapter table straight from the government's own data bank.
- It replaces repeated manual downloads from a JavaScript-heavy website: a Selenium collector handles the form and stores each pull in DuckDB with the pull date.
- The committed CSV snapshot already holds two financial years for both flows, so the demo ran with no browser and no network: 17 tests passed and the queries below took seconds.
- Evidence from the run: summing the chapters reproduced the official FY2024-25 totals the README cites (about US$ 438 bn exports, about US$ 721 bn imports).
What it is for
india-trade-tracker collects India's annual merchandise exports and imports by 2-digit HS chapter (US$ million, current and previous year, growth percent) from the DGFT / Department of Commerce Export-Import Data Bank, using headless Chrome because the site is JS-rendered.
It also pulls a World Bank trade indicator panel, bilateral monthly data and HS8 detail from the NIRYAT portal, and India chapter totals from the UN Comtrade public preview API.
Who it is for
- Students and researchers studying India's trade structure
- Exporters and consultants scanning which chapters are growing or shrinking
- Developers building trade dashboards
- Legal or customs-classification advice: this is not legal advice and not an official customs reference
- Shipment-level or company-level data (it is chapter totals, not bills of lading)
- Investment decisions: not investment advice
What you need
| Requirement | Why | How to get it |
|---|---|---|
| Python 3 with duckdb and selenium (pytest for tests) | requirements.txt lists duckdb and selenium | pip install -r requirements.txt |
| Google Chrome (only for live EIDB collection) | The EIDB site is JS-rendered, so the collector drives headless Chrome | Install Chrome; Selenium 4 fetches chromedriver itself. Not needed for the snapshot, the tests or the NIRYAT collectors |
| A terminal and git | To clone and run | Terminal on macOS/Linux, or Git Bash/WSL on Windows |
| No API keys or accounts | All sources are open | None needed |
Get the code and an AI assistant
You do not have to be a programmer. Get the repository, give it to an AI assistant, and ask in plain language. Any of these routes works:
| Tool | What you need | Best for |
|---|---|---|
| GitHub | Free account to fork or star; git to clone, or the green Code button, then Download ZIP, or open in Codespaces | Getting the code and keeping up with updates |
| Claude Code | Claude subscription or API key; run claude inside the cloned folder | Letting the AI read and run the whole repo |
| Gemini CLI | Google account; run gemini inside the cloned folder | The same hands-on workflow with Gemini |
| Claude.ai, Gemini or ChatGPT in the browser | A chat account; upload README.md and the files you care about (or paste the output of git ls-files) | Understanding the project and asking questions without installing anything |
| Other tools (Copilot Chat, Cursor, Codex CLI) | Open the cloned folder in the tool and point it at README.md first | Editing and extending the code |
git clone https://github.com/herrrickshaw/india-trade-tracker.git
cd india-trade-tracker
claude # or: gemini
Install
- Clone and enter the repo
git clone https://github.com/herrrickshaw/india-trade-tracker.git cd india-trade-tracker - Create a virtual environment and install dependencies
python3 -m venv .venv && source .venv/bin/activate pip install -r requirements.txt pytest
Quick start: commands and what you should see
Run the test suite (no browser or network needed)
python -m pytest -q
17 passed in about 1.5 seconds.
Pull a financial year live from EIDB (needs Chrome and network; not run in this demo)
python3 collectors/eidb_trade.py --year 2024
Chapter rows for exports and imports are written to data/trade.duckdb.
Query the committed snapshot with DuckDB
python3 -c "import duckdb; print(duckdb.sql(\"select flow, fy_start, count(*) chapters, round(sum(cur_year_usd_mn)) usd_mn from read_csv_auto('data/eidb_chapter_trade_snapshot.csv') group by all order by 1,2\"))"
Four rows (exports and imports for two financial years), 97 chapters each.
Sample outputs
Real output from a run on the date shown in the sources line; trimmed to fit.
Totals by flow and financial year (sum of chapters, US$ million)
group the snapshot by flow, fy_start
flow fy_start chapters usd_mn
exports 2024 97 437,685
exports 2025 97 441,427
imports 2024 97 721,174
imports 2025 97 775,689
Implied balance: FY2024-25 -283,489; FY2025-26 -334,262
fy_start 2024 means FY2024-25. FY2024-25 was pulled 21 Jul 2026 and FY2025-26 on 15 Sep 2026.
Top export chapters, FY2025-26 (US$ million)
flow='exports', fy_start=2025, order by cur_year_usd_mn desc
27 Mineral fuels, oils 55,871 (-16.7%)
85 Electrical machinery 53,976 (+22.5%)
84 Nuclear reactors, machinery 36,630 (+9.4%)
71 Pearls, precious stones 28,344 (-5.4%)
87 Vehicles (non-rail) 25,973 (+14.7%)
Growth is versus FY2024-25, as reported by the source.
Top import chapters, FY2025-26 (US$ million)
flow='imports', fy_start=2025, order by cur_year_usd_mn desc
27 Mineral fuels, oils 203,416 (-6.9%)
71 Pearls, precious stones 109,429 (+23.0%)
85 Electrical machinery 104,825 (+18.3%)
84 Nuclear reactors, machinery 74,002 (+15.1%)
29 Organic chemicals 25,411 (-4.4%)
Mineral fuels is the largest line on both sides of the ledger.
Ways to use it
| Method | How it works |
|---|---|
| Command line collectors | Run collectors/eidb_trade.py for EIDB, worldbank_trade.py, niryat_bilateral.py, niryat_hs8.py or comtrade_chapters.py; each writes to data/trade.duckdb. |
| SQL on the CSV snapshots | Read the committed CSVs under data/ directly with DuckDB or pandas. |
| Colab notebook | The README links a Colab notebook for a no-install try-out. |
| Through an AI assistant | Open the cloned folder in Claude Code or Gemini CLI and ask for tables or charts in plain English, or upload README.md and the snapshot CSV to a chat assistant. |
Sample prompts for your AI assistant
Copy, paste and edit the parts in [brackets].
- Explain this repository in plain English: what trade data does it collect and from where?
- From data/eidb_chapter_trade_snapshot.csv, list the five fastest-growing import chapters in FY2025-26 with value above US$ 5 billion.
- Build a trade-balance-by-chapter table for FY2025-26 by joining exports and imports on hs_code, and chart the biggest deficits.
- Read README.md and tell me what each collector needs (Chrome, network, keys) and which ones I can run without a browser.
- Compare the chapter totals in the snapshot with the World Bank trade indicators and explain any differences in definition.
Limits and honest caveats
- Not legal advice and not an official statistic; figures are as published by the Department of Commerce data bank and may be revised.
- I did not run the live EIDB collector (needs Chrome and network). Outputs shown come from the committed snapshot and the test suite, run 19 Oct 2026.
- The snapshot holds only two financial years (FY2024-25 and FY2025-26) at 2-digit chapter level; the FY2025-26 pull was made on 15 Sep 2026, so check how complete that year is before relying on it.
- Chapter totals are annual; monthly series and 4/6/8-digit drill-down are on the README roadmap. NIRYAT HS8 data exists but is limited to a few partner countries.
- The NIRYAT collector disables TLS verification because of a certificate mismatch on that site, per the README; understand that trade-off before using it.
- The 'sum of chapters' totals are my aggregation of the committed rows.
Sources: the india-trade-tracker README, tests and data/eidb_chapter_trade_snapshot.csv; pytest and DuckDB queries run on 19 October 2026 on a fresh clone.
- v1.0.0 — 19 October 2026 — first published.
About this article: Researched, written and edited by Umashankar Triplicane Dwarakanathan, with AI research assistance; every figure is meant to trace to the primary source cited. See the Editorial Policy for how sourcing, AI use and corrections work.