Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linkedin API - get company ID from url

Tags:

rest

linkedin

Is there a way to get the numeric company ID from the URL of a company page on Linkedin? This ID is the one I'll use to query the Linkedin API and get more information on the company. I need to get the ID from the information provided with the URL, to use it to get the rest of the information related to the company page.

It seems unusual to me that you need to dig in the HTML code to get the company ID you need to use to interact using the Linkedin API, so correct me if I'm wrong.

I know there have been similar request handlers, but I'm wondering why there isn't a handler available to get the company ID like there is to get the profile id from its url:

https://api.linkedin.com/v1/people/url=xxxx

I know there is the search company handler, but that is a text based research and I found myself with some inconsistent results from time to time.

I don't want to crawl the company page for the ID since I get blacklisted by Linkedin if I do it too many times from the same IP address.

I am aware of these answers:

  • how to get companies id from linkedin jsapi
  • How to get the company id from Linkedin Company URL in PHP?
  • LinkedIn API for Company Directory

But they seem outdated or marginally related to what I ask and since LI API has changed much over the past year, if there was any development on this.

EDIT: added more info on the kind of ID I am looking for. I had erroneously marked @display's answer as correct but unfortunately it's not what I am looking for. I am referring to the companyId that I'd use to query the Linkedin API concerning that company.

like image 968
Dieghito Avatar asked Mar 30 '16 18:03

Dieghito


2 Answers

June 2020 Update

Most of the above methods no longer work, including using the jobs page URL and hovering over search results. The 2019 update by @rinogo almost works. To make it easier, paste this script into the console. Of course, updates from LinkedIn may case this to fail eventually.

(() => {
  const name = document.location.pathname.replace(/^\/[^\/]*\/([^\/]*)\/?/, '$1');
  for (let json of Array.from(document.querySelectorAll('code'))) {
    try {json = JSON.parse(json.innerText);} catch (e) {json = null;}
    if (json && json.included) {
      for (let incl of json.included) {
        if (incl.universalName === name && incl.objectUrn) {
          return 'Company ID for [' + incl.universalName + '] is [' + incl.objectUrn.substr('urn:li:company:'.length) + ']';
        }
      }
    }
  }
  return 'Company ID not found';
})();
like image 113
Whatabrain Avatar answered Sep 20 '22 11:09

Whatabrain


We can obtain the company id from the url of a company page. For this we must have a valid linkedin account. Once you are in the company page, just check the url

https://www.linkedin.com/company/123456

The numbers given as 123456 is the respective company id.

Hope that you meant this company id.

like image 28
Ques Avatar answered Sep 19 '22 11:09

Ques