API Docs

linkedin-api

class linkedin_api.Linkedin(username, password, *, authenticate=True, refresh_cookies=False, debug=False, proxies={}, cookies=None, cookies_dir=None)

Class for accessing the LinkedIn API.

Parameters:
  • username (str) – Username of LinkedIn account.
  • password (str) – Password of LinkedIn account.
add_connection(profile_public_id, message='', profile_urn=None)

Add a given profile id as a connection.

Parameters:
  • profile_public_id (str) – public ID of a LinkedIn profile
  • message – message to send along with connection request
  • profile_urn (str, optional) – member URN for the given LinkedIn profile
Returns:

Error state. True if error occurred

Return type:

boolean

get_company(public_id)

Fetch data about a given LinkedIn company.

Parameters:public_id (str) – LinkedIn public ID for a company
Returns:Company data
Return type:dict
get_company_updates(public_id=None, urn_id=None, max_results=None, results=None)

Fetch company updates (news activity) for a given LinkedIn company.

Parameters:
  • public_id (str, optional) – LinkedIn public ID for a company
  • urn_id (str, optional) – LinkedIn URN ID for a company
Returns:

List of company update objects

Return type:

list

get_conversation(conversation_urn_id)

Fetch data about a given conversation.

Parameters:conversation_urn_id (str) – LinkedIn URN ID for a conversation
Returns:Conversation data
Return type:dict
get_conversation_details(profile_urn_id)

Fetch conversation (message thread) details for a given LinkedIn profile.

Parameters:profile_urn_id (str) – LinkedIn URN ID for a profile
Returns:Conversation data
Return type:dict
get_conversations()

Fetch list of conversations the user is in.

Returns:List of conversations
Return type:list
get_current_profile_views()

Get profile view statistics, including chart data.

Returns:Profile view data
Return type:dict
get_feed_posts(limit=-1, offset=0, exclude_promoted_posts=True)

Get a list of URNs from feed sorted by ‘Recent’

Parameters:
  • limit (int, optional) – Maximum length of the returned list, defaults to -1 (no limit)
  • offset (int, optional) – Index to start searching from
  • exclude_promoted_posts (bool, optional) – Exclude from the output promoted posts
Returns:

List of URNs

Return type:

list

get_invitations(start=0, limit=3)

Fetch connection invitations for the currently logged in user.

Parameters:
  • start (int) – How much to offset results by
  • limit (int) – Maximum amount of invitations to return
Returns:

List of invitation objects

Return type:

list

get_job(job_id)

Fetch data about a given job. :param job_id: LinkedIn job ID :type job_id: str

Returns:Job data
Return type:dict
get_post_comments(post_urn, comment_count=100)

get_post_comments: Get post comments

Parameters:
  • post_urn (str) – Post URN
  • comment_count (int, optional) – Number of comments to fetch
Returns:

List of post comments

Return type:

list

get_profile(public_id=None, urn_id=None)

Fetch data for a given LinkedIn profile.

Parameters:
  • public_id (str, optional) – LinkedIn public ID for a profile
  • urn_id (str, optional) – LinkedIn URN ID for a profile
Returns:

Profile data

Return type:

dict

get_profile_connections(urn_id)

Fetch first-degree connections for a given LinkedIn profile.

Parameters:urn_id (str) – LinkedIn URN ID for a profile
Returns:List of search results
Return type:list
get_profile_contact_info(public_id=None, urn_id=None)

Fetch contact information for a given LinkedIn profile. Pass a [public_id] or a [urn_id].

Parameters:
  • public_id (str, optional) – LinkedIn public ID for a profile
  • urn_id (str, optional) – LinkedIn URN ID for a profile
Returns:

Contact data

Return type:

dict

get_profile_member_badges(public_profile_id)

Fetch badges for a given LinkedIn profile.

Parameters:public_profile_id (str) – public ID of a LinkedIn profile
Returns:Badges data
Return type:dict
get_profile_network_info(public_profile_id)

Fetch network information for a given LinkedIn profile.

Parameters:public_profile_id (str) – public ID of a LinkedIn profile
Returns:Network data
Return type:dict
get_profile_posts(public_id=None, urn_id=None, post_count=10)

get_profile_posts: Get profile posts

Parameters:
  • public_id (str, optional) – LinkedIn public ID for a profile
  • urn_id (str, optional) – LinkedIn URN ID for a profile
  • post_count (int, optional) – Number of posts to fetch
Returns:

List of posts

Return type:

list

get_profile_privacy_settings(public_profile_id)

Fetch privacy settings for a given LinkedIn profile.

Parameters:public_profile_id (str) – public ID of a LinkedIn profile
Returns:Privacy settings data
Return type:dict
get_profile_skills(public_id=None, urn_id=None)

Fetch the skills listed on a given LinkedIn profile.

Parameters:
  • public_id (str, optional) – LinkedIn public ID for a profile
  • urn_id (str, optional) – LinkedIn URN ID for a profile
Returns:

List of skill objects

Return type:

list

get_profile_updates(public_id=None, urn_id=None, max_results=None, results=None)

Fetch profile updates (newsfeed activity) for a given LinkedIn profile.

Parameters:
  • public_id (str, optional) – LinkedIn public ID for a profile
  • urn_id (str, optional) – LinkedIn URN ID for a profile
Returns:

List of profile update objects

Return type:

list

get_school(public_id)

Fetch data about a given LinkedIn school.

Parameters:public_id (str) – LinkedIn public ID for a school
Returns:School data
Return type:dict
get_user_profile(use_cache=True)

Get the current user profile. If not cached, a network request will be fired.

Returns:Profile data for currently logged in user
Return type:dict
mark_conversation_as_seen(conversation_urn_id)

