@pencil-agent/nano-pencil 2.0.0-beta.8 → 2.0.0

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 (241) 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/extensions-host/index.d.ts +1 -1
  7. package/dist/core/extensions-host/loader.js +1 -1
  8. package/dist/core/extensions-host/runner.d.ts +1 -0
  9. package/dist/core/extensions-host/runner.js +2 -2
  10. package/dist/core/extensions-host/types.d.ts +17 -22
  11. package/dist/core/lib/ai/src/types.d.ts +12 -2
  12. package/dist/core/persona/persona-manager.js +5 -2
  13. package/dist/core/runtime/agent-session.js +3 -3
  14. package/dist/core/runtime/extension-core-bindings.d.ts +1 -0
  15. package/dist/core/runtime/extension-core-bindings.js +2 -2
  16. package/dist/extensions/builtin/AGENT.md +115 -115
  17. package/dist/extensions/builtin/browser/AGENT.md +17 -17
  18. package/dist/extensions/builtin/browser/agent-workspace/agent_helpers.py +12 -12
  19. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/amazon/product-search.md +198 -198
  20. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/archive-org/scraping.md +341 -341
  21. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/arxiv/scraping.md +311 -311
  22. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/arxiv-bulk/scraping.md +333 -333
  23. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/atlas/overview.md +70 -70
  24. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/booking-com/scraping.md +578 -578
  25. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/capterra/scraping.md +440 -440
  26. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/centilebrain/generate-estimates.md +110 -110
  27. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/coingecko/scraping.md +325 -325
  28. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/coinmarketcap/scraping.md +463 -463
  29. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/coursera/scraping.md +360 -360
  30. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/craigslist/scraping.md +390 -390
  31. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/crossref/scraping.md +568 -568
  32. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/dev-to/scraping.md +323 -323
  33. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/duckduckgo/scraping.md +349 -349
  34. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/ebay/scraping.md +435 -435
  35. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/etsy/scraping.md +506 -506
  36. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/eventbrite/scraping.md +363 -363
  37. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/expedia/automation.md +168 -168
  38. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/facebook/groups.md +236 -236
  39. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/facebook/pages.md +295 -295
  40. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/framer/editor.md +108 -108
  41. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/fred/scraping.md +493 -493
  42. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/g2/scraping.md +580 -580
  43. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/genius/scraping.md +511 -511
  44. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/github/repo-actions.md +65 -65
  45. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/github/scraping.md +184 -184
  46. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/glassdoor/scraping.md +543 -543
  47. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/gmail/compose.md +122 -122
  48. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/goodreads/scraping.md +461 -461
  49. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/gutenberg/scraping.md +383 -383
  50. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/hackernews/scraping.md +243 -243
  51. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/howlongtobeat/scraping.md +473 -473
  52. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/imdb/scraping.md +271 -271
  53. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/itch-io/scraping.md +436 -436
  54. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/job-boards/indeed-glassdoor.md +1021 -1021
  55. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/letterboxd/scraping.md +349 -349
  56. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/linkedin/invitation-manager.md +109 -109
  57. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/loom/folder-enumeration.md +170 -170
  58. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/macrotrends/scraping.md +537 -537
  59. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/medium/article-hydration.md +120 -120
  60. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/medium/scraping.md +414 -414
  61. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/metacritic/scraping.md +477 -477
  62. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/musicbrainz/scraping.md +478 -478
  63. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/nasa/scraping.md +339 -339
  64. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/news-aggregation/multi-source.md +205 -205
  65. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/open-library/scraping.md +472 -472
  66. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/openalex/scraping.md +470 -470
  67. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/openstreetmap/scraping.md +490 -490
  68. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/package-registries/npm-pypi.md +478 -478
  69. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/polymarket/scraping.md +234 -234
  70. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/producthunt/scraping.md +307 -307
  71. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/pubmed/scraping.md +421 -421
  72. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/quora/scraping.md +364 -364
  73. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/rawg/scraping.md +352 -352
  74. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/reddit/scraping.md +124 -124
  75. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/rest-countries/scraping.md +233 -233
  76. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/sec-edgar/scraping.md +361 -361
  77. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/shopify-admin/README.md +36 -36
  78. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/shopify-admin/embedded-apps.md +72 -72
  79. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/shopify-admin/knowledge-base.md +109 -109
  80. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/shopify-admin/polaris-inputs.md +137 -137
  81. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/soundcloud/scraping.md +362 -362
  82. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/spotify/scraping.md +339 -339
  83. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/stackoverflow/scraping.md +435 -435
  84. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/steam/scraping.md +575 -575
  85. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/substack/scraping.md +338 -338
  86. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/thetechgeeks/pricing.md +52 -52
  87. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/tiktok/upload.md +107 -107
  88. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/tradingview/scraping.md +309 -309
  89. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/trello/boards-and-lists.md +88 -88
  90. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/trustpilot/scraping.md +375 -375
  91. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/walmart/scraping.md +444 -444
  92. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/wayback-machine/scraping.md +306 -306
  93. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/weather/scraping.md +398 -398
  94. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/wellfound/scraping.md +596 -596
  95. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/world-bank/scraping.md +356 -356
  96. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/xiaohongshu/scraping.md +84 -84
  97. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/youtube/scraping.md +418 -418
  98. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/zillow/scraping.md +433 -433
  99. package/dist/extensions/builtin/browser/browser.md +73 -73
  100. package/dist/extensions/builtin/browser/install.md +142 -142
  101. package/dist/extensions/builtin/browser/interaction-skills/connection.md +48 -48
  102. package/dist/extensions/builtin/browser/interaction-skills/cookies.md +3 -3
  103. package/dist/extensions/builtin/browser/interaction-skills/cross-origin-iframes.md +3 -3
  104. package/dist/extensions/builtin/browser/interaction-skills/dialogs.md +64 -64
  105. package/dist/extensions/builtin/browser/interaction-skills/downloads.md +3 -3
  106. package/dist/extensions/builtin/browser/interaction-skills/drag-and-drop.md +3 -3
  107. package/dist/extensions/builtin/browser/interaction-skills/dropdowns.md +3 -3
  108. package/dist/extensions/builtin/browser/interaction-skills/iframes.md +3 -3
  109. package/dist/extensions/builtin/browser/interaction-skills/network-requests.md +3 -3
  110. package/dist/extensions/builtin/browser/interaction-skills/print-as-pdf.md +3 -3
  111. package/dist/extensions/builtin/browser/interaction-skills/profile-sync.md +90 -90
  112. package/dist/extensions/builtin/browser/interaction-skills/screenshots.md +17 -17
  113. package/dist/extensions/builtin/browser/interaction-skills/scrolling.md +3 -3
  114. package/dist/extensions/builtin/browser/interaction-skills/shadow-dom.md +3 -3
  115. package/dist/extensions/builtin/browser/interaction-skills/tabs.md +69 -69
  116. package/dist/extensions/builtin/browser/interaction-skills/uploads.md +1 -1
  117. package/dist/extensions/builtin/browser/interaction-skills/viewport.md +3 -3
  118. package/dist/extensions/builtin/browser/src/browser_harness/AGENT.md +15 -15
  119. package/dist/extensions/builtin/browser/src/browser_harness/__init__.py +8 -8
  120. package/dist/extensions/builtin/browser/src/browser_harness/_ipc.py +90 -90
  121. package/dist/extensions/builtin/browser/src/browser_harness/admin.py +722 -722
  122. package/dist/extensions/builtin/browser/src/browser_harness/daemon.py +328 -328
  123. package/dist/extensions/builtin/browser/src/browser_harness/helpers.py +396 -396
  124. package/dist/extensions/builtin/browser/src/browser_harness/run.py +103 -103
  125. package/dist/extensions/builtin/discipline/skills/brainstorming/SKILL.md +33 -33
  126. package/dist/extensions/builtin/discipline/skills/executing-plans/SKILL.md +25 -25
  127. package/dist/extensions/builtin/discipline/skills/finishing-development-branch/SKILL.md +25 -25
  128. package/dist/extensions/builtin/discipline/skills/receiving-code-review/SKILL.md +22 -22
  129. package/dist/extensions/builtin/discipline/skills/requesting-code-review/SKILL.md +31 -31
  130. package/dist/extensions/builtin/discipline/skills/systematic-debugging/SKILL.md +28 -28
  131. package/dist/extensions/builtin/discipline/skills/test-driven-development/SKILL.md +32 -32
  132. package/dist/extensions/builtin/discipline/skills/using-git-worktrees/SKILL.md +25 -25
  133. package/dist/extensions/builtin/discipline/skills/verification-before-completion/SKILL.md +27 -27
  134. package/dist/extensions/builtin/discipline/skills/writing-plans/SKILL.md +26 -26
  135. package/dist/extensions/builtin/goal/README.md +67 -67
  136. package/dist/extensions/builtin/goal/goal-controller.d.ts +39 -10
  137. package/dist/extensions/builtin/goal/goal-controller.js +1 -1
  138. package/dist/extensions/builtin/goal/goal-format.js +1 -1
  139. package/dist/extensions/builtin/goal/goal-prompts.d.ts +2 -0
  140. package/dist/extensions/builtin/goal/goal-prompts.js +5 -4
  141. package/dist/extensions/builtin/goal/goal-store.js +1 -1
  142. package/dist/extensions/builtin/goal/index.d.ts +1 -1
  143. package/dist/extensions/builtin/goal/index.js +10 -7
  144. package/dist/extensions/builtin/grub/README.md +112 -112
  145. package/dist/extensions/builtin/link-world/agent-workspace/README.md +16 -16
  146. package/dist/extensions/builtin/link-world/index.js +6 -6
  147. package/dist/extensions/builtin/link-world/internet-search/internet-search.md +65 -65
  148. package/dist/extensions/builtin/link-world/link-world-agent.md +82 -82
  149. package/dist/extensions/builtin/link-world/linkworld.md +313 -313
  150. package/dist/extensions/builtin/link-world/{network-routing.md → network-routing/network-routing.md} +67 -67
  151. package/dist/extensions/builtin/loop/README.md +92 -92
  152. package/dist/extensions/builtin/mcp/figma-design.md +68 -68
  153. package/dist/extensions/builtin/mcp/mcp-management.md +85 -85
  154. package/dist/extensions/builtin/plan/index.js +1 -1
  155. package/dist/extensions/builtin/recap/AGENT.md +15 -15
  156. package/dist/extensions/builtin/sal/README.md +72 -72
  157. package/dist/extensions/builtin/security-audit/README.md +289 -289
  158. package/dist/extensions/builtin/task/task-store.d.ts +4 -0
  159. package/dist/extensions/builtin/task/task-store.js +1 -1
  160. package/dist/extensions/builtin/team/AGENT.md +112 -112
  161. package/dist/extensions/builtin/team/TESTING.md +299 -299
  162. package/dist/extensions/builtin/token-save/README.md +56 -56
  163. package/dist/extensions/optional/AGENT.md +10 -10
  164. package/dist/index.d.ts +5 -30
  165. package/dist/index.js +1 -1
  166. package/dist/models.d.ts +7 -0
  167. package/dist/models.js +1 -0
  168. package/dist/modes/interactive/components/footer.js +1 -1
  169. package/dist/modes/interactive/components/task-status-panel.d.ts +36 -0
  170. package/dist/modes/interactive/components/task-status-panel.js +1 -0
  171. package/dist/modes/interactive/controllers/stream-render-controller.d.ts +7 -0
  172. package/dist/modes/interactive/controllers/stream-render-controller.js +2 -2
  173. package/dist/modes/interactive/interactive-mode.js +40 -40
  174. package/dist/modes/interactive/state/interactive-state.d.ts +2 -0
  175. package/dist/modes/interactive/state/interactive-state.js +1 -1
  176. package/dist/modes/interactive/theme/dark.json +85 -85
  177. package/dist/modes/interactive/theme/light.json +84 -84
  178. package/dist/modes/interactive/theme/theme-schema.json +335 -335
  179. package/dist/modes/interactive/theme/warm.json +81 -81
  180. package/dist/node_modules/@pencil-agent/ai/dist/cli.js +0 -0
  181. package/dist/node_modules/@pencil-agent/ai/dist/models.generated.js +1 -1
  182. package/dist/node_modules/@pencil-agent/ai/dist/providers/anthropic.js +2 -2
  183. package/dist/node_modules/@pencil-agent/ai/dist/providers/openai-completions.js +5 -5
  184. package/dist/node_modules/@pencil-agent/ai/dist/providers/openai-responses.js +1 -1
  185. package/dist/node_modules/@pencil-agent/ai/dist/stream.js +1 -1
  186. package/dist/packages/protocol/src/commands.d.ts +33 -0
  187. package/dist/packages/protocol/src/flags.d.ts +20 -0
  188. package/dist/packages/protocol/src/hooks.d.ts +17 -0
  189. package/dist/packages/protocol/src/hooks.js +0 -0
  190. package/dist/packages/{extension-sdk → protocol}/src/index.d.ts +7 -4
  191. package/dist/packages/protocol/src/index.js +1 -0
  192. package/dist/packages/{extension-sdk → protocol}/src/lifecycle.d.ts +15 -27
  193. package/dist/packages/protocol/src/lifecycle.js +0 -0
  194. package/dist/packages/{extension-sdk → protocol}/src/tools.d.ts +1 -1
  195. package/dist/packages/protocol/src/tools.js +0 -0
  196. package/dist/public-config.d.ts +12 -0
  197. package/dist/public-config.js +1 -0
  198. package/dist/runtime.d.ts +9 -0
  199. package/dist/runtime.js +1 -0
  200. package/dist/session-compaction.d.ts +7 -0
  201. package/dist/session-compaction.js +1 -0
  202. package/dist/session.d.ts +7 -0
  203. package/dist/session.js +1 -0
  204. package/dist/skills.d.ts +7 -0
  205. package/dist/skills.js +1 -0
  206. package/dist/tools.d.ts +7 -0
  207. package/dist/tools.js +1 -0
  208. 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
  209. package/docs/SDK-TESTING.md +364 -0
  210. package/docs/codex-goal-command-impl.md +1055 -1055
  211. package/docs/codex-goal-vs-grub.md +500 -500
  212. package/docs/custom-provider.md +27 -27
  213. package/docs/extensions.md +27 -27
  214. package/docs/keybindings.md +27 -27
  215. package/docs/loop /351/207/215/346/236/204/345/256/214/346/210/220/346/200/273/347/273/223.md" +250 -250
  216. package/docs/loop /351/207/215/346/236/204/345/256/214/346/210/220/346/212/245/345/221/212.md" +122 -122
  217. package/docs/loop /351/207/215/346/236/204/346/226/271/346/241/210.md" +1222 -1222
  218. 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
  219. 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
  220. package/docs/loop /351/207/215/346/236/204/350/256/241/345/210/222.md" +320 -320
  221. package/docs/loop-usage-examples.md +214 -214
  222. package/docs/mem-core/346/212/200/346/234/257/346/226/207/346/241/243.md +593 -0
  223. package/docs/models.md +27 -27
  224. package/docs/packages.md +27 -27
  225. package/docs/pi-design-philosophy.md +457 -457
  226. package/docs/planmode.md +1987 -1987
  227. package/docs/prompt-templates.md +27 -27
  228. package/docs/providers.md +27 -27
  229. package/docs/sdk.md +27 -27
  230. package/docs/skills.md +27 -27
  231. package/docs/startup-performance-optimization.md +301 -0
  232. package/docs/themes.md +27 -27
  233. package/docs/tui.md +27 -27
  234. package/docs//350/256/244/347/237/245/345/234/260/345/233/276.md +47 -0
  235. package/package.json +190 -162
  236. package/dist/packages/extension-sdk/src/index.js +0 -1
  237. package/docs/cc-agent-design.md +0 -1297
  238. package/docs/cc-tui-design.md +0 -1333
  239. package/docs//345/257/271/346/240/207Claude-Code.md +0 -1775
  240. /package/dist/packages/{extension-sdk/src/lifecycle.js → protocol/src/commands.js} +0 -0
  241. /package/dist/packages/{extension-sdk/src/tools.js → protocol/src/flags.js} +0 -0
@@ -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.