@pencil-agent/nano-pencil 2.0.1 → 2.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (186) hide show
  1. package/README.md +267 -267
  2. package/dist/build-meta.json +3 -3
  3. package/dist/core/export-html/AGENT.md +11 -11
  4. package/dist/core/export-html/template.css +971 -971
  5. package/dist/core/export-html/template.html +54 -54
  6. package/dist/core/model/custom-providers.js +1 -1
  7. package/dist/core/model-registry.js +5 -5
  8. package/dist/extensions/builtin/AGENT.md +115 -115
  9. package/dist/extensions/builtin/browser/AGENT.md +17 -17
  10. package/dist/extensions/builtin/browser/agent-workspace/agent_helpers.py +12 -12
  11. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/amazon/product-search.md +198 -198
  12. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/archive-org/scraping.md +341 -341
  13. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/arxiv/scraping.md +311 -311
  14. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/arxiv-bulk/scraping.md +333 -333
  15. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/atlas/overview.md +70 -70
  16. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/booking-com/scraping.md +578 -578
  17. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/capterra/scraping.md +440 -440
  18. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/centilebrain/generate-estimates.md +110 -110
  19. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/coingecko/scraping.md +325 -325
  20. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/coinmarketcap/scraping.md +463 -463
  21. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/coursera/scraping.md +360 -360
  22. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/craigslist/scraping.md +390 -390
  23. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/crossref/scraping.md +568 -568
  24. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/dev-to/scraping.md +323 -323
  25. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/duckduckgo/scraping.md +349 -349
  26. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/ebay/scraping.md +435 -435
  27. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/etsy/scraping.md +506 -506
  28. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/eventbrite/scraping.md +363 -363
  29. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/expedia/automation.md +168 -168
  30. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/facebook/groups.md +236 -236
  31. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/facebook/pages.md +295 -295
  32. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/framer/editor.md +108 -108
  33. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/fred/scraping.md +493 -493
  34. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/g2/scraping.md +580 -580
  35. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/genius/scraping.md +511 -511
  36. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/github/repo-actions.md +65 -65
  37. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/github/scraping.md +184 -184
  38. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/glassdoor/scraping.md +543 -543
  39. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/gmail/compose.md +122 -122
  40. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/goodreads/scraping.md +461 -461
  41. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/gutenberg/scraping.md +383 -383
  42. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/hackernews/scraping.md +243 -243
  43. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/howlongtobeat/scraping.md +473 -473
  44. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/imdb/scraping.md +271 -271
  45. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/itch-io/scraping.md +436 -436
  46. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/job-boards/indeed-glassdoor.md +1021 -1021
  47. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/letterboxd/scraping.md +349 -349
  48. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/linkedin/invitation-manager.md +109 -109
  49. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/loom/folder-enumeration.md +170 -170
  50. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/macrotrends/scraping.md +537 -537
  51. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/medium/article-hydration.md +120 -120
  52. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/medium/scraping.md +414 -414
  53. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/metacritic/scraping.md +477 -477
  54. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/musicbrainz/scraping.md +478 -478
  55. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/nasa/scraping.md +339 -339
  56. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/news-aggregation/multi-source.md +205 -205
  57. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/open-library/scraping.md +472 -472
  58. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/openalex/scraping.md +470 -470
  59. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/openstreetmap/scraping.md +490 -490
  60. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/package-registries/npm-pypi.md +478 -478
  61. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/polymarket/scraping.md +234 -234
  62. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/producthunt/scraping.md +307 -307
  63. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/pubmed/scraping.md +421 -421
  64. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/quora/scraping.md +364 -364
  65. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/rawg/scraping.md +352 -352
  66. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/reddit/scraping.md +124 -124
  67. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/rest-countries/scraping.md +233 -233
  68. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/sec-edgar/scraping.md +361 -361
  69. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/shopify-admin/README.md +36 -36
  70. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/shopify-admin/embedded-apps.md +72 -72
  71. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/shopify-admin/knowledge-base.md +109 -109
  72. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/shopify-admin/polaris-inputs.md +137 -137
  73. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/soundcloud/scraping.md +362 -362
  74. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/spotify/scraping.md +339 -339
  75. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/stackoverflow/scraping.md +435 -435
  76. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/steam/scraping.md +575 -575
  77. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/substack/scraping.md +338 -338
  78. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/thetechgeeks/pricing.md +52 -52
  79. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/tiktok/upload.md +107 -107
  80. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/tradingview/scraping.md +309 -309
  81. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/trello/boards-and-lists.md +88 -88
  82. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/trustpilot/scraping.md +375 -375
  83. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/walmart/scraping.md +444 -444
  84. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/wayback-machine/scraping.md +306 -306
  85. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/weather/scraping.md +398 -398
  86. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/wellfound/scraping.md +596 -596
  87. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/world-bank/scraping.md +356 -356
  88. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/xiaohongshu/scraping.md +84 -84
  89. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/youtube/scraping.md +418 -418
  90. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/zillow/scraping.md +433 -433
  91. package/dist/extensions/builtin/browser/browser.md +73 -73
  92. package/dist/extensions/builtin/browser/install.md +142 -142
  93. package/dist/extensions/builtin/browser/interaction-skills/connection.md +48 -48
  94. package/dist/extensions/builtin/browser/interaction-skills/cookies.md +3 -3
  95. package/dist/extensions/builtin/browser/interaction-skills/cross-origin-iframes.md +3 -3
  96. package/dist/extensions/builtin/browser/interaction-skills/dialogs.md +64 -64
  97. package/dist/extensions/builtin/browser/interaction-skills/downloads.md +3 -3
  98. package/dist/extensions/builtin/browser/interaction-skills/drag-and-drop.md +3 -3
  99. package/dist/extensions/builtin/browser/interaction-skills/dropdowns.md +3 -3
  100. package/dist/extensions/builtin/browser/interaction-skills/iframes.md +3 -3
  101. package/dist/extensions/builtin/browser/interaction-skills/network-requests.md +3 -3
  102. package/dist/extensions/builtin/browser/interaction-skills/print-as-pdf.md +3 -3
  103. package/dist/extensions/builtin/browser/interaction-skills/profile-sync.md +90 -90
  104. package/dist/extensions/builtin/browser/interaction-skills/screenshots.md +17 -17
  105. package/dist/extensions/builtin/browser/interaction-skills/scrolling.md +3 -3
  106. package/dist/extensions/builtin/browser/interaction-skills/shadow-dom.md +3 -3
  107. package/dist/extensions/builtin/browser/interaction-skills/tabs.md +69 -69
  108. package/dist/extensions/builtin/browser/interaction-skills/uploads.md +1 -1
  109. package/dist/extensions/builtin/browser/interaction-skills/viewport.md +3 -3
  110. package/dist/extensions/builtin/browser/src/browser_harness/AGENT.md +15 -15
  111. package/dist/extensions/builtin/browser/src/browser_harness/__init__.py +8 -8
  112. package/dist/extensions/builtin/browser/src/browser_harness/_ipc.py +90 -90
  113. package/dist/extensions/builtin/browser/src/browser_harness/admin.py +722 -722
  114. package/dist/extensions/builtin/browser/src/browser_harness/daemon.py +328 -328
  115. package/dist/extensions/builtin/browser/src/browser_harness/helpers.py +396 -396
  116. package/dist/extensions/builtin/browser/src/browser_harness/run.py +103 -103
  117. package/dist/extensions/builtin/discipline/skills/brainstorming/SKILL.md +33 -33
  118. package/dist/extensions/builtin/discipline/skills/executing-plans/SKILL.md +25 -25
  119. package/dist/extensions/builtin/discipline/skills/finishing-development-branch/SKILL.md +25 -25
  120. package/dist/extensions/builtin/discipline/skills/receiving-code-review/SKILL.md +22 -22
  121. package/dist/extensions/builtin/discipline/skills/requesting-code-review/SKILL.md +31 -31
  122. package/dist/extensions/builtin/discipline/skills/systematic-debugging/SKILL.md +28 -28
  123. package/dist/extensions/builtin/discipline/skills/test-driven-development/SKILL.md +32 -32
  124. package/dist/extensions/builtin/discipline/skills/using-git-worktrees/SKILL.md +25 -25
  125. package/dist/extensions/builtin/discipline/skills/verification-before-completion/SKILL.md +27 -27
  126. package/dist/extensions/builtin/discipline/skills/writing-plans/SKILL.md +26 -26
  127. package/dist/extensions/builtin/goal/README.md +67 -67
  128. package/dist/extensions/builtin/grub/README.md +112 -112
  129. package/dist/extensions/builtin/link-world/agent-workspace/README.md +16 -16
  130. package/dist/extensions/builtin/link-world/internet-search/internet-search.md +65 -65
  131. package/dist/extensions/builtin/link-world/link-world-agent.md +82 -82
  132. package/dist/extensions/builtin/link-world/linkworld.md +313 -313
  133. package/dist/extensions/builtin/link-world/network-routing/network-routing.md +67 -67
  134. package/dist/extensions/builtin/loop/README.md +92 -92
  135. package/dist/extensions/builtin/mcp/figma-design.md +68 -68
  136. package/dist/extensions/builtin/mcp/mcp-management.md +85 -85
  137. package/dist/extensions/builtin/recap/AGENT.md +15 -15
  138. package/dist/extensions/builtin/sal/README.md +72 -72
  139. package/dist/extensions/builtin/security-audit/README.md +289 -289
  140. package/dist/extensions/builtin/team/AGENT.md +112 -112
  141. package/dist/extensions/builtin/team/TESTING.md +299 -299
  142. package/dist/extensions/builtin/token-save/README.md +56 -56
  143. package/dist/extensions/optional/AGENT.md +10 -10
  144. package/dist/modes/interactive/controllers/input-submit-controller.js +2 -2
  145. package/dist/modes/interactive/controllers/stream-render-controller.js +2 -2
  146. package/dist/modes/interactive/interactive-mode.js +19 -19
  147. package/dist/modes/interactive/theme/dark.json +85 -85
  148. package/dist/modes/interactive/theme/light.json +84 -84
  149. package/dist/modes/interactive/theme/theme-schema.json +335 -335
  150. package/dist/modes/interactive/theme/warm.json +81 -81
  151. package/dist/node_modules/@pencil-agent/ai/dist/cli.js +0 -0
  152. package/dist/node_modules/@pencil-agent/ai/dist/models.generated.js +1 -1
  153. package/docs/ACP/345/215/217/350/256/256/351/233/206/346/210/220/345/274/200/345/217/221/346/226/207/346/241/243.md +851 -0
  154. package/docs/SDK-TESTING.md +364 -0
  155. package/docs/codex-goal-command-impl.md +1055 -1055
  156. package/docs/codex-goal-vs-grub.md +500 -500
  157. package/docs/custom-provider.md +27 -27
  158. package/docs/extensions.md +27 -27
  159. package/docs/keybindings.md +27 -27
  160. package/docs/loop /351/207/215/346/236/204/345/256/214/346/210/220/346/200/273/347/273/223.md" +250 -250
  161. package/docs/loop /351/207/215/346/236/204/345/256/214/346/210/220/346/212/245/345/221/212.md" +122 -122
  162. package/docs/loop /351/207/215/346/236/204/346/226/271/346/241/210.md" +1222 -1222
  163. package/docs/loop /351/207/215/346/236/204/346/226/271/346/241/210/345/256/236/347/216/260/346/212/245/345/221/212.md" +158 -158
  164. package/docs/loop /351/207/215/346/236/204/346/226/271/346/241/210/345/257/271/346/257/224/345/210/206/346/236/220.md" +128 -128
  165. package/docs/loop /351/207/215/346/236/204/350/256/241/345/210/222.md" +320 -320
  166. package/docs/loop-usage-examples.md +214 -214
  167. package/docs/mem-core/346/212/200/346/234/257/346/226/207/346/241/243.md +593 -0
  168. package/docs/models.md +27 -27
  169. package/docs/packages.md +27 -27
  170. package/docs/pi-design-philosophy.md +457 -457
  171. package/docs/planmode.md +1987 -1987
  172. package/docs/prompt-templates.md +27 -27
  173. package/docs/providers.md +27 -27
  174. package/docs/sdk.md +27 -27
  175. package/docs/skills.md +27 -27
  176. package/docs/startup-performance-optimization.md +301 -0
  177. package/docs/themes.md +27 -27
  178. package/docs/tui.md +27 -27
  179. package/docs//350/256/244/347/237/245/345/234/260/345/233/276.md +47 -0
  180. package/package.json +190 -190
  181. package/docs/cc-agent-design.md +0 -1297
  182. package/docs/cc-tui-design.md +0 -1333
  183. package/docs/nanoPencil-/345/255/246/344/271/240/350/256/241/345/210/222.md +0 -170
  184. package/docs/scan-report.md +0 -3820
  185. package/docs//345/257/271/346/240/207Claude-Code.md +0 -1775
  186. package/docs//351/230/277/351/207/214/345/267/264/345/267/264/350/264/242/346/212/245/345/210/206/346/236/220/344/271/246.md +0 -261