Send ‘seen’ to a given conversation.

Parameters:conversation_urn_id (str) – LinkedIn URN ID for a conversation
Returns:Error state. If True, an error occured.
Return type:boolean
remove_connection(public_profile_id)

Remove a given profile as a connection.

Parameters:public_profile_id (str) – public ID of a LinkedIn profile
Returns:Error state. True if error occurred
Return type:boolean
reply_invitation(invitation_entity_urn, invitation_shared_secret, action='accept')

Respond to a connection invitation. By default, accept the invitation.

Parameters:
  • invitation_entity_urn (int) – URN ID of the invitation
  • invitation_shared_secret (str) – Shared secret of invitation
  • action (str, optional) – “accept” or “reject”. Defaults to “accept”
Returns:

Success state. True if successful

Return type:

boolean

search(params, limit=-1, offset=0)

Perform a LinkedIn search.

Parameters:
  • params (dict) – Search parameters (see code)
  • limit (int, optional) – Maximum length of the returned list, defaults to -1 (no limit)
  • offset (int, optional) – Index to start searching from
Returns:

List of search results

Return type:

list

search_companies(keywords=None, **kwargs)

Perform a LinkedIn search for companies.

Parameters:keywords (list, optional) – A list of search keywords (str)
Returns:List of companies
Return type:list
search_jobs(keywords=None, companies=None, experience=None, job_type=None, job_title=None, industries=None, location_name=None, remote=False, listed_at=86400, distance=None, limit=-1, offset=0, **kwargs)

Perform a LinkedIn search for jobs.

Parameters:
  • keywords (str, optional) – Search keywords (str)
  • companies (list, optional) – A list of company URN IDs (str)
  • experience (list, optional) – A list of experience levels, one or many of “1”, “2”, “3”, “4”, “5” and “6” (internship, entry level, associate, mid-senior level, director and executive, respectively)
  • job_type (list, optional) – A list of job types , one or many of “F”, “C”, “P”, “T”, “I”, “V”, “O” (full-time, contract, part-time, temporary, internship, volunteer and “other”, respectively)
  • job_title (list, optional) – A list of title URN IDs (str)
  • industries (list, optional) – A list of industry URN IDs (str)
  • location_name (str, optional) – Name of the location to search within. Example: “Kyiv City, Ukraine”
  • remote (boolean, optional) – Whether to search only for remote jobs. Defaults to False.
  • listed_at (int/str, optional. Default value is equal to 24 hours.) – maximum number of seconds passed since job posting. 86400 will filter job postings posted in last 24 hours.
  • distance (int/str, optional. If not specified, None or 0, the default value of 25 miles applied.) – maximum distance from location in miles
  • limit (int, optional, default -1) – maximum number of results obtained from API queries. -1 means maximum which is defined by constants and is equal to 1000 now.
  • offset (int, optional) – indicates how many search results shall be skipped
Returns:

List of jobs

Return type:

list

search_people(keywords=None, connection_of=None, network_depths=None, current_company=None, past_companies=None, nonprofit_interests=None, profile_languages=None, regions=None, industries=None, schools=None, contact_interests=None, service_categories=None, include_private_profiles=False, keyword_first_name=None, keyword_last_name=None, keyword_title=None, keyword_company=None, keyword_school=None, network_depth=None, title=None, **kwargs)

Perform a LinkedIn search for people.

Parameters:
  • keywords (str, optional) – Keywords to search on
  • current_company (list, optional) – A list of company URN IDs (str)
  • past_companies (list, optional) – A list of company URN IDs (str)
  • regions (list, optional) – A list of geo URN IDs (str)
  • industries (list, optional) – A list of industry URN IDs (str)
  • schools (list, optional) – A list of school URN IDs (str)
  • profile_languages (list, optional) – A list of 2-letter language codes (str)
  • contact_interests (list, optional) – A list containing one or both of “proBono” and “boardMember”
  • service_categories (list, optional) – A list of service category URN IDs (str)
  • network_depth (str, optional) – Deprecated, use network_depths. One of “F”, “S” and “O” (first, second and third+ respectively)
  • network_depths (list, optional) – A list containing one or many of “F”, “S” and “O” (first, second and third+ respectively)
  • include_private_profiles (boolean, optional) – Include private profiles in search results. If False, only public profiles are included. Defaults to False
  • keyword_first_name (str, optional) – First name
  • keyword_last_name (str, optional) – Last name
  • keyword_title (str, optional) – Job title
  • keyword_company (str, optional) – Company name
  • keyword_school (str, optional) – School name
  • connection_of (str, optional) – Connection of LinkedIn user, given by profile URN ID
Returns:

List of profiles (minimal data only)

Return type:

list

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

Send a message to a given conversation.

Parameters:
  • message_body (str) – Message text to send
  • conversation_urn_id (str, optional) – LinkedIn URN ID for a conversation
  • recipients (list, optional) – List of profile urn id’s
Returns:

Error state. If True, an error occured.

Return type:

boolean

unfollow_entity(urn_id)

Unfollow a given entity.

Parameters:urn_id (str) – URN ID of entity to unfollow
Returns:Error state. Returns True if error occurred
Return type:boolean
view_profile(target_profile_public_id, target_profile_member_urn_id=None, network_distance=None)

View a profile, notifying the user that you “viewed” their profile.

Provide [target_profile_member_urn_id] and [network_distance] to save 2 network requests and speed up the execution of this function.

Parameters:
  • target_profile_public_id (str) – public ID of a LinkedIn profile
  • network_distance (int, optional) – How many degrees of separation exist e.g. 2
  • target_profile_member_urn_id (str, optional) – member URN id for target profile
Returns:

Error state. True if error occurred

Return type:

boolean