Skip to content

Latest commit

 

History

History
629 lines (371 loc) · 13.3 KB

DOCS.md

File metadata and controls

629 lines (371 loc) · 13.3 KB

Documentation

The Linkedin instance

Linkedin(username, password, refresh_cookies=False, debug=False, proxies=proxies)

Where it all begins. Create an instance of Linkedin to get started. You'll automatically get authenticated.

Arguments

  • username <str> - Linkedin username
  • password <str> - Linkedin password
  • refresh_cookies <boolean>: kwarg - Whether to refresh any cached cookies
  • debug <boolean>: kwarg - Enable debug logging
  • proxies <dict>: kwarg - Proxies to use, of Python Requests format

API Reference


linkedin.get_profile(public_id=None, urn_id=None)

Returns a Linkedin profile.

Arguments One of:

  • public_id <str> - public identifier i.e. tom-quirk-1928345
  • urn_id <str> - id provided by the Linkedin URN

Return

  • <dict> - that includes languages, publications, certifications, volunteer, honors

Example

linkedin = Linkedin(credentials['username'], credentials['password'])

profile = linkedin.get_profile('tom-quirk')

linkedin.get_profile(urn_id)

Returns a Linkedin profile's first degree (direct) connections

Arguments

  • urn_id <str> - id provided by the Linkedin URN

Return

  • <list>

Example

linkedin = Linkedin(credentials['username'], credentials['password'])

connections = linkedin.get_profile_connections('AC000102305')

linkedin.get_profile_contact_info(urn_id)

Returns a Linkedin profile's contact information.

Arguments One of:

  • public_id <str> - public identifier i.e. tom-quirk-1928345
  • urn_id <str> - id provided by the Linkedin URN

Return

  • <dict>

Example

linkedin = Linkedin(credentials['username'], credentials['password'])

profile_info = linkedin.get_profile_contact_info('tom-quirk')

linkedin.get_profile_skills(urn_id)

Returns a Linkedin profile's skills.

Arguments One of:

  • public_id <str> - public identifier i.e. tom-quirk-1928345
  • urn_id <str> - id provided by the Linkedin URN

Return

  • <dict>

Example

linkedin = Linkedin(credentials['username'], credentials['password'])

profile_info = linkedin.get_profile_skills('AC000102305')

linkedin.remove_connection(public_id)

Removes a connection on Linkedin

Arguments

  • public_id <str> - public identifier i.e. tom-quirk-1928345

Return

  • <bool> - True if err

Example

linkedin = Linkedin(credentials['username'], credentials['password'])

err = linkedin.remove_connection('tom-tom-quirk-1928345')

linkedin.get_school(public_id)

Returns a school's Linkedin profile.

Arguments

  • public_id <str> - public identifier i.e. university-of-queensland

Return

  • <dict>

Example

linkedin = Linkedin(credentials['username'], credentials['password'])

school = linkedin.get_school('university-of-queensland')

linkedin.get_company(public_id)

Returns a company's Linkedin profile.

Arguments

  • public_id <str> - public identifier i.e. linkedin

Return

  • <dict>

Example

linkedin = Linkedin(credentials['username'], credentials['password'])

company = linkedin.get_company('linkedin')

linkedin.get_job_posting(job_urn_id)

Returns job posting details. The job_urn_id can be found in the "jobPosting" fields in the response of a linkedin.search for job postings, (i.e, with query param decoration_id=com.linkedin.voyager.deco.jobs.web.shared.WebFullJobPosting-39).

Arguments

  • job_urn_id <str> - job id, e.g: '1792209257'

Return

  • <dict>

Example

linkedin = Linkedin(credentials['username'], credentials['password'])

