module linkedin.linkedin_access
¶
Short summary¶
module manydataapi.linkedin.linkedin_access
Provides functionalities around LinkedIn.
Some pointers:
Existing Python libraries:
Classes¶
class |
truncated documentation |
---|---|
This class manages the access to LinkedIn functionalities. It assumes you requested an access to the API LinkedIn … |
Methods¶
method |
truncated documentation |
---|---|
All the following parameter are given when you request an access to linkedin. |
|
Opens the connection to linkedin (using the api_key and the secret_key). |
|
Retrieves the connection for a given profile. |
|
Returns the profile of the connected user. |
|
Searches profiles on linkedin, allowed parameters (replace _ by -): |
Documentation¶
Provides functionalities around LinkedIn.
Some pointers:
Existing Python libraries:
You should install: sdpython/python-linkedin
- class manydataapi.linkedin.linkedin_access.LinkedInAccess(api_key, secret_key, user_token, user_secret)¶
Bases:
object
This class manages the access to LinkedIn functionalities.
It assumes you requested an access to the API LinkedIn See also ipython + python-linkedin.
See linkedin, linkedin. This class proposes simplified versions of the same methods, you should follow those link to see what is missing. About LinkedIn:
Throttle limits: see throttle-limits
To see your API usage: API limits
Setting up your Permissions
Search API:
https://api.linkedin.com/v1/company-search:(companies:(id,name,logo_url))?keywords=keyword?oauth2_access_token={accesstoken}&format=json
How to Get data from your linkedin profile?
Search and get profiles:
accessToken = ["w....", "n....", "3....", "2..." ] linkedin = LinkedInAccess(*TestLinkedIn.accessToken) linkedin.connect() se = linkedin.search_profile(params={"last-name":"dupre", "first-name":"xavier"}) for _ in se["people"]["values"]: print(_)
Same results in a DataFrame:
accessToken = ["w....", "n....", "3....", "2..." ] linkedin = LinkedInAccess(*TestLinkedIn.accessToken) linkedin.connect() df = linkedin.search_profile(params={"keywords":"ensae"}, count=500, as_df=True )
All the following parameter are given when you request an access to linkedin.
- Parameters:
api_key – api key
[a-z0-9]+
secrect_key – secret key
[A-Za-z]+
user_token – user token
guid style
user_secret – user_secret
guid style
- __init__(api_key, secret_key, user_token, user_secret)¶
All the following parameter are given when you request an access to linkedin.
- Parameters:
api_key – api key
[a-z0-9]+
secrect_key – secret key
[A-Za-z]+
user_token – user token
guid style
user_secret – user_secret
guid style
- connect(all_permissions=True)¶
Opens the connection to linkedin (using the api_key and the secret_key).
- Parameters:
all_permissions – True to get all permissions, otherwise, only public profiles
- Returns:
client
- get_connections(totals_only=None, params=None, headers=None)¶
Retrieves the connection for a given profile.
- get_profile(selectors=None, idu=None, url=None)¶
Returns the profile of the connected user.
- Parameters:
selectors – if None, it is replace by
LinkedInAccess.default_selectors
idu – search by id
url – search by url
- Returns:
json
See selectors to get the full of allowed selectors.
- search_profile(params, selectors=None, count=10, as_df=False, start=0, fLOG=None)¶
Searches profiles on linkedin, allowed parameters (replace _ by -):
first-name
last-name
The others fields are (see search api
http://api.linkedin.com/v1/people-search? keywords=[space delimited keywords]& first-name=[first name]& last-name=[last name]& company-name=[company name]& current-company=[true|false]& title=[title]& current-title=[true|false]& school-name=[school name]& current-school=[true|false]& country-code=[country code]& postal-code=[postal code]& distance=[miles]& start=[number]& count=[1-25]& facet=[facet code, values]& facets=[facet codes]& sort=[connections|recommenders|distance|relevance]
- Parameters:
params – dictionary
{ field: value }
(see above)selectors – if None, uses the default selectors
count – 1 to 25, if -1 or > 25, search for all (do multiple searches and concatenate them
as_df – return a DataFrame
start – first result to fetch
fLOG – logging function
- Returns:
json format (or DataFrame if as_df is True or None if there is nothing to return)
Example of code:
accessToken = [ "w....", "n....", "3....", "2..." ] linkedin = LinkedInAccess (*TestLinkedIn.accessToken) linkedin.connect() se = linkedin.search_profile ( params = {"last-name":"dupre", "first-name":"xavier"} ) for _ in se["people"]["values"] : print(_)