Home / Blog / Saratoga isn't where you think it is

May 11, 2026· Wine World Map

Saratoga isn't where you think it is

Wikipedia has thumbnails for almost every wine region on earth. The REST endpoint at en.wikipedia.org/api/rest_v1/page/summary/{title} returns a JSON blob with thumbnail.source, which is exactly the "hero image at the top of the article" that you want.

The catch: you have to know which article. Saratoga is a wine district in the Santa Cruz Mountains AVA. Saratoga is also a city in upstate New York that hosts a famous horse race. Asking Wikipedia for Saratoga gives you the horses.

scripts/fetch-wikipedia-images.js is the script that tries to ask the right question.

The variant list

For each district it tries up to seven title variants, in order, until one returns a non-disambiguation result with a wine-related extract:

const variants = [
  region && `${name} ${region} wine`,
  at && `${name} ${at}`,
  `${name} ${hint || 'wine'}`,
  `${name} (wine region)`,
  `${name} (wine)`,
  country && `${name} ${country}`,
  name,
]

So Saratoga in the Santa Cruz Mountains AVA gets queried as:

  1. Saratoga Santa Cruz Mountains wine
  2. Saratoga AVA
  3. Saratoga wine
  4. Saratoga (wine region)
  5. Saratoga (wine)
  6. Saratoga United States
  7. Saratoga

Variant 2 usually wins. Variant 7 is the fallback that gives you the horses — and is the reason the next paragraph exists.

The wine-keyword gate

Even when a variant returns a result, we don't trust it. If a context object was passed, the extract has to mention something wine-shaped:

const isWine = /wine|vine|vineyard|grape|appellation|d\.?o\.?c|
                a\.?v\.?a|a\.?o\.?c|d\.?o|crémant|champagne|prosecco|
                chianti/.test(text)
if (!isWine) continue

This is the trap door. Without it, Saratoga → Saratoga, New York would slip through with a thumbnail of a brick downtown street and a horse statue. With it, the script keeps looking until it finds the AVA page.

For regions (top-level) the gate is disabled — most well-known wine regions have their own article and you'd rather have a slightly off-topic Bordeaux skyline than no image at all.

Disambiguation pages

The REST endpoint helpfully tags disambiguation pages with type: 'disambiguation'. We just skip them:

if (sum.type === 'disambiguation') continue

Cheap and effective. Without this you sometimes get a thumbnail that's literally the Wikipedia disambiguation page icon (a stack of papers).

Free 2× upscaling

Wikipedia returns thumbnails at ~320px by default. The image URL encodes the width directly:

.../1024px-Vineyards_in_Bordeaux.jpg/320px-Vineyards_in_Bordeaux.jpg

Substituting 640px- for 320px- doubles the resolution at zero cost:

const img = sum.thumbnail.source.replace(/\/\d+px-/, '/640px-')

The 640px version is still well below the original's resolution, so Wikimedia's image scaler has it cached for everyone. No new server work, just better-looking cards.

Politeness

A User-Agent with a contact email (Wikipedia's rate-limiter is friendlier when you identify yourself) and a 120 ms sleep between requests. On a 3,500-district run that's about seven minutes. Faster would probably be fine; this is well inside their rate limits and the script doesn't need to win any benchmarks.

What we got

Roughly 88% of regions and 62% of districts end up with an image after one pass. The misses are usually obscure New World AVAs that don't have their own Wikipedia article, plus everything in languages where the English Wikipedia is thin (Georgian wine regions, some Balkan PDOs).

For those, the UI falls back to a tinted card with no hero photo, which is honestly fine — the alternative is a stock photo of a generic vineyard, which is worse than admitting you don't have one.

#wikipedia#images#import