linkedin-api is an unofficial Python client for interacting with LinkedIn's internal APIs. It allows developers to programmatically access various LinkedIn features, such as profiles, connections, and company data, by simulating browser behavior. As it uses unofficial APIs, it is prone to breaking changes and requires careful usage to avoid account issues. The current version is 2.3.1, with releases occurring as needed to address LinkedIn's frequent changes.
pip install linkedin-apiVerified import paths — ran on the pinned version, not inferred.
Initialize the Linkedin API client with your username and password, then make a simple call to retrieve a user profile. It's crucial to handle credentials securely, preferably via environment variables. This library uses unofficial APIs, so methods and responses might change without notice.
Regularly update the library (`pip install --upgrade linkedin-api`) and test your code. Monitor the GitHub repository for recent commits or issue reports regarding functionality breakage.
Implement rate limiting and exponential backoff in your code. Use reasonable delays between requests. Consider using a session cookie for authentication if you have an active browser session, which might be less prone to detection than direct username/password login.
Try disabling 2FA temporarily for programmatic access if possible, or use the `linkedin_api.Linkedin(..., cookies=...)` option to provide a session cookie from a browser. If login fails, check your LinkedIn account manually for any security challenges.
Double-check your credentials. Try logging into LinkedIn manually in a browser to see if there's a security challenge. If 2FA is enabled, you might need to provide a session cookie instead of direct username/password.
This usually indicates your account or IP is being challenged or temporarily blocked. Wait some time, reduce request frequency, or try with a different IP/account. Check the raw response content to understand what LinkedIn actually returned.
Implement robust rate limiting and exponential backoff in your code. Introduce delays between API calls (e.g., `time.sleep()`). Consider distributing requests across multiple IP addresses or using a different API client if the issue persists.
Ensure your credentials are correct, try updating the `linkedin-api` library to the latest version (`pip install --upgrade linkedin-api`), and try manually logging into LinkedIn in a browser to check for any interactive challenges.
Install the library using pip: `pip install linkedin-api`.