26. How to Read APIs, JSON and Zipped CSVs into pandas
Chala mitrano, CSV drive var nestana — kahi data API JSON madhun yeto, kahi .csv.zip email attachment. Aaj requests + JSON + json_normalize, read_json, ani zipped CSV. Model nahi. Secrets notebook madhe paste naka.
What you will learn in this chapter
- Why analysts pull APIs and zips (not only flat CSV)
- Safe
requests.gethabits (timeout, status code, secrets) - JSON → DataFrame with
json_normalize/read_json - Nested lists of dicts (orders inside a payload)
- Reading
.csv.zip/ compression in pandas - Common mistakes: no timeout, huge downloads, wrong record path
- A fictional Blinkit-style practice lab
Fictional data
Blinkit / Amazon Now figures and API hosts in this chapter are fictional classroom samples. They do not show real company numbers or real production URLs. People names are for practice; e-mails use example.com. Never paste live API keys into a notebook you share or commit.
Concepts in this chapter
- 26.1Why APIs, JSON and Zips
- 26.2requests Basics: Timeout and Status
- 26.3JSON into a DataFrame
- 26.4Nested and Paged Payloads (Keep It Light)
- 26.5Zipped CSVs into pandas
- 26.6Common Mistakes
- 26.7Practice, Tip and Close
The chapter recap is at the end of the last concept page.