job_posting = linkedin.get_job_posting('1754968923")

linkedin.search(params, max_results=None, results=[])

Perform a Linkedin search and return the results. A reference of country and industry codes can be found here.

Arguments

  • params <dict> - search parameters (see implementation of search_people for a reference)
  • `max_results - the max number of results to return

Return

  • <list>

Example

linkedin = Linkedin(credentials['username'], credentials['password'])

results = linkedin.search({'keywords': 'software'}, 200)

linkedin.get_conversations()

Return a list of metadata of the user's conversations.

Return

  • <list>

Example

linkedin = Linkedin(credentials['username'], credentials['password'])

conversations = linkedin.get_conversations()

linkedin.get_conversation(conversation_urn_id)

Return a conversation

Arguments

  • conversation_urn_id <str> - ID of the conversation

Return

  • <dict>

Example

linkedin = Linkedin(credentials['username'], credentials['password'])

conversation = linkedin.get_conversation('6446595445958545408')

linkedin.get_conversation_details(profile_urn_id)

Return the conversation details (metadata) for a given profile_urn_id. Use this endpoint to get the conversation id to send messages (see example).

Arguments

  • profile_urn_id <str> - the urn id of the profile

Return

  • <dict>

Example

linkedin = Linkedin(credentials['username'], credentials['password'])

profile = linkedin.get_profile('bill-g')
profile_urn_id = profile['profile_id']

conversation_details = linkedin.get_conversation_details(profile_urn_id)
# example: getting the conversation_id
conversation_id = conversation_details['id']

linkedin.send_message(conversation_urn_id=None, recipients=None, message_body=None)

Sends a message to the given [conversation_urn_id] OR list of recipients

Arguments

  • conversation_urn_id <str> - the urn id of the conversation
  • recipients <list(str)> - a list of profile urn id's
  • message_body <str> - the message to send

Return

  • <boolean> - True if error

Example

linkedin = Linkedin(credentials['username'], credentials['password'])

profile = linkedin.get_profile('bill-g')
profile_urn_id = profile['profile_id']

conversation = linkedin.get_conversation_details(profile_urn_id)
conversation_id = conversation['id']

err = linkedin.send_message(conversation_urn_id=conversation_id, message_body="No I will not be your technical cofounder")
if err:
    # handle error
    return

linkedin.mark_conversation_as_seen(conversation_urn_id)

Mark a given conversation as seen.

Arguments

  • conversation_urn_id <str> - the urn id of the conversation

Return

  • <boolean> - True if error

Example

linkedin = Linkedin(credentials['username'], credentials['password'])

profile = linkedin.get_profile('bill-g')
profile_urn_id = profile['profile_id']

conversation = linkedin.get_conversation_details(profile_urn_id)
conversation_id = conversation['id']

err = linkedin.mark_conversation_as_seen(conversation_id)
if err:
    # handle error
    return

linkedin.get_current_profile_views()

Get view statistics for the current profile. Includes views over time (chart data)

Example

linkedin = Linkedin(credentials['username'], credentials['password'])

views = linkedin.get_current_profile_views()

linkedin.search_people(keywords=None, connection_of=None, network_depth=None, regions=None, industries=None)

Perform a Linkedin search for people and return the results. A reference of country and industry codes can be found here.

Arguments

  • keywords <str> - keywords, comma seperated
  • connection_of <str> - urn id of a profile. Only people connected to this profile are returned
  • network_depth <str> - the network depth to search within. One of {F, S, or O} (first, second and third+ respectively)
  • regions <list> - list of Linkedin region ids
  • industries <list> - list of Linkedin industry ids
  • ... more (see code)

Return

  • <list>

Example

linkedin = Linkedin(credentials['username'], credentials['password'])

results = linkedin.search_people(
  keywords='software,lol',
  connection_of='AC000120303',
  network_depth='F',
  regions=['au:4909'],
  industries=['29', '1']
)

linkedin.search_companies(keywords=None, connection_of=None, network_depth=None, regions=None, industries=None)

Perform a Linkedin search for companies and return the results.

Arguments

  • keywords <str> - keywords, comma seperated
  • limit <int> - search limit

Return

  • <list>

Example

linkedin = Linkedin(credentials['username'], credentials['password'])

results = linkedin.search_companies(
  keywords='linkedin'
)

linkedin.get_invitations()

Get all the invitations for the current authenticated profile.

Example

linkedin = Linkedin(credentials['username'], credentials['password'])

invitations = linkedin.get_invitations()

linkedin.reply_invitation(invitation_entity_urn, invitation_shared_secret, action="accept")

Reply to the given invite (invitation_entity_urn) with one of the possible actions action=["accept"|"ignore"]. The default is to accept the given invitation.

Example

linkedin = Linkedin(credentials['username'], credentials['password'])

invite_to_accept = linkedin.get_invitations()[0]
invite_to_ignore = linkedin.get_invitations()[1]

linkedin.reply_invitation(invitation_entity_urn=invite_to_accept['entityUrn'], invitation_shared_secret=invite_to_accept['sharedSecret'])
linkedin.reply_invitation(invitation_entity_urn=invite_to_ignore['entityUrn'], invitation_shared_secret=invite_to_ignore['sharedSecret'], action="ignore")

linkedin.view_profile(public_id)

Send a profile view (i.e. "<your_name> viewed your profile")

NOTE: method does not work

Arguments

  • public_id <str> - public identifier i.e. tom-quirk-1928345

Return

  • <boolean>

Example

linkedin = Linkedin(credentials['username'], credentials['password'])

profile = linkedin.view_profile('tom-quirk')

linkedin.get_profile_privacy_settings(public_id)

Get the privacy settings for a given profile. Useful to determine whether the profile is publicly accessible.

Arguments

  • public_id <str> - public identifier i.e. tom-quirk-1928345

Return

  • <boolean>

Example

linkedin = Linkedin(credentials['username'], credentials['password'])

profile = linkedin.get_profile_privacy_settings('tom-quirk')

linkedin.get_profile_member_badges(public_id)

Get member badges for a given profile. As of writing this, badges may include:

  • influencer <boolean>
  • jobSeeker <boolean>
  • openLink <boolean>
  • premium <boolean>

Arguments

  • public_id <str> - public identifier i.e. tom-quirk-1928345

Return

  • <boolean>

Example

linkedin = Linkedin(credentials['username'], credentials['password'])

profile = linkedin.get_profile_member_badges('tom-quirk')

linkedin.get_profile_network_info(public_id)

Get high level information about a given profile's network. Useful for follower counts followability, distance from the authed user, etc.

Arguments

  • public_id <str> - public identifier i.e. tom-quirk-1928345

Return

  • <boolean>

Example

linkedin = Linkedin(credentials['username'], credentials['password'])

profile = linkedin.get_profile_network_info('tom-quirk')