Minimal, production-lean script to demonstrate real REST API integration using Python 3.11+, requests, and pandas. Fetches the latest ~30 daily candles from a public REST endpoint, converts timestamps to IST, saves to CSV, and prints a sample to the terminal. Provider-agnostic by design (no SDKs).
- Python 3.11+
- Packages:
requests,pandas
Install packages:
python -m pip install --upgrade pip
python -m pip install requests pandaspython api_automation.py --symbol BTCUSDT --interval 1d --limit 30 --output results/data.csv- Default values:
symbol=BTCUSDT,interval=1d,limit=30,output=results/data.csv. - The script creates
results/if not present. - Timestamps are saved in IST (Asia/Kolkata).
- Calls a real REST API (baseline: Binance klines) via HTTP GET (no SDKs).
- Parses JSON into a typed
pandasDataFrame with columns:open_time,open,high,low,close,volume,close_time. - Converts timestamps to timezone-aware IST.
- Validates basic data quality (row count, nulls, monotonic time).
- Saves to CSV and prints a
head()preview.
- Change the base URL and query parameters.
- Update the response-to-columns mapping in the script where indicated.
- All other steps (validation, timezone conversion, CSV save, printing) remain the same.
- Terminal run showing the printed
head()preview. - A CSV preview (first ~10 rows) from your editor/spreadsheet viewer.
- This demo intentionally excludes indicators, backtests, databases, and schedulers to stay minimal and focused on API + data handling.