{"id":9891,"library":"linkedin-api","title":"linkedin-api: Unofficial LinkedIn API Client","description":"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.","status":"active","version":"2.3.1","language":"en","source_language":"en","source_url":"https://github.com/tomquirk/linkedin-api","tags":["linkedin","api","unofficial","social-media","scraping"],"install":[{"cmd":"pip install linkedin-api","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"Used for making HTTP requests to LinkedIn's endpoints.","package":"requests"}],"imports":[{"symbol":"Linkedin","correct":"from linkedin_api import Linkedin"}],"quickstart":{"code":"import os\nfrom linkedin_api import Linkedin\n\n# It's highly recommended to use environment variables for credentials\nUSERNAME = os.environ.get('LINKEDIN_USERNAME', 'your_email@example.com')\nPASSWORD = os.environ.get('LINKEDIN_PASSWORD', 'your_strong_password')\n\nif not USERNAME or not PASSWORD:\n    print(\"Please set LINKEDIN_USERNAME and LINKEDIN_PASSWORD environment variables.\")\nelse:\n    try:\n        api = Linkedin(USERNAME, PASSWORD)\n        # Example: Get a public profile by its LinkedIn URL or ID\n        # Replace 'ACoAAADm-wABuE77A8WbNlQoV-xT8D12345' with an actual profile ID\n        profile = api.get_profile('ACoAAADm-wABuE77A8WbNlQoV-xT8D12345')\n        print(f\"Successfully fetched profile for {profile.get('firstName')} {profile.get('lastName')}\")\n        # Example: Get posts from a specific person\n        # posts = api.get_profile_posts('ACoAAADm-wABuE77A8WbNlQoV-xT8D12345')\n        # print(f\"Fetched {len(posts)} posts.\")\n\n    except Exception as e:\n        print(f\"An error occurred: {e}\")","lang":"python","description":"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."},"warnings":[{"fix":"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.","message":"As an unofficial client, 'linkedin-api' is highly susceptible to breaking changes. LinkedIn frequently updates its internal APIs, which can cause methods to fail or return unexpected data. The library maintainers strive to keep it updated, but delays are possible.","severity":"breaking","affected_versions":"All versions"},{"fix":"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.","message":"Frequent or aggressive use of the API can lead to your LinkedIn account being rate-limited, temporarily blocked, or even permanently restricted by LinkedIn's bot detection mechanisms. This includes rapid successive requests or scraping large amounts of data.","severity":"gotcha","affected_versions":"All versions"},{"fix":"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.","message":"Authentication with username/password can be unreliable, especially if your LinkedIn account has Two-Factor Authentication (2FA) enabled or if LinkedIn suspects bot activity, leading to CAPTCHA challenges or login failures.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-17T00:00:00.000Z","next_check":"2026-07-16T00:00:00.000Z","problems":[{"fix":"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.","cause":"Incorrect username or password, or LinkedIn detected suspicious activity requiring manual intervention (e.g., CAPTCHA, 2FA challenge, or account lock).","error":"Could not login: Check your email and password."},{"fix":"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.","cause":"The API endpoint did not return valid JSON. This often happens if LinkedIn redirected the request to a CAPTCHA page, a 'something went wrong' page, or a block page instead of the expected data.","error":"JSONDecodeError: Expecting value: line 1 column 1 (char 0)"},{"fix":"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.","cause":"You have exceeded LinkedIn's rate limits, or your IP address has been temporarily throttled or blocked due to aggressive scraping behavior.","error":"requests.exceptions.HTTPError: 429 Client Error: Too Many Requests for url: ..."},{"fix":"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.","cause":"LinkedIn's login flow or security measures have changed (e.g., CAPTCHA, 2FA, or HTML structure), preventing the unofficial API from successfully authenticating, or your credentials are incorrect.","error":"Login failed, please try again later."},{"fix":"Install the library using pip: `pip install linkedin-api`.","cause":"The `linkedin-api` Python package has not been installed in your current Python environment.","error":"ModuleNotFoundError: No module named 'linkedin_api'"}]}