@@ -1,356 +1,356 @@
1
- # World Bank Open Data — Scraping & Data Extraction
2
-
3
- `https://api.worldbank.org/v2` — free REST API for global development indicators. No API key, no auth, no browser needed. All data via `http_get`.
4
-
5
- ## Do this first
6
-
7
- **Every response is a 2-element JSON array: `[metadata, data]`.** The metadata element is always at index 0 (pagination info); the data array is at index 1. This is the single biggest gotcha — `json.loads(raw)` gives you a list, not a dict.
8
-
9
- ```python
10
- from helpers import http_get
11
- import json
12
-
13
- raw = http_get("https://api.worldbank.org/v2/country/US/indicator/NY.GDP.MKTP.CD?format=json")
14
- d = json.loads(raw)
15
- meta = d[0] # {"page": 1, "pages": 2, "per_page": 50, "total": 66, ...}
16
- rows = d[1] # list of data records
17
- ```
18
-
19
- Always append `?format=json` — default response is XML.
20
-
21
- ## Common workflows
22
-
23
- ### Single country, single indicator
24
-
25
- ```python
26
- from helpers import http_get
27
- import json
28
-
29
- raw = http_get("https://api.worldbank.org/v2/country/US/indicator/NY.GDP.MKTP.CD?format=json")
30
- d = json.loads(raw)
31
- meta, rows = d[0], d[1]
32
-
33
- for r in rows:
34
- if r["value"] is not None: # recent years often have null values
35
- print(r["date"], r["value"])
36
- # Confirmed output (2026-04-18):
37
- # 2024 28750956130731.2
38
- # 2023 27292170793214.4
39
- # 2022 25604848907611.0
40
- # ...
41
- ```
42
-
43
- ### Most recent N values (`mrv` param)
44
-
45
- `mrv` (most recent values) skips null years and returns the N most recent non-provisional points.
46
-
47
- ```python
48
- from helpers import http_get
49
- import json
50
-
51
- raw = http_get(
52
- "https://api.worldbank.org/v2/country/US/indicator/NY.GDP.MKTP.CD"
53
- "?format=json&mrv=5"
54
- )
55
- d = json.loads(raw)
56
- for r in d[1]:
57
- print(r["date"], r["value"])
58
- # Confirmed output (2026-04-18):
59
- # 2024 28750956130731.2
60
- # 2023 27292170793214.4
61
- # 2022 25604848907611.0
62
- # 2021 23315080560000.0
63
- # 2020 21060473613000.0
64
- ```
65
-
66
- ### Multiple countries, date range
67
-
68
- Semicolon-delimit country codes in the URL path. Use `date=YYYY:YYYY` for a range.
69
-
70
- ```python
71
- from helpers import http_get
72
- import json
73
-
74
- raw = http_get(
75
- "https://api.worldbank.org/v2/country/US;CN;GB/indicator/SP.POP.TOTL"
76
- "?format=json&date=2000:2023&per_page=100"
77
- )
78
- d = json.loads(raw)
79
- meta, rows = d[0], d[1]
80
- print(f"Total records: {meta['total']}, pages: {meta['pages']}")
81
-
82
- for r in rows:
83
- print(r["country"]["value"], r["date"], r["value"])
84
- # Confirmed: returns 8 records per page (50 default), date range honored exactly
85
- # Countries: ['China', 'United States', 'United Kingdom']
86
- # Dates: ['2000', '2001', ..., '2023']
87
- ```
88
-
89
- ### All countries, latest value only
90
-
91
- Use `mrv=1` with `per_page=1000` to get all 266 countries in a single call.
92
-
93
- ```python
94
- from helpers import http_get
95
- import json
96
-
97
- raw = http_get(
98
- "https://api.worldbank.org/v2/country/all/indicator/NY.GDP.PCAP.CD"
99
- "?format=json&mrv=1&per_page=1000"
100
- )
101
- d = json.loads(raw)
102
- meta, rows = d[0], d[1]
103
- print(f"Countries returned: {len(rows)}") # 266 (includes aggregates)
104
-
105
- # Filter out regional aggregates — they have no iso2Code or have aggregate ids
106
- countries_only = [r for r in rows if len(r["country"]["id"]) == 2]
107
- for r in sorted(countries_only, key=lambda x: -(x["value"] or 0))[:5]:
108
- print(r["country"]["value"], r["date"], f"${r['value']:,.0f}")
109
- # Confirmed output (2026-04-18):
110
- # Luxembourg 2024 $135,605
111
- # Norway 2024 $105,056
112
- # ...
113
- ```
114
-
115
- ### Full pagination (fetch all pages)
116
-
117
- ```python
118
- from helpers import http_get
119
- import json
120
-
121
- def fetch_all_pages(base_url):
122
- """Fetch all pages of a World Bank API endpoint."""
123
- all_rows = []
124
- page = 1
125
- while True:
126
- url = f"{base_url}&page={page}" if "?" in base_url else f"{base_url}?page={page}"
127
- d = json.loads(http_get(url))
128
- meta, rows = d[0], d[1]
129
- all_rows.extend(rows)
130
- if page >= meta["pages"]:
131
- break
132
- page += 1
133
- return all_rows
134
-
135
- # Example: all US GDP data (66 years, 2 pages)
136
- rows = fetch_all_pages(
137
- "https://api.worldbank.org/v2/country/US/indicator/NY.GDP.MKTP.CD"
138
- "?format=json&per_page=50"
139
- )
140
- print(f"Total rows: {len(rows)}") # 66
141
- non_null = [(r["date"], r["value"]) for r in rows if r["value"] is not None]
142
- print(f"Non-null: {len(non_null)}, range: {non_null[-1][0]}–{non_null[0][0]}")
143
- ```
144
-
145
- ### Indicators list (discover available indicators)
146
-
147
- ```python
148
- from helpers import http_get
149
- import json
150
-
151
- raw = http_get("https://api.worldbank.org/v2/indicator?format=json&per_page=50")
152
- d = json.loads(raw)
153
- meta = d[0]
154
- print(f"Total indicators: {meta['total']}, pages: {meta['pages']}")
155
- # Confirmed: 29,511 indicators across 591 pages
156
-
157
- for ind in d[1][:3]:
158
- print(ind["id"], "-", ind["name"])
159
- # 1.0.HCount.1.90usd - Poverty Headcount ($1.90 a day)
160
- # ...
161
- ```
162
-
163
- ### Indicators by topic
164
-
165
- ```python
166
- from helpers import http_get
167
- import json
168
-
169
- # Topic 3 = Economy & Growth
170
- raw = http_get("https://api.worldbank.org/v2/topic/3/indicator?format=json&per_page=50")
171
- d = json.loads(raw)
172
- print(f"Economy & Growth indicators: {d[0]['total']}") # 306
173
-
174
- for ind in d[1][:5]:
175
- print(ind["id"], "-", ind["name"])
176
- ```
177
-
178
- ### Country metadata
179
-
180
- ```python
181
- from helpers import http_get
182
- import json
183
-
184
- raw = http_get("https://api.worldbank.org/v2/country/US?format=json")
185
- d = json.loads(raw)
186
- c = d[1][0]
187
- print(c["name"], c["capitalCity"], c["region"]["value"], c["incomeLevel"]["value"])
188
- # United States Washington D.C. North America High income
189
-
190
- # Filter countries by income level
191
- raw = http_get("https://api.worldbank.org/v2/country?format=json&incomeLevel=LIC&per_page=300")
192
- d = json.loads(raw)
193
- print(f"Low-income countries: {d[0]['total']}") # 25
194
- ```
195
-
196
- ### Topics list
197
-
198
- ```python
199
- from helpers import http_get
200
- import json
201
-
202
- raw = http_get("https://api.worldbank.org/v2/topics?format=json")
203
- d = json.loads(raw)
204
- for t in d[1]:
205
- print(t["id"], t["value"])
206
- # 1 Agriculture & Rural Development
207
- # 2 Aid Effectiveness
208
- # 3 Economy & Growth
209
- # ... (21 topics total)
210
- ```
211
-
212
- ### Parallel fetch for multiple indicators (ThreadPoolExecutor)
213
-
214
- ```python
215
- from helpers import http_get
216
- from concurrent.futures import ThreadPoolExecutor
217
- import json
218
-
219
- INDICATORS = {
220
- "NY.GDP.MKTP.CD": "GDP (current US$)",
221
- "SP.POP.TOTL": "Population",
222
- "NY.GDP.PCAP.CD": "GDP per capita",
223
- }
224
-
225
- def fetch_indicator(ind_id):
226
- url = (
227
- f"https://api.worldbank.org/v2/country/US/indicator/{ind_id}"
228
- f"?format=json&mrv=5"
229
- )
230
- d = json.loads(http_get(url))
231
- return ind_id, d[1]
232
-
233
- with ThreadPoolExecutor(max_workers=3) as ex:
234
- results = dict(ex.map(lambda i: fetch_indicator(i), INDICATORS))
235
-
236
- for ind_id, rows in results.items():
237
- latest = next((r for r in rows if r["value"] is not None), None)
238
- if latest:
239
- print(f"{INDICATORS[ind_id]}: {latest['date']} = {latest['value']:,.2f}")
240
- ```
241
-
242
- ## URL reference
243
-
244
- ### Base URL
245
-
246
- ```
247
- https://api.worldbank.org/v2
248
- ```
249
-
250
- HTTP redirects to HTTPS (302). Always use HTTPS directly.
251
-
252
- ### Endpoint patterns
253
-
254
- | Endpoint | Description |
255
- |---|---|
256
- | `/country/{code}/indicator/{id}` | Single country + indicator time series |
257
- | `/country/{c1};{c2};{c3}/indicator/{id}` | Multi-country (semicolon-delimited) |
258
- | `/country/all/indicator/{id}` | All countries |
259
- | `/country/{code}` | Country metadata |
260
- | `/country` | All countries metadata (filterable) |
261
- | `/indicator` | All indicators list |
262
- | `/indicator/{id}` | Single indicator metadata |
263
- | `/topic/{id}/indicator` | Indicators for a topic |
264
- | `/topics` | All topics |
265
-
266
- ### Query parameters
267
-
268
- | Parameter | Values | Notes |
269
- |---|---|---|
270
- | `format` | `json`, `xml` (default) | Always set `format=json` |
271
- | `per_page` | integer, default 50, max 1000 | Higher is faster for bulk |
272
- | `page` | integer, default 1 | For paginating results |
273
- | `date` | `2020`, `2000:2023` | Single year or colon-separated range |
274
- | `mrv` | integer | N most recent non-null values |
275
- | `gapfill` | `Y` | Forward-fill nulls when used with `mrv` |
276
- | `incomeLevel` | `LIC`, `MIC`, `HIC`, `LMC`, `UMC` | Filter countries by income |
277
- | `region` | `EAS`, `ECS`, `LAC`, `MEA`, `NAC`, `SAS`, `SSF` | Filter countries by region |
278
-
279
- ### Common indicator IDs (confirmed working, 2026-04-18)
280
-
281
- | ID | Name |
282
- |---|---|
283
- | `NY.GDP.MKTP.CD` | GDP (current US$) |
284
- | `NY.GDP.PCAP.CD` | GDP per capita (current US$) |
285
- | `SP.POP.TOTL` | Population, total |
286
- | `SL.UEM.TOTL.ZS` | Unemployment (% of labor force) |
287
- | `FP.CPI.TOTL.ZG` | Inflation, consumer prices (%) |
288
- | `NE.EXP.GNFS.ZS` | Exports of goods and services (% of GDP) |
289
- | `SP.DYN.LE00.IN` | Life expectancy at birth |
290
- | `SE.ADT.LITR.ZS` | Literacy rate, adult total (%) |
291
- | `EG.USE.PCAP.KG.OE` | Energy use per capita (kg of oil equiv.) |
292
-
293
- Find more: `https://api.worldbank.org/v2/indicator?format=json&per_page=50&page=N`
294
-
295
- ### Country codes (ISO2)
296
-
297
- Standard ISO 3166-1 alpha-2 codes: `US`, `CN`, `GB`, `DE`, `JP`, `IN`, `BR`, etc.
298
- Special: `all` for all countries.
299
-
300
- ## Response structure
301
-
302
- Every endpoint returns a 2-element array:
303
-
304
- ```json
305
- [
306
- {
307
- "page": 1,
308
- "pages": 2,
309
- "per_page": 50,
310
- "total": 66,
311
- "sourceid": "2",
312
- "lastupdated": "2026-04-08"
313
- },
314
- [
315
- {
316
- "indicator": {"id": "NY.GDP.MKTP.CD", "value": "GDP (current US$)"},
317
- "country": {"id": "US", "value": "United States"},
318
- "countryiso3code": "USA",
319
- "date": "2024",
320
- "value": 28750956130731.2,
321
- "unit": "",
322
- "obs_status": "",
323
- "decimal": 0
324
- },
325
- ...
326
- ]
327
- ]
328
- ```
329
-
330
- Country metadata endpoint returns same 2-element shape but with country objects (not indicator rows) at index 1.
331
-
332
- ## Gotchas
333
-
334
- - **Response is always a 2-element array, not a dict.** `d = json.loads(raw)` gives a list. `d[0]` is pagination metadata, `d[1]` is the data list. Accessing `d["page"]` raises `TypeError`. This is the most common mistake.
335
-
336
- - **`value` can be null.** Recent years (e.g. 2025) and data-sparse countries frequently have `null` values. Always check `if r["value"] is not None` before using. Use `mrv=N` to skip nulls automatically.
337
-
338
- - **Always append `?format=json`.** The default response format is XML. Without `format=json`, you get an XML string that fails `json.loads`.
339
-
340
- - **`all/indicator/{id}` includes regional aggregates.** The "all countries" endpoint returns 266 entries including aggregated regions like "Africa Eastern and Southern" (`id: "ZH"`). Filter to real countries with `len(r["country"]["id"]) == 2` (ISO2 codes are always 2 chars; aggregate codes are 2-3 chars but with non-standard values).
341
-
342
- - **Semicolons in URL path, not query string.** Multi-country requests use `country/US;CN;GB/indicator/...` not `?countries=US,CN,GB`. Commas do not work.
343
-
344
- - **HTTP 302 redirects HTTP to HTTPS.** Always use `https://` directly to avoid an extra round trip.
345
-
346
- - **`per_page` in metadata is sometimes a string, sometimes an integer.** The API returns `"per_page": "50"` (string) for some endpoints and `"per_page": 50` (int) for others. Don't compare with `==` without casting: `int(meta["per_page"])`.
347
-
348
- - **Invalid country codes return an error object, not a 2-element array.** A bad code gives `[{"message": [{"id": "120", "key": "Invalid value", ...}]}]` — a 1-element list with an error dict. Check `if isinstance(d[0], dict) and "message" in d[0]` before accessing `d[1]`.
349
-
350
- - **`mrv` + `gapfill=Y` forward-fills the latest value into future years.** If 2024 is the latest data point and `mrv=3`, `gapfill=Y` returns 2025 (the current year) with the 2024 value copied in. Useful for "current" lookups, but the filled date is misleading.
351
-
352
- - **No rate limit documented, but 3 req/s sustained is safe.** The API handles bursts (parallel ThreadPoolExecutor with `max_workers=3`) without issue. For crawling thousands of indicators, add `time.sleep(0.5)` between pages.
353
-
354
- - **`date` range returns records newest-first.** Results within a date range are sorted descending by year. If you need ascending order, sort after fetching: `sorted(rows, key=lambda r: r["date"])`.
355
-
356
- - **Indicator IDs are case-sensitive.** `ny.gdp.mktp.cd` returns an error; use the uppercase dot-separated form `NY.GDP.MKTP.CD`.
1
+ # World Bank Open Data — Scraping & Data Extraction
2
+
3
+ `https://api.worldbank.org/v2` — free REST API for global development indicators. No API key, no auth, no browser needed. All data via `http_get`.
4
+
5
+ ## Do this first
6
+
7
+ **Every response is a 2-element JSON array: `[metadata, data]`.** The metadata element is always at index 0 (pagination info); the data array is at index 1. This is the single biggest gotcha — `json.loads(raw)` gives you a list, not a dict.
8
+
9
+ ```python
10
+ from helpers import http_get
11
+ import json
12
+
13
+ raw = http_get("https://api.worldbank.org/v2/country/US/indicator/NY.GDP.MKTP.CD?format=json")
14
+ d = json.loads(raw)
15
+ meta = d[0] # {"page": 1, "pages": 2, "per_page": 50, "total": 66, ...}
16
+ rows = d[1] # list of data records
17
+ ```
18
+
19
+ Always append `?format=json` — default response is XML.
20
+
21
+ ## Common workflows
22
+
23
+ ### Single country, single indicator
24
+
25
+ ```python
26
+ from helpers import http_get
27
+ import json
28
+
29
+ raw = http_get("https://api.worldbank.org/v2/country/US/indicator/NY.GDP.MKTP.CD?format=json")
30
+ d = json.loads(raw)
31
+ meta, rows = d[0], d[1]
32
+
33
+ for r in rows:
34
+ if r["value"] is not None: # recent years often have null values
35
+ print(r["date"], r["value"])
36
+ # Confirmed output (2026-04-18):
37
+ # 2024 28750956130731.2
38
+ # 2023 27292170793214.4
39
+ # 2022 25604848907611.0
40
+ # ...
41
+ ```
42
+
43
+ ### Most recent N values (`mrv` param)
44
+
45
+ `mrv` (most recent values) skips null years and returns the N most recent non-provisional points.
46
+
47
+ ```python
48
+ from helpers import http_get
49
+ import json
50
+
51
+ raw = http_get(
52
+ "https://api.worldbank.org/v2/country/US/indicator/NY.GDP.MKTP.CD"
53
+ "?format=json&mrv=5"
54
+ )
55
+ d = json.loads(raw)
56
+ for r in d[1]:
57
+ print(r["date"], r["value"])
58
+ # Confirmed output (2026-04-18):
59
+ # 2024 28750956130731.2
60
+ # 2023 27292170793214.4
61
+ # 2022 25604848907611.0
62
+ # 2021 23315080560000.0
63
+ # 2020 21060473613000.0
64
+ ```
65
+
66
+ ### Multiple countries, date range
67
+
68
+ Semicolon-delimit country codes in the URL path. Use `date=YYYY:YYYY` for a range.
69
+
70
+ ```python
71
+ from helpers import http_get
72
+ import json
73
+
74
+ raw = http_get(
75
+ "https://api.worldbank.org/v2/country/US;CN;GB/indicator/SP.POP.TOTL"
76
+ "?format=json&date=2000:2023&per_page=100"
77
+ )
78
+ d = json.loads(raw)
79
+ meta, rows = d[0], d[1]
80
+ print(f"Total records: {meta['total']}, pages: {meta['pages']}")
81
+
82
+ for r in rows:
83
+ print(r["country"]["value"], r["date"], r["value"])
84
+ # Confirmed: returns 8 records per page (50 default), date range honored exactly
85
+ # Countries: ['China', 'United States', 'United Kingdom']
86
+ # Dates: ['2000', '2001', ..., '2023']
87
+ ```
88
+
89
+ ### All countries, latest value only
90
+
91
+ Use `mrv=1` with `per_page=1000` to get all 266 countries in a single call.
92
+
93
+ ```python
94
+ from helpers import http_get
95
+ import json
96
+
97
+ raw = http_get(
98
+ "https://api.worldbank.org/v2/country/all/indicator/NY.GDP.PCAP.CD"
99
+ "?format=json&mrv=1&per_page=1000"
100
+ )
101
+ d = json.loads(raw)
102
+ meta, rows = d[0], d[1]
103
+ print(f"Countries returned: {len(rows)}") # 266 (includes aggregates)
104
+
105
+ # Filter out regional aggregates — they have no iso2Code or have aggregate ids
106
+ countries_only = [r for r in rows if len(r["country"]["id"]) == 2]
107
+ for r in sorted(countries_only, key=lambda x: -(x["value"] or 0))[:5]:
108
+ print(r["country"]["value"], r["date"], f"${r['value']:,.0f}")
109
+ # Confirmed output (2026-04-18):
110
+ # Luxembourg 2024 $135,605
111
+ # Norway 2024 $105,056
112
+ # ...
113
+ ```
114
+
115
+ ### Full pagination (fetch all pages)
116
+
117
+ ```python
118
+ from helpers import http_get
119
+ import json
120
+
121
+ def fetch_all_pages(base_url):
122
+ """Fetch all pages of a World Bank API endpoint."""
123
+ all_rows = []
124
+ page = 1
125
+ while True:
126
+ url = f"{base_url}&page={page}" if "?" in base_url else f"{base_url}?page={page}"
127
+ d = json.loads(http_get(url))
128
+ meta, rows = d[0], d[1]
129
+ all_rows.extend(rows)
130
+ if page >= meta["pages"]:
131
+ break
132
+ page += 1
133
+ return all_rows
134
+
135
+ # Example: all US GDP data (66 years, 2 pages)
136
+ rows = fetch_all_pages(
137
+ "https://api.worldbank.org/v2/country/US/indicator/NY.GDP.MKTP.CD"
138
+ "?format=json&per_page=50"
139
+ )
140
+ print(f"Total rows: {len(rows)}") # 66
141
+ non_null = [(r["date"], r["value"]) for r in rows if r["value"] is not None]
142
+ print(f"Non-null: {len(non_null)}, range: {non_null[-1][0]}–{non_null[0][0]}")
143
+ ```
144
+
145
+ ### Indicators list (discover available indicators)
146
+
147
+ ```python
148
+ from helpers import http_get
149
+ import json
150
+
151
+ raw = http_get("https://api.worldbank.org/v2/indicator?format=json&per_page=50")
152
+ d = json.loads(raw)
153
+ meta = d[0]
154
+ print(f"Total indicators: {meta['total']}, pages: {meta['pages']}")
155
+ # Confirmed: 29,511 indicators across 591 pages
156
+
157
+ for ind in d[1][:3]:
158
+ print(ind["id"], "-", ind["name"])
159
+ # 1.0.HCount.1.90usd - Poverty Headcount ($1.90 a day)
160
+ # ...
161
+ ```
162
+
163
+ ### Indicators by topic
164
+
165
+ ```python
166
+ from helpers import http_get
167
+ import json
168
+
169
+ # Topic 3 = Economy & Growth
170
+ raw = http_get("https://api.worldbank.org/v2/topic/3/indicator?format=json&per_page=50")
171
+ d = json.loads(raw)
172
+ print(f"Economy & Growth indicators: {d[0]['total']}") # 306
173
+
174
+ for ind in d[1][:5]:
175
+ print(ind["id"], "-", ind["name"])
176
+ ```
177
+
178
+ ### Country metadata
179
+
180
+ ```python
181
+ from helpers import http_get
182
+ import json
183
+
184
+ raw = http_get("https://api.worldbank.org/v2/country/US?format=json")
185
+ d = json.loads(raw)
186
+ c = d[1][0]
187
+ print(c["name"], c["capitalCity"], c["region"]["value"], c["incomeLevel"]["value"])
188
+ # United States Washington D.C. North America High income
189
+
190
+ # Filter countries by income level
191
+ raw = http_get("https://api.worldbank.org/v2/country?format=json&incomeLevel=LIC&per_page=300")
192
+ d = json.loads(raw)
193
+ print(f"Low-income countries: {d[0]['total']}") # 25
194
+ ```
195
+
196
+ ### Topics list
197
+
198
+ ```python
199
+ from helpers import http_get
200
+ import json
201
+
202
+ raw = http_get("https://api.worldbank.org/v2/topics?format=json")
203
+ d = json.loads(raw)
204
+ for t in d[1]:
205
+ print(t["id"], t["value"])
206
+ # 1 Agriculture & Rural Development
207
+ # 2 Aid Effectiveness
208
+ # 3 Economy & Growth
209
+ # ... (21 topics total)
210
+ ```
211
+
212
+ ### Parallel fetch for multiple indicators (ThreadPoolExecutor)
213
+
214
+ ```python
215
+ from helpers import http_get
216
+ from concurrent.futures import ThreadPoolExecutor
217
+ import json
218
+
219
+ INDICATORS = {
220
+ "NY.GDP.MKTP.CD": "GDP (current US$)",
221
+ "SP.POP.TOTL": "Population",
222
+ "NY.GDP.PCAP.CD": "GDP per capita",
223
+ }
224
+
225
+ def fetch_indicator(ind_id):
226
+ url = (
227
+ f"https://api.worldbank.org/v2/country/US/indicator/{ind_id}"
228
+ f"?format=json&mrv=5"
229
+ )
230
+ d = json.loads(http_get(url))
231
+ return ind_id, d[1]
232
+
233
+ with ThreadPoolExecutor(max_workers=3) as ex:
234
+ results = dict(ex.map(lambda i: fetch_indicator(i), INDICATORS))
235
+
236
+ for ind_id, rows in results.items():
237
+ latest = next((r for r in rows if r["value"] is not None), None)
238
+ if latest:
239
+ print(f"{INDICATORS[ind_id]}: {latest['date']} = {latest['value']:,.2f}")
240
+ ```
241
+
242
+ ## URL reference
243
+
244
+ ### Base URL
245
+
246
+ ```
247
+ https://api.worldbank.org/v2
248
+ ```
249
+
250
+ HTTP redirects to HTTPS (302). Always use HTTPS directly.
251
+
252
+ ### Endpoint patterns
253
+
254
+ | Endpoint | Description |
255
+ |---|---|
256
+ | `/country/{code}/indicator/{id}` | Single country + indicator time series |
257
+ | `/country/{c1};{c2};{c3}/indicator/{id}` | Multi-country (semicolon-delimited) |
258
+ | `/country/all/indicator/{id}` | All countries |
259
+ | `/country/{code}` | Country metadata |
260
+ | `/country` | All countries metadata (filterable) |
261
+ | `/indicator` | All indicators list |
262
+ | `/indicator/{id}` | Single indicator metadata |
263
+ | `/topic/{id}/indicator` | Indicators for a topic |
264
+ | `/topics` | All topics |
265
+
266
+ ### Query parameters
267
+
268
+ | Parameter | Values | Notes |
269
+ |---|---|---|
270
+ | `format` | `json`, `xml` (default) | Always set `format=json` |
271
+ | `per_page` | integer, default 50, max 1000 | Higher is faster for bulk |
272
+ | `page` | integer, default 1 | For paginating results |
273
+ | `date` | `2020`, `2000:2023` | Single year or colon-separated range |
274
+ | `mrv` | integer | N most recent non-null values |
275
+ | `gapfill` | `Y` | Forward-fill nulls when used with `mrv` |
276
+ | `incomeLevel` | `LIC`, `MIC`, `HIC`, `LMC`, `UMC` | Filter countries by income |
277
+ | `region` | `EAS`, `ECS`, `LAC`, `MEA`, `NAC`, `SAS`, `SSF` | Filter countries by region |
278
+
279
+ ### Common indicator IDs (confirmed working, 2026-04-18)
280
+
281
+ | ID | Name |
282
+ |---|---|
283
+ | `NY.GDP.MKTP.CD` | GDP (current US$) |
284
+ | `NY.GDP.PCAP.CD` | GDP per capita (current US$) |
285
+ | `SP.POP.TOTL` | Population, total |
286
+ | `SL.UEM.TOTL.ZS` | Unemployment (% of labor force) |
287
+ | `FP.CPI.TOTL.ZG` | Inflation, consumer prices (%) |
288
+ | `NE.EXP.GNFS.ZS` | Exports of goods and services (% of GDP) |
289
+ | `SP.DYN.LE00.IN` | Life expectancy at birth |
290
+ | `SE.ADT.LITR.ZS` | Literacy rate, adult total (%) |
291
+ | `EG.USE.PCAP.KG.OE` | Energy use per capita (kg of oil equiv.) |
292
+
293
+ Find more: `https://api.worldbank.org/v2/indicator?format=json&per_page=50&page=N`
294
+
295
+ ### Country codes (ISO2)
296
+
297
+ Standard ISO 3166-1 alpha-2 codes: `US`, `CN`, `GB`, `DE`, `JP`, `IN`, `BR`, etc.
298
+ Special: `all` for all countries.
299
+
300
+ ## Response structure
301
+
302
+ Every endpoint returns a 2-element array:
303
+
304
+ ```json
305
+ [
306
+ {
307
+ "page": 1,
308
+ "pages": 2,
309
+ "per_page": 50,
310
+ "total": 66,
311
+ "sourceid": "2",
312
+ "lastupdated": "2026-04-08"
313
+ },
314
+ [
315
+ {
316
+ "indicator": {"id": "NY.GDP.MKTP.CD", "value": "GDP (current US$)"},
317
+ "country": {"id": "US", "value": "United States"},
318
+ "countryiso3code": "USA",
319
+ "date": "2024",
320
+ "value": 28750956130731.2,
321
+ "unit": "",
322
+ "obs_status": "",
323
+ "decimal": 0
324
+ },
325
+ ...
326
+ ]
327
+ ]
328
+ ```
329
+
330
+ Country metadata endpoint returns same 2-element shape but with country objects (not indicator rows) at index 1.
331
+
332
+ ## Gotchas
333
+
334
+ - **Response is always a 2-element array, not a dict.** `d = json.loads(raw)` gives a list. `d[0]` is pagination metadata, `d[1]` is the data list. Accessing `d["page"]` raises `TypeError`. This is the most common mistake.
335
+
336
+ - **`value` can be null.** Recent years (e.g. 2025) and data-sparse countries frequently have `null` values. Always check `if r["value"] is not None` before using. Use `mrv=N` to skip nulls automatically.
337
+
338
+ - **Always append `?format=json`.** The default response format is XML. Without `format=json`, you get an XML string that fails `json.loads`.
339
+
340
+ - **`all/indicator/{id}` includes regional aggregates.** The "all countries" endpoint returns 266 entries including aggregated regions like "Africa Eastern and Southern" (`id: "ZH"`). Filter to real countries with `len(r["country"]["id"]) == 2` (ISO2 codes are always 2 chars; aggregate codes are 2-3 chars but with non-standard values).
341
+
342
+ - **Semicolons in URL path, not query string.** Multi-country requests use `country/US;CN;GB/indicator/...` not `?countries=US,CN,GB`. Commas do not work.
343
+
344
+ - **HTTP 302 redirects HTTP to HTTPS.** Always use `https://` directly to avoid an extra round trip.
345
+
346
+ - **`per_page` in metadata is sometimes a string, sometimes an integer.** The API returns `"per_page": "50"` (string) for some endpoints and `"per_page": 50` (int) for others. Don't compare with `==` without casting: `int(meta["per_page"])`.
347
+
348
+ - **Invalid country codes return an error object, not a 2-element array.** A bad code gives `[{"message": [{"id": "120", "key": "Invalid value", ...}]}]` — a 1-element list with an error dict. Check `if isinstance(d[0], dict) and "message" in d[0]` before accessing `d[1]`.
349
+
350
+ - **`mrv` + `gapfill=Y` forward-fills the latest value into future years.** If 2024 is the latest data point and `mrv=3`, `gapfill=Y` returns 2025 (the current year) with the 2024 value copied in. Useful for "current" lookups, but the filled date is misleading.
351
+
352
+ - **No rate limit documented, but 3 req/s sustained is safe.** The API handles bursts (parallel ThreadPoolExecutor with `max_workers=3`) without issue. For crawling thousands of indicators, add `time.sleep(0.5)` between pages.
353
+
354
+ - **`date` range returns records newest-first.** Results within a date range are sorted descending by year. If you need ascending order, sort after fetching: `sorted(rows, key=lambda r: r["date"])`.
355
+
356
+ - **Indicator IDs are case-sensitive.** `ny.gdp.mktp.cd` returns an error; use the uppercase dot-separated form `NY.GDP.MKTP.CD`.