@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,477 +1,477 @@
1
- # Metacritic — Scraping & Data Extraction
2
-
3
- Field-tested against metacritic.com on 2026-04-18. All code blocks validated with live requests.
4
-
5
- ## Do this first
6
-
7
- **Use the backend API — it returns clean JSON with both scores in one call, no HTML parsing.**
8
-
9
- Metacritic's internal backend API is publicly accessible with a stable key embedded in every page. It covers games, movies, and TV shows.
10
-
11
- ```python
12
- import json
13
-
14
- API_KEY = "1MOZgmNFxvmljaQR1X9KAij9Mo4xAY3u"
15
-
16
- def get_game_scores(slug):
17
- """slug = URL slug e.g. 'elden-ring', 'the-last-of-us'"""
18
- base = f"https://backend.metacritic.com"
19
- product = json.loads(http_get(
20
- f"{base}/games/metacritic/{slug}/web"
21
- f"?componentName=product&componentType=Product&apiKey={API_KEY}"
22
- ))
23
- user_stats = json.loads(http_get(
24
- f"{base}/reviews/metacritic/user/games/{slug}/stats/web"
25
- f"?componentName=user-score-summary&componentType=ScoreSummary&apiKey={API_KEY}"
26
- ))
27
- item = product["data"]["item"]
28
- crit = item["criticScoreSummary"]
29
- user = user_stats["data"]["item"]
30
- return {
31
- "title": item["title"],
32
- "platform": item["platform"], # lead platform
33
- "platforms": item["platforms"], # list with per-platform scores
34
- "metascore": crit["score"], # int 0–100 or None
35
- "critic_reviews": crit["reviewCount"], # int
36
- "critic_sentiment": crit["sentiment"], # e.g. "Universal acclaim"
37
- "user_score": user["score"], # float 0.0–10.0 or None
38
- "user_reviews": user["reviewCount"], # int
39
- "user_sentiment": user["sentiment"],
40
- "release_date": item["releaseDate"], # "YYYY-MM-DD"
41
- }
42
-
43
- print(get_game_scores("the-last-of-us"))
44
- # {'title': 'The Last of Us', 'platform': 'PlayStation 3',
45
- # 'metascore': 95, 'critic_reviews': 98,
46
- # 'user_score': 9.2, 'user_reviews': 17207, ...}
47
- ```
48
-
49
- Use the browser **only** if you need music pages — `metacritic.com/music/*` returns HTTP 403 to `http_get` (Cloudflare blocks those routes). Games, movies, and TV all work with plain HTTP.
50
-
51
- ---
52
-
53
- ## Fastest approach: JSON-LD (critic score + review count only)
54
-
55
- If you only need the Metascore and critic review count and don't need the user score, JSON-LD is the single-call option — no API key, no separate request:
56
-
57
- ```python
58
- import json, re
59
-
60
- url = "https://www.metacritic.com/game/elden-ring/" # or /movie/ or /tv/
61
- html = http_get(url)
62
-
63
- block = re.findall(
64
- r'<script[^>]*type="application/ld\+json"[^>]*>(.*?)</script>',
65
- html, re.DOTALL
66
- )[0]
67
- ld = json.loads(block)
68
-
69
- agg = ld["aggregateRating"]
70
- print(ld["name"]) # "Elden Ring"
71
- print(agg["ratingValue"]) # 96 (metascore)
72
- print(agg["reviewCount"]) # 93 (critic reviews count)
73
- print(ld.get("gamePlatform")) # ['Xbox One', 'PC', 'PlayStation 4', 'Xbox Series X', 'PlayStation 5']
74
- print(ld.get("genre")) # "Action RPG"
75
- print(ld.get("contentRating")) # "M"
76
- print(ld.get("datePublished")) # "2022-02-25"
77
- ```
78
-
79
- **JSON-LD limitations:**
80
- - Only contains Metascore and critic review count — **no user score, no user review count**.
81
- - For multi-platform games, `ratingValue` is the lead platform score; all platforms are listed in `gamePlatform` but without individual scores.
82
- - `@type` is `VideoGame` for games, `Movie` for movies, `TVSeries` for TV shows.
83
-
84
- ---
85
-
86
- ## Common workflows
87
-
88
- ### Get scores for a single title (backend API)
89
-
90
- ```python
91
- import json
92
-
93
- API_KEY = "1MOZgmNFxvmljaQR1X9KAij9Mo4xAY3u"
94
- BASE = "https://backend.metacritic.com"
95
-
96
- # Games
97
- def game_scores(slug):
98
- p = json.loads(http_get(f"{BASE}/games/metacritic/{slug}/web?componentName=product&componentType=Product&apiKey={API_KEY}"))
99
- u = json.loads(http_get(f"{BASE}/reviews/metacritic/user/games/{slug}/stats/web?componentName=user-score-summary&componentType=ScoreSummary&apiKey={API_KEY}"))
100
- c = p["data"]["item"]["criticScoreSummary"]
101
- us = u["data"]["item"]
102
- return {"metascore": c["score"], "critic_reviews": c["reviewCount"],
103
- "user_score": us["score"], "user_reviews": us["reviewCount"]}
104
-
105
- # Movies
106
- def movie_scores(slug):
107
- p = json.loads(http_get(f"{BASE}/movies/metacritic/{slug}/web?componentName=product&componentType=Product&apiKey={API_KEY}"))
108
- u = json.loads(http_get(f"{BASE}/reviews/metacritic/user/movies/{slug}/stats/web?componentName=user-score-summary&componentType=ScoreSummary&apiKey={API_KEY}"))
109
- c = p["data"]["item"]["criticScoreSummary"]
110
- us = u["data"]["item"]
111
- return {"metascore": c["score"], "critic_reviews": c["reviewCount"],
112
- "user_score": us["score"], "user_reviews": us["reviewCount"]}
113
-
114
- # TV shows
115
- def show_scores(slug):
116
- p = json.loads(http_get(f"{BASE}/shows/metacritic/{slug}/web?componentName=product&componentType=Product&apiKey={API_KEY}"))
117
- u = json.loads(http_get(f"{BASE}/reviews/metacritic/user/shows/{slug}/stats/web?componentName=user-score-summary&componentType=ScoreSummary&apiKey={API_KEY}"))
118
- c = p["data"]["item"]["criticScoreSummary"]
119
- us = u["data"]["item"]
120
- return {"metascore": c["score"], "critic_reviews": c["reviewCount"],
121
- "user_score": us["score"], "user_reviews": us["reviewCount"]}
122
-
123
- # Verified results:
124
- print(game_scores("the-last-of-us"))
125
- # {'metascore': 95, 'critic_reviews': 98, 'user_score': 9.2, 'user_reviews': 17207}
126
- print(movie_scores("the-godfather"))
127
- # {'metascore': 100, 'critic_reviews': 16, 'user_score': 9.2, 'user_reviews': 4450}
128
- print(show_scores("breaking-bad"))
129
- # {'metascore': 87, 'critic_reviews': 98, 'user_score': 9.4, 'user_reviews': 19070}
130
- ```
131
-
132
- ### Parallel fetching (multiple titles at once)
133
-
134
- 10 API calls in 0.68s with 5 workers — no rate-limit errors:
135
-
136
- ```python
137
- import json
138
- from concurrent.futures import ThreadPoolExecutor
139
- import urllib.request, gzip
140
-
141
- API_KEY = "1MOZgmNFxvmljaQR1X9KAij9Mo4xAY3u"
142
-
143
- def _fetch(url):
144
- h = {"User-Agent": "Mozilla/5.0", "Accept-Encoding": "gzip"}
145
- with urllib.request.urlopen(urllib.request.Request(url, headers=h), timeout=15) as r:
146
- data = r.read()
147
- if r.headers.get("Content-Encoding") == "gzip": data = gzip.decompress(data)
148
- return json.loads(data.decode())
149
-
150
- def batch_game_scores(slugs, workers=5):
151
- """Fetch critic+user scores for multiple game slugs in parallel."""
152
- BASE = "https://backend.metacritic.com"
153
- AK = f"apiKey={API_KEY}"
154
-
155
- def fetch_one(slug):
156
- c = _fetch(f"{BASE}/reviews/metacritic/critic/games/{slug}/stats/web?componentName=critic-score-summary&componentType=ScoreSummary&{AK}")
157
- u = _fetch(f"{BASE}/reviews/metacritic/user/games/{slug}/stats/web?componentName=user-score-summary&componentType=ScoreSummary&{AK}")
158
- ci = c["data"]["item"]
159
- ui = u["data"]["item"]
160
- return {"slug": slug, "metascore": ci["score"], "critic_reviews": ci["reviewCount"],
161
- "user_score": ui["score"], "user_reviews": ui["reviewCount"]}
162
-
163
- with ThreadPoolExecutor(max_workers=workers) as ex:
164
- return list(ex.map(fetch_one, slugs))
165
-
166
- results = batch_game_scores([
167
- "the-last-of-us", "elden-ring", "god-of-war",
168
- "red-dead-redemption-2", "the-witcher-3-wild-hunt"
169
- ])
170
- # the-last-of-us: meta=95/98critics, user=9.2/17207
171
- # elden-ring: meta=96/86critics, user=8.4/23344
172
- # god-of-war: meta=94/118critics, user=9.0/30439
173
- # red-dead-redemption-2: meta=97/99critics, user=9.0/35306
174
- # the-witcher-3-wild-hunt: meta=92/79critics, user=9.1/19370
175
- ```
176
-
177
- ### Search by title
178
-
179
- ```python
180
- import json, urllib.parse
181
-
182
- API_KEY = "1MOZgmNFxvmljaQR1X9KAij9Mo4xAY3u"
183
-
184
- def search(query, media_type=None, limit=10):
185
- """
186
- media_type: None='all', 'games' (mcoTypeId=13), 'movies' (2), 'shows' (1)
187
- Returns list of {title, type, slug, premiereYear, metascore, user_score}
188
- """
189
- type_map = {"games": 13, "movies": 2, "shows": 1}
190
- q = urllib.parse.quote(query)
191
- type_param = f"&mcoTypeId={type_map[media_type]}" if media_type else "&mcoTypeId=1%2C2%2C3%2C13"
192
- url = (
193
- f"https://backend.metacritic.com/finder/metacritic/search/{q}/web"
194
- f"?offset=0&limit={limit}&sortBy=META_SCORE&sortDirection=DESC"
195
- f"{type_param}&componentName=search&componentType=SearchResult"
196
- f"&apiKey={API_KEY}"
197
- )
198
- data = json.loads(http_get(url))
199
- items = data["data"]["items"]
200
- return [
201
- {
202
- "title": i["title"],
203
- "type": i["type"], # "game-title", "movie", "tv-show"
204
- "slug": i["slug"],
205
- "year": i.get("premiereYear"),
206
- "metascore": i.get("criticScoreSummary", {}).get("score"),
207
- "user_score": i.get("userScore"), # None in search results (use stats API for this)
208
- }
209
- for i in items
210
- ]
211
-
212
- results = search("elden ring", media_type="games")
213
- # [{'title': 'Elden Ring', 'type': 'game-title', 'slug': 'elden-ring', 'year': 2022, 'metascore': 96, ...}]
214
- ```
215
-
216
- **Note:** `userScore` is `None` in search results. Call the stats API with the `slug` to get it.
217
-
218
- ### Browse/list titles by score
219
-
220
- ```python
221
- import json
222
-
223
- API_KEY = "1MOZgmNFxvmljaQR1X9KAij9Mo4xAY3u"
224
-
225
- def browse_games(sort_by="-metaScore", year_min=None, year_max=None, offset=0, limit=24):
226
- """
227
- sort_by: '-metaScore' | '-releaseDate' | '-popularityCount'
228
- Returns up to `limit` games with criticScoreSummary and userScore.
229
- Total available: ~14,160 games.
230
- """
231
- params = f"sortBy={sort_by}&mcoTypeId=13&offset={offset}&limit={limit}"
232
- if year_min: params += f"&releaseYearMin={year_min}"
233
- if year_max: params += f"&releaseYearMax={year_max}"
234
- url = f"https://backend.metacritic.com/finder/metacritic/web?{params}&componentName=finder&componentType=Finder&apiKey={API_KEY}"
235
- data = json.loads(http_get(url))
236
- total = data["data"]["totalResults"]
237
- items = data["data"]["items"]
238
- return total, [
239
- {
240
- "title": i["title"],
241
- "slug": i["slug"],
242
- "year": i.get("premiereYear"),
243
- "metascore": i.get("criticScoreSummary", {}).get("score"),
244
- "critic_reviews": i.get("criticScoreSummary", {}).get("reviewCount"),
245
- "user_score": i.get("userScore", {}).get("score") if isinstance(i.get("userScore"), dict) else i.get("userScore"),
246
- }
247
- for i in items
248
- ]
249
-
250
- total, games = browse_games(year_min=2023, year_max=2024)
251
- print(f"{total} games 2023-2024") # 953
252
- for g in games[:3]:
253
- print(g)
254
- # {'title': "Baldur's Gate 3", 'year': 2023, 'metascore': 96, 'user_score': 9.2}
255
- # {'title': 'The Legend of Zelda: Tears of the Kingdom', 'year': 2023, 'metascore': 96, ...}
256
- ```
257
-
258
- Finder API totals (confirmed 2026-04-18):
259
- - Games (mcoTypeId=13): 14,160
260
- - Movies (mcoTypeId=2): 17,152
261
- - TV Shows (mcoTypeId=1): 3,392
262
-
263
- ### Get per-platform scores for multi-platform games
264
-
265
- ```python
266
- import json
267
-
268
- API_KEY = "1MOZgmNFxvmljaQR1X9KAij9Mo4xAY3u"
269
-
270
- def game_platforms(slug):
271
- url = (
272
- f"https://backend.metacritic.com/games/metacritic/{slug}/web"
273
- f"?componentName=product&componentType=Product&apiKey={API_KEY}"
274
- )
275
- data = json.loads(http_get(url))
276
- platforms = data["data"]["item"]["platforms"]
277
- return [
278
- {
279
- "name": p["name"],
280
- "slug": p["slug"],
281
- "is_lead": p["isLeadPlatform"],
282
- "metascore": p["criticScoreSummary"]["score"], # None if <4 reviews
283
- "critic_reviews": p["criticScoreSummary"]["reviewCount"],
284
- "release_date": p["releaseDate"],
285
- }
286
- for p in platforms
287
- ]
288
-
289
- print(game_platforms("elden-ring"))
290
- # [{'name': 'Xbox One', 'slug': 'xbox-one', 'is_lead': False, 'metascore': None, ...},
291
- # {'name': 'PC', 'slug': 'pc', 'is_lead': False, 'metascore': 94, 'critic_reviews': 63},
292
- # {'name': 'PlayStation 4', 'slug': 'playstation-4', 'is_lead': False, 'metascore': None, 'critic_reviews': 1},
293
- # {'name': 'Xbox Series X', 'slug': 'xbox-series-x', 'is_lead': False, 'metascore': 96, 'critic_reviews': 19},
294
- # {'name': 'PlayStation 5', 'slug': 'playstation-5', 'is_lead': True, 'metascore': 96, 'critic_reviews': 93}]
295
- ```
296
-
297
- ### Get critic reviews (paginated)
298
-
299
- ```python
300
- import json
301
-
302
- API_KEY = "1MOZgmNFxvmljaQR1X9KAij9Mo4xAY3u"
303
-
304
- def get_critic_reviews(slug, media="games", offset=0, limit=10, sort="date"):
305
- """sort: 'date' | 'score' | 'publication'"""
306
- url = (
307
- f"https://backend.metacritic.com/reviews/metacritic/critic/{media}/{slug}/web"
308
- f"?offset={offset}&limit={limit}&sort={sort}"
309
- f"&componentName=latest-critic-reviews&componentType=CriticReviewList&apiKey={API_KEY}"
310
- )
311
- data = json.loads(http_get(url))
312
- total = data["data"]["totalResults"] # e.g. 98
313
- items = data["data"]["items"]
314
- return total, [
315
- {
316
- "score": r["score"], # int 0–100
317
- "publication": r["publicationName"],
318
- "quote": r["quote"],
319
- "date": r["date"],
320
- "url": r.get("url"),
321
- }
322
- for r in items
323
- ]
324
-
325
- total, reviews = get_critic_reviews("the-last-of-us", sort="score")
326
- print(f"{total} critic reviews") # 98
327
- print(reviews[0])
328
- # {'score': 97, 'publication': 'GamingXP', 'quote': 'Flawless in its ambition...', 'date': '...'}
329
- ```
330
-
331
- ### Get user reviews (paginated)
332
-
333
- ```python
334
- import json
335
-
336
- API_KEY = "1MOZgmNFxvmljaQR1X9KAij9Mo4xAY3u"
337
-
338
- def get_user_reviews(slug, media="games", offset=0, limit=10, order_by="score", order_type="desc"):
339
- """order_by: 'score' | 'date' | 'helpfulness'"""
340
- url = (
341
- f"https://backend.metacritic.com/reviews/metacritic/user/{media}/{slug}/web"
342
- f"?offset={offset}&limit={limit}&orderBy={order_by}&orderType={order_type}"
343
- f"&componentName=top-user-reviews&componentType=UserReviewList&apiKey={API_KEY}"
344
- )
345
- data = json.loads(http_get(url))
346
- total = data["data"]["totalResults"] # e.g. 2983 for The Last of Us
347
- items = data["data"]["items"]
348
- return total, [
349
- {
350
- "score": r["score"], # int 0–10
351
- "quote": r["quote"],
352
- "date": r["date"],
353
- "spoiler": r.get("spoiler", False),
354
- }
355
- for r in items
356
- ]
357
-
358
- total, reviews = get_user_reviews("the-last-of-us")
359
- print(f"{total} user reviews") # 2983
360
- ```
361
-
362
- ### NUXT_DATA extraction (alternative, no API key)
363
-
364
- If you need to avoid the backend API (e.g., the API key rotates), the HTML page embeds all score data in `<script id="__NUXT_DATA__">` as a flat pool with integer cross-references. This is more fragile but requires no API key:
365
-
366
- ```python
367
- import json, re
368
-
369
- url = "https://www.metacritic.com/game/the-last-of-us/"
370
- html = http_get(url)
371
-
372
- pool = json.loads(
373
- re.search(r'<script[^>]*id="__NUXT_DATA__"[^>]*>(.*?)</script>', html, re.DOTALL).group(1)
374
- )
375
-
376
- def deref(pool, idx, depth=0, visited=None):
377
- if visited is None: visited = set()
378
- if not isinstance(idx, int) or idx in visited or depth > 4: return idx
379
- visited.add(idx)
380
- val = pool[idx]
381
- if isinstance(val, dict):
382
- return {k: deref(pool, v, depth+1, visited) if isinstance(v, int) else v for k, v in val.items()}
383
- elif isinstance(val, list) and len(val) == 2 and isinstance(val[0], str) and val[0] in ('Ref','Reactive','ShallowReactive','ShallowRef'):
384
- return deref(pool, val[1], depth+1, visited)
385
- elif isinstance(val, list):
386
- return [deref(pool, v, depth+1, visited) if isinstance(v, int) else v for v in val]
387
- return val
388
-
389
- # Find components
390
- components_idx = next(
391
- pool[i] for i, v in enumerate(pool)
392
- if isinstance(v, list) and len(v) > 3 and all(isinstance(x, int) for x in v[:3])
393
- and isinstance(pool[v[0]], dict) and 'data' in pool[v[0]] and 'meta' in pool[v[0]]
394
- )
395
-
396
- def find_component(pool, name):
397
- for i, val in enumerate(pool):
398
- if not isinstance(val, dict) or 'data' not in val or 'meta' not in val: continue
399
- meta = pool[val['meta']] if isinstance(val.get('meta'), int) else {}
400
- if not isinstance(meta, dict): continue
401
- cname = pool[meta.get('componentName')] if isinstance(meta.get('componentName'), int) else ''
402
- if cname == name: return deref(pool, val['data'])
403
- return None
404
-
405
- critic = find_component(pool, 'critic-score-summary')
406
- user = find_component(pool, 'user-score-summary')
407
- print("Metascore:", critic['item']['score']) # 95
408
- print("Critic reviews:", critic['item']['reviewCount']) # 98
409
- print("User score:", user['item']['score']) # 9.2
410
- print("User reviews:", user['item']['reviewCount']) # 17207
411
- ```
412
-
413
- ---
414
-
415
- ## URL slug patterns
416
-
417
- Metacritic slugs are lowercased, spaces replaced with hyphens, special chars dropped:
418
-
419
- | Title | Slug |
420
- |-------|------|
421
- | `The Last of Us` | `the-last-of-us` |
422
- | `Baldur's Gate 3` | `baldurs-gate-3` |
423
- | `Elden Ring: Shadow of the Erdtree` | `elden-ring-shadow-of-the-erdtree` |
424
- | `Breaking Bad` | `breaking-bad` |
425
- | `The Godfather` | `the-godfather` |
426
-
427
- Derive slug from the page URL: everything between the media-type path and the trailing slash.
428
-
429
- ```python
430
- import re
431
-
432
- def slug_from_url(url):
433
- # Works for /game/, /movie/, /tv/
434
- m = re.search(r'/(?:game|movie|tv)/([^/]+)/', url)
435
- return m.group(1) if m else None
436
-
437
- slug_from_url("https://www.metacritic.com/game/the-last-of-us/") # "the-last-of-us"
438
- ```
439
-
440
- ---
441
-
442
- ## Anti-bot measures
443
-
444
- - **Cloudflare** is in front of both `metacritic.com` and `backend.metacritic.com` (confirmed via `CF-Ray` and `Server: cloudflare` headers).
445
- - **Frontend pages** (`metacritic.com/*`): Require a non-empty User-Agent. `Mozilla/5.0` works. `python-requests/...` or empty UA returns HTTP 403.
446
- - **Backend API** (`backend.metacritic.com`): Same rule — any non-empty User-Agent works, including `curl/7.84.0` and `python-requests/2.31.0`. Only truly empty UA gets 403.
447
- - **Music pages** (`metacritic.com/music/*`): HTTP 403 even with valid User-Agent — Cloudflare blocks that path category. The backend API for music also 404s. Use the browser via CDP for music pages.
448
- - **Cache**: Frontend pages are Cloudflare-cached (10 minute TTL, `Cache-Control: public, max-age=600`). Backend API responses are not cached (`CF-Cache-Status: MISS`).
449
- - **No CAPTCHA** observed during testing with any of the approaches above.
450
- - **No rate limit** hit during testing: 10 sequential calls at 3.6 calls/sec, 10 parallel calls in 0.68s — all succeeded.
451
- - **PerimeterX**: Not detected in response headers or HTML.
452
-
453
- ---
454
-
455
- ## Gotchas
456
-
457
- - **API key is embedded in every Metacritic page HTML** — find it by searching for `apiKey=` in `backend.metacritic.com` URLs. The key `1MOZgmNFxvmljaQR1X9KAij9Mo4xAY3u` was confirmed active as of 2026-04-18. If it rotates, fetch any Metacritic page and extract it: `re.search(r'apiKey=([A-Za-z0-9]+)', html).group(1)`.
458
-
459
- - **userScore is None in search results** — the `/finder/metacritic/search/` endpoint returns `userScore: null` for all results. Call the stats API separately with the slug to get user score + review count.
460
-
461
- - **Metascore None means < 4 reviews** — the backend API returns `score: null` (not 0) when a title has fewer than 4 critic reviews. Always check `if score is not None` before using.
462
-
463
- - **Multi-platform games: JSON-LD shows lead platform score** — for a game on PS5 and Xbox, `aggregateRating.ratingValue` in JSON-LD is the lead platform's score (the platform marked `isLeadPlatform: True` in the backend API). All platforms are listed in `gamePlatform` but without individual scores. Use the product API's `platforms` array for per-platform breakdown.
464
-
465
- - **Music is blocked** — `metacritic.com/music/*` returns HTTP 403 even with a real browser User-Agent. The backend API for albums (`/albums/metacritic/...`) also returns 404. Music data requires a real browser session via CDP.
466
-
467
- - **NUXT_DATA pool deref is fragile** — the pool structure is a flat array where every value is either a primitive or an integer index pointing elsewhere in the array. Component locations shift between page loads but the component names (`critic-score-summary`, `user-score-summary`) are stable.
468
-
469
- - **`http_get` default UA is `Mozilla/5.0`** — this works for Metacritic. No need to override it.
470
-
471
- - **Backend API `componentName` and `componentType` params are required** — omitting them returns HTTP 400. Use the exact values shown in the code examples above.
472
-
473
- - **Finder `userScore` format**: In finder/browse results, `userScore` is `{"score": 9.1}` (a dict with just `score`). In the stats API, it's a full object with `reviewCount`, `sentiment`, etc. In search results, it's `null`.
474
-
475
- - **Media type URL paths**: games=`/games/`, movies=`/movies/`, TV shows=`/shows/`. There is no `/tv/` path in the backend API (the frontend uses `/tv/` but the API uses `/shows/`).
476
-
477
- - **Finder API does not support free-text search** — the `q=` param is silently ignored and returns 0 results. Use the `/finder/metacritic/search/{query}/web` endpoint for title search.
1
+ # Metacritic — Scraping & Data Extraction
2
+
3
+ Field-tested against metacritic.com on 2026-04-18. All code blocks validated with live requests.
4
+
5
+ ## Do this first
6
+
7
+ **Use the backend API — it returns clean JSON with both scores in one call, no HTML parsing.**
8
+
9
+ Metacritic's internal backend API is publicly accessible with a stable key embedded in every page. It covers games, movies, and TV shows.
10
+
11
+ ```python
12
+ import json
13
+
14
+ API_KEY = "1MOZgmNFxvmljaQR1X9KAij9Mo4xAY3u"
15
+
16
+ def get_game_scores(slug):
17
+ """slug = URL slug e.g. 'elden-ring', 'the-last-of-us'"""
18
+ base = f"https://backend.metacritic.com"
19
+ product = json.loads(http_get(
20
+ f"{base}/games/metacritic/{slug}/web"
21
+ f"?componentName=product&componentType=Product&apiKey={API_KEY}"
22
+ ))
23
+ user_stats = json.loads(http_get(
24
+ f"{base}/reviews/metacritic/user/games/{slug}/stats/web"
25
+ f"?componentName=user-score-summary&componentType=ScoreSummary&apiKey={API_KEY}"
26
+ ))
27
+ item = product["data"]["item"]
28
+ crit = item["criticScoreSummary"]
29
+ user = user_stats["data"]["item"]
30
+ return {
31
+ "title": item["title"],
32
+ "platform": item["platform"], # lead platform
33
+ "platforms": item["platforms"], # list with per-platform scores
34
+ "metascore": crit["score"], # int 0–100 or None
35
+ "critic_reviews": crit["reviewCount"], # int
36
+ "critic_sentiment": crit["sentiment"], # e.g. "Universal acclaim"
37
+ "user_score": user["score"], # float 0.0–10.0 or None
38
+ "user_reviews": user["reviewCount"], # int
39
+ "user_sentiment": user["sentiment"],
40
+ "release_date": item["releaseDate"], # "YYYY-MM-DD"
41
+ }
42
+
43
+ print(get_game_scores("the-last-of-us"))
44
+ # {'title': 'The Last of Us', 'platform': 'PlayStation 3',
45
+ # 'metascore': 95, 'critic_reviews': 98,
46
+ # 'user_score': 9.2, 'user_reviews': 17207, ...}
47
+ ```
48
+
49
+ Use the browser **only** if you need music pages — `metacritic.com/music/*` returns HTTP 403 to `http_get` (Cloudflare blocks those routes). Games, movies, and TV all work with plain HTTP.
50
+
51
+ ---
52
+
53
+ ## Fastest approach: JSON-LD (critic score + review count only)
54
+
55
+ If you only need the Metascore and critic review count and don't need the user score, JSON-LD is the single-call option — no API key, no separate request:
56
+
57
+ ```python
58
+ import json, re
59
+
60
+ url = "https://www.metacritic.com/game/elden-ring/" # or /movie/ or /tv/
61
+ html = http_get(url)
62
+
63
+ block = re.findall(
64
+ r'<script[^>]*type="application/ld\+json"[^>]*>(.*?)</script>',
65
+ html, re.DOTALL
66
+ )[0]
67
+ ld = json.loads(block)
68
+
69
+ agg = ld["aggregateRating"]
70
+ print(ld["name"]) # "Elden Ring"
71
+ print(agg["ratingValue"]) # 96 (metascore)
72
+ print(agg["reviewCount"]) # 93 (critic reviews count)
73
+ print(ld.get("gamePlatform")) # ['Xbox One', 'PC', 'PlayStation 4', 'Xbox Series X', 'PlayStation 5']
74
+ print(ld.get("genre")) # "Action RPG"
75
+ print(ld.get("contentRating")) # "M"
76
+ print(ld.get("datePublished")) # "2022-02-25"
77
+ ```
78
+
79
+ **JSON-LD limitations:**
80
+ - Only contains Metascore and critic review count — **no user score, no user review count**.
81
+ - For multi-platform games, `ratingValue` is the lead platform score; all platforms are listed in `gamePlatform` but without individual scores.
82
+ - `@type` is `VideoGame` for games, `Movie` for movies, `TVSeries` for TV shows.
83
+
84
+ ---
85
+
86
+ ## Common workflows
87
+
88
+ ### Get scores for a single title (backend API)
89
+
90
+ ```python
91
+ import json
92
+
93
+ API_KEY = "1MOZgmNFxvmljaQR1X9KAij9Mo4xAY3u"
94
+ BASE = "https://backend.metacritic.com"
95
+
96
+ # Games
97
+ def game_scores(slug):
98
+ p = json.loads(http_get(f"{BASE}/games/metacritic/{slug}/web?componentName=product&componentType=Product&apiKey={API_KEY}"))
99
+ u = json.loads(http_get(f"{BASE}/reviews/metacritic/user/games/{slug}/stats/web?componentName=user-score-summary&componentType=ScoreSummary&apiKey={API_KEY}"))
100
+ c = p["data"]["item"]["criticScoreSummary"]
101
+ us = u["data"]["item"]
102
+ return {"metascore": c["score"], "critic_reviews": c["reviewCount"],
103
+ "user_score": us["score"], "user_reviews": us["reviewCount"]}
104
+
105
+ # Movies
106
+ def movie_scores(slug):
107
+ p = json.loads(http_get(f"{BASE}/movies/metacritic/{slug}/web?componentName=product&componentType=Product&apiKey={API_KEY}"))
108
+ u = json.loads(http_get(f"{BASE}/reviews/metacritic/user/movies/{slug}/stats/web?componentName=user-score-summary&componentType=ScoreSummary&apiKey={API_KEY}"))
109
+ c = p["data"]["item"]["criticScoreSummary"]
110
+ us = u["data"]["item"]
111
+ return {"metascore": c["score"], "critic_reviews": c["reviewCount"],
112
+ "user_score": us["score"], "user_reviews": us["reviewCount"]}
113
+
114
+ # TV shows
115
+ def show_scores(slug):
116
+ p = json.loads(http_get(f"{BASE}/shows/metacritic/{slug}/web?componentName=product&componentType=Product&apiKey={API_KEY}"))
117
+ u = json.loads(http_get(f"{BASE}/reviews/metacritic/user/shows/{slug}/stats/web?componentName=user-score-summary&componentType=ScoreSummary&apiKey={API_KEY}"))
118
+ c = p["data"]["item"]["criticScoreSummary"]
119
+ us = u["data"]["item"]
120
+ return {"metascore": c["score"], "critic_reviews": c["reviewCount"],
121
+ "user_score": us["score"], "user_reviews": us["reviewCount"]}
122
+
123
+ # Verified results:
124
+ print(game_scores("the-last-of-us"))
125
+ # {'metascore': 95, 'critic_reviews': 98, 'user_score': 9.2, 'user_reviews': 17207}
126
+ print(movie_scores("the-godfather"))
127
+ # {'metascore': 100, 'critic_reviews': 16, 'user_score': 9.2, 'user_reviews': 4450}
128
+ print(show_scores("breaking-bad"))
129
+ # {'metascore': 87, 'critic_reviews': 98, 'user_score': 9.4, 'user_reviews': 19070}
130
+ ```
131
+
132
+ ### Parallel fetching (multiple titles at once)
133
+
134
+ 10 API calls in 0.68s with 5 workers — no rate-limit errors:
135
+
136
+ ```python
137
+ import json
138
+ from concurrent.futures import ThreadPoolExecutor
139
+ import urllib.request, gzip
140
+
141
+ API_KEY = "1MOZgmNFxvmljaQR1X9KAij9Mo4xAY3u"
142
+
143
+ def _fetch(url):
144
+ h = {"User-Agent": "Mozilla/5.0", "Accept-Encoding": "gzip"}
145
+ with urllib.request.urlopen(urllib.request.Request(url, headers=h), timeout=15) as r:
146
+ data = r.read()
147
+ if r.headers.get("Content-Encoding") == "gzip": data = gzip.decompress(data)
148
+ return json.loads(data.decode())
149
+
150
+ def batch_game_scores(slugs, workers=5):
151
+ """Fetch critic+user scores for multiple game slugs in parallel."""
152
+ BASE = "https://backend.metacritic.com"
153
+ AK = f"apiKey={API_KEY}"
154
+
155
+ def fetch_one(slug):
156
+ c = _fetch(f"{BASE}/reviews/metacritic/critic/games/{slug}/stats/web?componentName=critic-score-summary&componentType=ScoreSummary&{AK}")
157
+ u = _fetch(f"{BASE}/reviews/metacritic/user/games/{slug}/stats/web?componentName=user-score-summary&componentType=ScoreSummary&{AK}")
158
+ ci = c["data"]["item"]
159
+ ui = u["data"]["item"]
160
+ return {"slug": slug, "metascore": ci["score"], "critic_reviews": ci["reviewCount"],
161
+ "user_score": ui["score"], "user_reviews": ui["reviewCount"]}
162
+
163
+ with ThreadPoolExecutor(max_workers=workers) as ex:
164
+ return list(ex.map(fetch_one, slugs))
165
+
166
+ results = batch_game_scores([
167
+ "the-last-of-us", "elden-ring", "god-of-war",
168
+ "red-dead-redemption-2", "the-witcher-3-wild-hunt"
169
+ ])
170
+ # the-last-of-us: meta=95/98critics, user=9.2/17207
171
+ # elden-ring: meta=96/86critics, user=8.4/23344
172
+ # god-of-war: meta=94/118critics, user=9.0/30439
173
+ # red-dead-redemption-2: meta=97/99critics, user=9.0/35306
174
+ # the-witcher-3-wild-hunt: meta=92/79critics, user=9.1/19370
175
+ ```
176
+
177
+ ### Search by title
178
+
179
+ ```python
180
+ import json, urllib.parse
181
+
182
+ API_KEY = "1MOZgmNFxvmljaQR1X9KAij9Mo4xAY3u"
183
+
184
+ def search(query, media_type=None, limit=10):
185
+ """
186
+ media_type: None='all', 'games' (mcoTypeId=13), 'movies' (2), 'shows' (1)
187
+ Returns list of {title, type, slug, premiereYear, metascore, user_score}
188
+ """
189
+ type_map = {"games": 13, "movies": 2, "shows": 1}
190
+ q = urllib.parse.quote(query)
191
+ type_param = f"&mcoTypeId={type_map[media_type]}" if media_type else "&mcoTypeId=1%2C2%2C3%2C13"
192
+ url = (
193
+ f"https://backend.metacritic.com/finder/metacritic/search/{q}/web"
194
+ f"?offset=0&limit={limit}&sortBy=META_SCORE&sortDirection=DESC"
195
+ f"{type_param}&componentName=search&componentType=SearchResult"
196
+ f"&apiKey={API_KEY}"
197
+ )
198
+ data = json.loads(http_get(url))
199
+ items = data["data"]["items"]
200
+ return [
201
+ {
202
+ "title": i["title"],
203
+ "type": i["type"], # "game-title", "movie", "tv-show"
204
+ "slug": i["slug"],
205
+ "year": i.get("premiereYear"),
206
+ "metascore": i.get("criticScoreSummary", {}).get("score"),
207
+ "user_score": i.get("userScore"), # None in search results (use stats API for this)
208
+ }
209
+ for i in items
210
+ ]
211
+
212
+ results = search("elden ring", media_type="games")
213
+ # [{'title': 'Elden Ring', 'type': 'game-title', 'slug': 'elden-ring', 'year': 2022, 'metascore': 96, ...}]
214
+ ```
215
+
216
+ **Note:** `userScore` is `None` in search results. Call the stats API with the `slug` to get it.
217
+
218
+ ### Browse/list titles by score
219
+
220
+ ```python
221
+ import json
222
+
223
+ API_KEY = "1MOZgmNFxvmljaQR1X9KAij9Mo4xAY3u"
224
+
225
+ def browse_games(sort_by="-metaScore", year_min=None, year_max=None, offset=0, limit=24):
226
+ """
227
+ sort_by: '-metaScore' | '-releaseDate' | '-popularityCount'
228
+ Returns up to `limit` games with criticScoreSummary and userScore.
229
+ Total available: ~14,160 games.
230
+ """
231
+ params = f"sortBy={sort_by}&mcoTypeId=13&offset={offset}&limit={limit}"
232
+ if year_min: params += f"&releaseYearMin={year_min}"
233
+ if year_max: params += f"&releaseYearMax={year_max}"
234
+ url = f"https://backend.metacritic.com/finder/metacritic/web?{params}&componentName=finder&componentType=Finder&apiKey={API_KEY}"
235
+ data = json.loads(http_get(url))
236
+ total = data["data"]["totalResults"]
237
+ items = data["data"]["items"]
238
+ return total, [
239
+ {
240
+ "title": i["title"],
241
+ "slug": i["slug"],
242
+ "year": i.get("premiereYear"),
243
+ "metascore": i.get("criticScoreSummary", {}).get("score"),
244
+ "critic_reviews": i.get("criticScoreSummary", {}).get("reviewCount"),
245
+ "user_score": i.get("userScore", {}).get("score") if isinstance(i.get("userScore"), dict) else i.get("userScore"),
246
+ }
247
+ for i in items
248
+ ]
249
+
250
+ total, games = browse_games(year_min=2023, year_max=2024)
251
+ print(f"{total} games 2023-2024") # 953
252
+ for g in games[:3]:
253
+ print(g)
254
+ # {'title': "Baldur's Gate 3", 'year': 2023, 'metascore': 96, 'user_score': 9.2}
255
+ # {'title': 'The Legend of Zelda: Tears of the Kingdom', 'year': 2023, 'metascore': 96, ...}
256
+ ```
257
+
258
+ Finder API totals (confirmed 2026-04-18):
259
+ - Games (mcoTypeId=13): 14,160
260
+ - Movies (mcoTypeId=2): 17,152
261
+ - TV Shows (mcoTypeId=1): 3,392
262
+
263
+ ### Get per-platform scores for multi-platform games
264
+
265
+ ```python
266
+ import json
267
+
268
+ API_KEY = "1MOZgmNFxvmljaQR1X9KAij9Mo4xAY3u"
269
+
270
+ def game_platforms(slug):
271
+ url = (
272
+ f"https://backend.metacritic.com/games/metacritic/{slug}/web"
273
+ f"?componentName=product&componentType=Product&apiKey={API_KEY}"
274
+ )
275
+ data = json.loads(http_get(url))
276
+ platforms = data["data"]["item"]["platforms"]
277
+ return [
278
+ {
279
+ "name": p["name"],
280
+ "slug": p["slug"],
281
+ "is_lead": p["isLeadPlatform"],
282
+ "metascore": p["criticScoreSummary"]["score"], # None if <4 reviews
283
+ "critic_reviews": p["criticScoreSummary"]["reviewCount"],
284
+ "release_date": p["releaseDate"],
285
+ }
286
+ for p in platforms
287
+ ]
288
+
289
+ print(game_platforms("elden-ring"))
290
+ # [{'name': 'Xbox One', 'slug': 'xbox-one', 'is_lead': False, 'metascore': None, ...},
291
+ # {'name': 'PC', 'slug': 'pc', 'is_lead': False, 'metascore': 94, 'critic_reviews': 63},
292
+ # {'name': 'PlayStation 4', 'slug': 'playstation-4', 'is_lead': False, 'metascore': None, 'critic_reviews': 1},
293
+ # {'name': 'Xbox Series X', 'slug': 'xbox-series-x', 'is_lead': False, 'metascore': 96, 'critic_reviews': 19},
294
+ # {'name': 'PlayStation 5', 'slug': 'playstation-5', 'is_lead': True, 'metascore': 96, 'critic_reviews': 93}]
295
+ ```
296
+
297
+ ### Get critic reviews (paginated)
298
+
299
+ ```python
300
+ import json
301
+
302
+ API_KEY = "1MOZgmNFxvmljaQR1X9KAij9Mo4xAY3u"
303
+
304
+ def get_critic_reviews(slug, media="games", offset=0, limit=10, sort="date"):
305
+ """sort: 'date' | 'score' | 'publication'"""
306
+ url = (
307
+ f"https://backend.metacritic.com/reviews/metacritic/critic/{media}/{slug}/web"
308
+ f"?offset={offset}&limit={limit}&sort={sort}"
309
+ f"&componentName=latest-critic-reviews&componentType=CriticReviewList&apiKey={API_KEY}"
310
+ )
311
+ data = json.loads(http_get(url))
312
+ total = data["data"]["totalResults"] # e.g. 98
313
+ items = data["data"]["items"]
314
+ return total, [
315
+ {
316
+ "score": r["score"], # int 0–100
317
+ "publication": r["publicationName"],
318
+ "quote": r["quote"],
319
+ "date": r["date"],
320
+ "url": r.get("url"),
321
+ }
322
+ for r in items
323
+ ]
324
+
325
+ total, reviews = get_critic_reviews("the-last-of-us", sort="score")
326
+ print(f"{total} critic reviews") # 98
327
+ print(reviews[0])
328
+ # {'score': 97, 'publication': 'GamingXP', 'quote': 'Flawless in its ambition...', 'date': '...'}
329
+ ```
330
+
331
+ ### Get user reviews (paginated)
332
+
333
+ ```python
334
+ import json
335
+
336
+ API_KEY = "1MOZgmNFxvmljaQR1X9KAij9Mo4xAY3u"
337
+
338
+ def get_user_reviews(slug, media="games", offset=0, limit=10, order_by="score", order_type="desc"):
339
+ """order_by: 'score' | 'date' | 'helpfulness'"""
340
+ url = (
341
+ f"https://backend.metacritic.com/reviews/metacritic/user/{media}/{slug}/web"
342
+ f"?offset={offset}&limit={limit}&orderBy={order_by}&orderType={order_type}"
343
+ f"&componentName=top-user-reviews&componentType=UserReviewList&apiKey={API_KEY}"
344
+ )
345
+ data = json.loads(http_get(url))
346
+ total = data["data"]["totalResults"] # e.g. 2983 for The Last of Us
347
+ items = data["data"]["items"]
348
+ return total, [
349
+ {
350
+ "score": r["score"], # int 0–10
351
+ "quote": r["quote"],
352
+ "date": r["date"],
353
+ "spoiler": r.get("spoiler", False),
354
+ }
355
+ for r in items
356
+ ]
357
+
358
+ total, reviews = get_user_reviews("the-last-of-us")
359
+ print(f"{total} user reviews") # 2983
360
+ ```
361
+
362
+ ### NUXT_DATA extraction (alternative, no API key)
363
+
364
+ If you need to avoid the backend API (e.g., the API key rotates), the HTML page embeds all score data in `<script id="__NUXT_DATA__">` as a flat pool with integer cross-references. This is more fragile but requires no API key:
365
+
366
+ ```python
367
+ import json, re
368
+
369
+ url = "https://www.metacritic.com/game/the-last-of-us/"
370
+ html = http_get(url)
371
+
372
+ pool = json.loads(
373
+ re.search(r'<script[^>]*id="__NUXT_DATA__"[^>]*>(.*?)</script>', html, re.DOTALL).group(1)
374
+ )
375
+
376
+ def deref(pool, idx, depth=0, visited=None):
377
+ if visited is None: visited = set()
378
+ if not isinstance(idx, int) or idx in visited or depth > 4: return idx
379
+ visited.add(idx)
380
+ val = pool[idx]
381
+ if isinstance(val, dict):
382
+ return {k: deref(pool, v, depth+1, visited) if isinstance(v, int) else v for k, v in val.items()}
383
+ elif isinstance(val, list) and len(val) == 2 and isinstance(val[0], str) and val[0] in ('Ref','Reactive','ShallowReactive','ShallowRef'):
384
+ return deref(pool, val[1], depth+1, visited)
385
+ elif isinstance(val, list):
386
+ return [deref(pool, v, depth+1, visited) if isinstance(v, int) else v for v in val]
387
+ return val
388
+
389
+ # Find components
390
+ components_idx = next(
391
+ pool[i] for i, v in enumerate(pool)
392
+ if isinstance(v, list) and len(v) > 3 and all(isinstance(x, int) for x in v[:3])
393
+ and isinstance(pool[v[0]], dict) and 'data' in pool[v[0]] and 'meta' in pool[v[0]]
394
+ )
395
+
396
+ def find_component(pool, name):
397
+ for i, val in enumerate(pool):
398
+ if not isinstance(val, dict) or 'data' not in val or 'meta' not in val: continue
399
+ meta = pool[val['meta']] if isinstance(val.get('meta'), int) else {}
400
+ if not isinstance(meta, dict): continue
401
+ cname = pool[meta.get('componentName')] if isinstance(meta.get('componentName'), int) else ''
402
+ if cname == name: return deref(pool, val['data'])
403
+ return None
404
+
405
+ critic = find_component(pool, 'critic-score-summary')
406
+ user = find_component(pool, 'user-score-summary')
407
+ print("Metascore:", critic['item']['score']) # 95
408
+ print("Critic reviews:", critic['item']['reviewCount']) # 98
409
+ print("User score:", user['item']['score']) # 9.2
410
+ print("User reviews:", user['item']['reviewCount']) # 17207
411
+ ```
412
+
413
+ ---
414
+
415
+ ## URL slug patterns
416
+
417
+ Metacritic slugs are lowercased, spaces replaced with hyphens, special chars dropped:
418
+
419
+ | Title | Slug |
420
+ |-------|------|
421
+ | `The Last of Us` | `the-last-of-us` |
422
+ | `Baldur's Gate 3` | `baldurs-gate-3` |
423
+ | `Elden Ring: Shadow of the Erdtree` | `elden-ring-shadow-of-the-erdtree` |
424
+ | `Breaking Bad` | `breaking-bad` |
425
+ | `The Godfather` | `the-godfather` |
426
+
427
+ Derive slug from the page URL: everything between the media-type path and the trailing slash.
428
+
429
+ ```python
430
+ import re
431
+
432
+ def slug_from_url(url):
433
+ # Works for /game/, /movie/, /tv/
434
+ m = re.search(r'/(?:game|movie|tv)/([^/]+)/', url)
435
+ return m.group(1) if m else None
436
+
437
+ slug_from_url("https://www.metacritic.com/game/the-last-of-us/") # "the-last-of-us"
438
+ ```
439
+
440
+ ---
441
+
442
+ ## Anti-bot measures
443
+
444
+ - **Cloudflare** is in front of both `metacritic.com` and `backend.metacritic.com` (confirmed via `CF-Ray` and `Server: cloudflare` headers).
445
+ - **Frontend pages** (`metacritic.com/*`): Require a non-empty User-Agent. `Mozilla/5.0` works. `python-requests/...` or empty UA returns HTTP 403.
446
+ - **Backend API** (`backend.metacritic.com`): Same rule — any non-empty User-Agent works, including `curl/7.84.0` and `python-requests/2.31.0`. Only truly empty UA gets 403.
447
+ - **Music pages** (`metacritic.com/music/*`): HTTP 403 even with valid User-Agent — Cloudflare blocks that path category. The backend API for music also 404s. Use the browser via CDP for music pages.
448
+ - **Cache**: Frontend pages are Cloudflare-cached (10 minute TTL, `Cache-Control: public, max-age=600`). Backend API responses are not cached (`CF-Cache-Status: MISS`).
449
+ - **No CAPTCHA** observed during testing with any of the approaches above.
450
+ - **No rate limit** hit during testing: 10 sequential calls at 3.6 calls/sec, 10 parallel calls in 0.68s — all succeeded.
451
+ - **PerimeterX**: Not detected in response headers or HTML.
452
+
453
+ ---
454
+
455
+ ## Gotchas
456
+
457
+ - **API key is embedded in every Metacritic page HTML** — find it by searching for `apiKey=` in `backend.metacritic.com` URLs. The key `1MOZgmNFxvmljaQR1X9KAij9Mo4xAY3u` was confirmed active as of 2026-04-18. If it rotates, fetch any Metacritic page and extract it: `re.search(r'apiKey=([A-Za-z0-9]+)', html).group(1)`.
458
+
459
+ - **userScore is None in search results** — the `/finder/metacritic/search/` endpoint returns `userScore: null` for all results. Call the stats API separately with the slug to get user score + review count.
460
+
461
+ - **Metascore None means < 4 reviews** — the backend API returns `score: null` (not 0) when a title has fewer than 4 critic reviews. Always check `if score is not None` before using.
462
+
463
+ - **Multi-platform games: JSON-LD shows lead platform score** — for a game on PS5 and Xbox, `aggregateRating.ratingValue` in JSON-LD is the lead platform's score (the platform marked `isLeadPlatform: True` in the backend API). All platforms are listed in `gamePlatform` but without individual scores. Use the product API's `platforms` array for per-platform breakdown.
464
+
465
+ - **Music is blocked** — `metacritic.com/music/*` returns HTTP 403 even with a real browser User-Agent. The backend API for albums (`/albums/metacritic/...`) also returns 404. Music data requires a real browser session via CDP.
466
+
467
+ - **NUXT_DATA pool deref is fragile** — the pool structure is a flat array where every value is either a primitive or an integer index pointing elsewhere in the array. Component locations shift between page loads but the component names (`critic-score-summary`, `user-score-summary`) are stable.
468
+
469
+ - **`http_get` default UA is `Mozilla/5.0`** — this works for Metacritic. No need to override it.
470
+
471
+ - **Backend API `componentName` and `componentType` params are required** — omitting them returns HTTP 400. Use the exact values shown in the code examples above.
472
+
473
+ - **Finder `userScore` format**: In finder/browse results, `userScore` is `{"score": 9.1}` (a dict with just `score`). In the stats API, it's a full object with `reviewCount`, `sentiment`, etc. In search results, it's `null`.
474
+
475
+ - **Media type URL paths**: games=`/games/`, movies=`/movies/`, TV shows=`/shows/`. There is no `/tv/` path in the backend API (the frontend uses `/tv/` but the API uses `/shows/`).
476
+
477
+ - **Finder API does not support free-text search** — the `q=` param is silently ignored and returns 0 results. Use the `/finder/metacritic/search/{query}/web` endpoint for title search.