DEV Community

SwiftKit
SwiftKit

Posted on

Company name website, logo and stock ticker for free: Wikidata is the enrichment API nobody mentions

"I have 2,000 company names in a spreadsheet and need their websites" is a surprisingly common request. Paid enrichment APIs exist, but for well-known and mid-size companies there's a free, openly licensed source most people skip: Wikidata, the structured database behind Wikipedia. It's CC0 (public domain), has an official API, and asks only that bots identify themselves and don't hammer it.

Step 1: search by name

const UA = 'my-enrichment-script/1.0 (contact@example.com)';
const wd = async (params) =>
  (await fetch(`https://www.wikidata.org/w/api.php?${new URLSearchParams({ format: 'json', maxlag: '5', ...params })}`,
    { headers: { 'User-Agent': UA } })).json();

const { search } = await wd({ action: 'wbsearchentities', search: 'Stripe', language: 'en', type: 'item', limit: '7' });
// Q7624104 Stripe — Irish-American payment technology company
// Q3421342 stripe — long, narrow band of color…
Enter fullscreen mode Exit fullscreen mode

Step 2: read the facts

Every result is an item with "claims" (property → values). The useful ones for companies:

Property Meaning
P856 official website
P154 logo image (a file on Wikimedia Commons, often SVG)
P17 / P159 country / headquarters
P452 industry
P571 founded
P1128 employees
P414 + qualifier P249 stock exchange + ticker
P4264, P2002, P2037 LinkedIn company, X username, GitHub org
const { entities } = await wd({ action: 'wbgetentities', ids: search.map((s) => s.id).join('|'), props: 'claims|labels|descriptions' });
const best = (claims, p) => {
  const list = (claims[p] || []).filter((c) => c.rank !== 'deprecated' && c.mainsnak.datavalue);
  return list.find((c) => c.rank === 'preferred') || list.at(-1); // "preferred" = current value
};
const website = best(entities.Q7624104.claims, 'P856')?.mainsnak.datavalue.value; // https://stripe.com/
Enter fullscreen mode Exit fullscreen mode

A logo filename turns into a direct image URL with https://commons.wikimedia.org/wiki/Special:FilePath/<file name>.

Values that point to other items (country, industry) come back as IDs like Q30. Fetch their labels in one batched wbgetentities call (up to 50 IDs). One gotcha: some newer items only have a mul (multilingual) label, not an English one, so ask for languages: 'en|mul' or you'll print raw Q140991293s.

Step 3: pick the right "Apple"

Searching a name returns fruit, record labels and albums too. What worked for me:

  1. Drop anything whose type (P31) is a human, a disambiguation page or a creative work (album, film, song, book).
  2. Require an official website (P856). You wanted the domain anyway, and it filters out most noise.
  3. Prefer an exact label match, then the first remaining result. Wikidata's search ranking is already good.

That picked the right entity for Stripe, Toyota, Siemens, Canva, Mercari, Patagonia and Death Wish Coffee in my tests, and correctly returned nothing for "Taylor Swift".

Step 4: going the other way (domain → company)

Wikidata's search index can match the website statement directly:

await wd({ action: 'query', list: 'search', srsearch: 'haswbstatement:P856=https://www.allbirds.com/' });
Enter fullscreen mode Exit fullscreen mode

It's an exact match, so try the https://, https://www. and trailing-slash variants.

Step 5: fill the gaps from the homepage

Smaller companies often aren't in Wikidata, and logos on Commons are sometimes missing. One polite visit to the homepage gets you the rest: <link rel="apple-touch-icon"> (a clean square icon), the favicon (prefer SVG), og:image, an <img> whose src/alt/class mentions "logo", JSON-LD Organization.logo and sameAs (official social links).

Limits

  • Coverage is great for listed companies and well-known brands, patchy for local small businesses.
  • Employee counts are community-maintained, usually from annual reports, and can be a year or two old.
  • Logos are trademarks: fine for identifying a company, not for pretending to be one.

The packaged version

I wrapped this as Company Domain & Logo Finder on Apify: paste names or domains, get website, logo, favicon, country, industry, founded year, employees, tickers and official social accounts per row. Companies only, never people. 10 companies take about 15 seconds.

Have you used Wikidata in production? I'm curious what else people pull from it.


Written with AI assistance; the code and numbers were tested before publishing.

Top comments (0)