1

I would like to query Wikidata for a company based on its domain url.

For instance if I query facebook.com, it should return Facebook Inc.

I have the below query which works fine but doesn't return the Ticker symbol.

 SELECT distinct ?item ?itemLabel ?stock_exchange  ?stock_exchangeLabel ?ticker_symbol
WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
  ?item (wdt:P31/wdt:P279*) wd:Q783794.
  {
            { ?item wdt:P856 <https://www.google.com.co> }   
      UNION { ?item wdt:P856 <http://www.google.com.co> }
  }  
  OPTIONAL { ?item wdt:P414 ?stock_exchange. }
  OPTIONAL { ?item wdt:P249 ?ticker_symbol. } 
}
GROUP BY  ?item ?stock_exchange ?itemLabel stock_exchangeLabel ?ticker_symbol
Srini
  • 53
  • 8
  • 1
    The easiest way is SPARQL. Somebody has already asked: https://www.wikidata.org/wiki/Wikidata:Request_a_query#Query_a_company_based_on_its_official_website. – Stanislav Kralin Feb 19 '19 at 21:13
  • Yes. I developed on the solution provided there and expanded my query. It works fine except for the ticker symbol. – Srini Feb 21 '19 at 09:29
  • SELECT distinct ?item ?itemLabel ?stock_exchange ?stock_exchangeLabel WHERE { SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } ?item (wdt:P31/wdt:P279*) wd:Q783794. { { ?item wdt:P856 } UNION { ?item wdt:P856 } } OPTIONAL { ?item wdt:P414 ?stock_exchange. } } GROUP BY ?item ?stock_exchange ?itemLabel stock_exchangeLabel – Srini Feb 21 '19 at 09:34
  • The question about tickers was already asked here or there too. – Stanislav Kralin Feb 21 '19 at 09:35
  • 1
    [Here](https://stackoverflow.com/search?q=%5Bsparql%5D+ticker), [there](https://www.wikidata.org/wiki/Special:Search?search=ticker&prefix=Wikidata%3ARequest+a+query%2F&ns4=1&fulltext=Search+the+archives&fulltext=Search). – Stanislav Kralin Feb 21 '19 at 09:38
  • Works like a charm. thanks! :) – Srini Feb 21 '19 at 09:43
  • *"Works like a charm"* — This is SPARQL :-). – Stanislav Kralin Feb 21 '19 at 09:46
  • 1
    I was finding it difficult initially until I got the hang of it! Love it now :) – Srini Feb 21 '19 at 09:50
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/188804/discussion-between-srini-and-stanislav-kralin). – Srini Feb 21 '19 at 10:57

0 Answers0