eilonmore / linkedin-private-api

LinkedIn NodeJS API, written in TypeScript.
MIT License
264 stars 79 forks source link

Linkedin Session #396

Open deividcingolani opened 2 years ago

deividcingolani commented 2 years ago

Hi!

hugomn commented 2 years ago

I've also checked the code but couldn't figure out how to fetch the previous work experience from a profile. Is it possible?

deividcingolani commented 2 years ago

any update?

mjyocca commented 2 years ago
  const client = new Client();
  await client.login.userPass({ username, password });

  const profile = await client.profile.getOwnProfile();

  const result: any = await client.request.get(
    `https://www.linkedin.com/voyager/api/identity/profiles/${profile?.entityUrn.split(':')[3]}/profileView`
  );
  const aggregateResults = result?.included?.reduce(
    (acc: Record<string, any[]>, item: any) => {
      if (item.$type == 'com.linkedin.voyager.identity.profile.Position') {
        acc.positions.push(item);
      } else if (item.$type == 'com.linkedin.voyager.identity.profile.Certification') {
        acc.certifications.push(item);
      } else if (item.$type == 'com.linkedin.voyager.entities.shared.MiniSchool') {
        acc.education.push(item);
      }
      return acc;
    },
    { certifications: [], positions: [], education: [] }
  );

Not perfect but could give that a go

eilonmore commented 2 years ago

@mjyocca Feel free to open a pull request with this change :) Can be placed here