linkedin-api 2.3.1__tar.gz → 2.4.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- linkedin_api-2.4.0/.env.example +5 -0
- linkedin_api-2.4.0/.github/workflows/ci.yml +27 -0
- linkedin_api-2.4.0/.github/workflows/dependency-security.yml +28 -0
- linkedin_api-2.4.0/.github/workflows/release.yml +52 -0
- linkedin_api-2.4.0/.gitignore +26 -0
- linkedin_api-2.4.0/AGENTS.md +37 -0
- linkedin_api-2.4.0/CONTRIBUTING.md +41 -0
- linkedin_api-2.4.0/PKG-INFO +268 -0
- linkedin_api-2.4.0/README.md +250 -0
- linkedin_api-2.4.0/docs/.readthedocs.yaml +14 -0
- linkedin_api-2.4.0/docs/Makefile +20 -0
- linkedin_api-2.4.0/docs/assets/logo-dark.png +0 -0
- linkedin_api-2.4.0/docs/assets/logo-light.png +0 -0
- linkedin_api-2.4.0/docs/make.bat +35 -0
- linkedin_api-2.4.0/docs/source/api.rst +10 -0
- linkedin_api-2.4.0/docs/source/conf.py +57 -0
- linkedin_api-2.4.0/docs/source/guides/add-connection.rst +160 -0
- linkedin_api-2.4.0/docs/source/guides/fetch-profile.rst +120 -0
- linkedin_api-2.4.0/docs/source/guides/get-company.rst +177 -0
- linkedin_api-2.4.0/docs/source/guides/get-conversations.rst +68 -0
- linkedin_api-2.4.0/docs/source/guides/get-profile-contact.rst +187 -0
- linkedin_api-2.4.0/docs/source/guides/get-profile-skills.rst +191 -0
- linkedin_api-2.4.0/docs/source/guides/index.rst +33 -0
- linkedin_api-2.4.0/docs/source/guides/search-jobs.rst +179 -0
- linkedin_api-2.4.0/docs/source/guides/search-people.rst +168 -0
- linkedin_api-2.4.0/docs/source/guides/send-messages.rst +167 -0
- linkedin_api-2.4.0/docs/source/guides/track-profile-views.rst +151 -0
- linkedin_api-2.4.0/docs/source/index.rst +31 -0
- linkedin_api-2.4.0/docs/source/key_concepts.rst +25 -0
- linkedin_api-2.4.0/examples/fetch_profile_example.py +97 -0
- linkedin_api-2.4.0/examples/search_jobs_example.py +102 -0
- linkedin_api-2.4.0/linkedin_api/__init__.py +6 -0
- linkedin_api-2.4.0/linkedin_api/_profile_view.py +102 -0
- linkedin_api-2.4.0/linkedin_api/_types.py +28 -0
- linkedin_api-2.4.0/linkedin_api/client.py +187 -0
- linkedin_api-2.4.0/linkedin_api/cookie_repository.py +73 -0
- {linkedin_api-2.3.1 → linkedin_api-2.4.0}/linkedin_api/linkedin.py +472 -598
- linkedin_api-2.4.0/linkedin_api/models.py +147 -0
- linkedin_api-2.4.0/linkedin_api/search.py +132 -0
- linkedin_api-2.4.0/linkedin_api/settings.py +9 -0
- linkedin_api-2.4.0/linkedin_api/utils/__init__.py +1 -0
- {linkedin_api-2.3.1 → linkedin_api-2.4.0}/linkedin_api/utils/helpers.py +59 -56
- linkedin_api-2.4.0/pyproject.toml +97 -0
- linkedin_api-2.4.0/tests/e2e/test_linkedin_api_requests.py +355 -0
- linkedin_api-2.4.0/tests/e2e/test_linkedin_client.py +22 -0
- linkedin_api-2.4.0/tests/unit/test_cookie_repository.py +47 -0
- linkedin_api-2.4.0/tests/unit/test_invitations.py +62 -0
- linkedin_api-2.4.0/tests/unit/test_linkedin_api.py +68 -0
- linkedin_api-2.4.0/tests/unit/test_pagination.py +156 -0
- linkedin_api-2.4.0/tests/unit/test_search_contracts.py +113 -0
- linkedin_api-2.4.0/tests/unit/test_transport.py +148 -0
- linkedin_api-2.4.0/uv.lock +1148 -0
- linkedin_api-2.3.1/PKG-INFO +0 -403
- linkedin_api-2.3.1/README.md +0 -378
- linkedin_api-2.3.1/linkedin_api/__init__.py +0 -7
- linkedin_api-2.3.1/linkedin_api/client.py +0 -172
- linkedin_api-2.3.1/linkedin_api/cookie_repository.py +0 -70
- linkedin_api-2.3.1/linkedin_api/settings.py +0 -7
- linkedin_api-2.3.1/pyproject.toml +0 -33
- {linkedin_api-2.3.1 → linkedin_api-2.4.0}/LICENSE +0 -0
- /linkedin_api-2.3.1/linkedin_api/utils/__init__.py → /linkedin_api-2.4.0/linkedin_api/py.typed +0 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
name: Python checks
|
|
2
|
+
on:
|
|
3
|
+
push:
|
|
4
|
+
branches: ['**']
|
|
5
|
+
tags-ignore: ['v[0-9]*']
|
|
6
|
+
pull_request:
|
|
7
|
+
workflow_call:
|
|
8
|
+
permissions:
|
|
9
|
+
contents: read
|
|
10
|
+
jobs:
|
|
11
|
+
check:
|
|
12
|
+
runs-on: ubuntu-latest
|
|
13
|
+
strategy:
|
|
14
|
+
fail-fast: false
|
|
15
|
+
matrix:
|
|
16
|
+
python-version: ['3.12', '3.13', '3.14', '3.15']
|
|
17
|
+
steps:
|
|
18
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
19
|
+
- uses: astral-sh/setup-uv@36300bab3f61b84e19f32b6bd26b7897f3c7e951 # v10.4.2
|
|
20
|
+
with:
|
|
21
|
+
version: '0.13.10'
|
|
22
|
+
python-version: ${{ matrix.python-version }}
|
|
23
|
+
- run: uv sync --locked --all-groups
|
|
24
|
+
- run: uv run --locked black --check .
|
|
25
|
+
- run: uv run --locked ruff check .
|
|
26
|
+
- run: uv run --locked mypy --python-version ${{ matrix.python-version }}
|
|
27
|
+
- run: uv run --locked --group test pytest tests/unit
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
name: Dependency security
|
|
2
|
+
'on':
|
|
3
|
+
push: {}
|
|
4
|
+
pull_request: {}
|
|
5
|
+
workflow_dispatch: {}
|
|
6
|
+
permissions:
|
|
7
|
+
contents: read
|
|
8
|
+
jobs:
|
|
9
|
+
python-dependencies:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
strategy:
|
|
12
|
+
fail-fast: false
|
|
13
|
+
matrix:
|
|
14
|
+
project:
|
|
15
|
+
- .
|
|
16
|
+
defaults:
|
|
17
|
+
run:
|
|
18
|
+
working-directory: ${{ matrix.project }}
|
|
19
|
+
steps:
|
|
20
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
21
|
+
- uses: astral-sh/setup-uv@36300bab3f61b84e19f32b6bd26b7897f3c7e951 # v10.4.2
|
|
22
|
+
with:
|
|
23
|
+
version: 0.13.10
|
|
24
|
+
python-version: '3.12'
|
|
25
|
+
- name: Export locked registry dependencies
|
|
26
|
+
run: uv export --locked --all-groups --no-emit-project --no-emit-local --no-hashes --output-file /tmp/dependencies.txt
|
|
27
|
+
- name: Reject known vulnerabilities
|
|
28
|
+
run: uvx --exclude-newer '7 days' pip-audit==2.10.1 --no-deps --disable-pip --requirement /tmp/dependencies.txt
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
name: Publish to PyPI
|
|
2
|
+
on:
|
|
3
|
+
push:
|
|
4
|
+
tags: ['v[0-9]*']
|
|
5
|
+
|
|
6
|
+
permissions:
|
|
7
|
+
contents: read
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
check:
|
|
11
|
+
uses: ./.github/workflows/ci.yml
|
|
12
|
+
|
|
13
|
+
build:
|
|
14
|
+
runs-on: ubuntu-latest
|
|
15
|
+
steps:
|
|
16
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
17
|
+
- uses: astral-sh/setup-uv@36300bab3f61b84e19f32b6bd26b7897f3c7e951 # v10.4.2
|
|
18
|
+
with:
|
|
19
|
+
version: '0.13.10'
|
|
20
|
+
python-version: '3.12'
|
|
21
|
+
- name: Verify release tag
|
|
22
|
+
run: |
|
|
23
|
+
expected="v$(uv version --short)"
|
|
24
|
+
if [[ "$GITHUB_REF_NAME" != "$expected" ]]; then
|
|
25
|
+
echo "Expected tag $expected for this commit, got $GITHUB_REF_NAME" >&2
|
|
26
|
+
exit 1
|
|
27
|
+
fi
|
|
28
|
+
- run: uv build --no-sources --out-dir "$RUNNER_TEMP/dist"
|
|
29
|
+
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
|
30
|
+
with:
|
|
31
|
+
name: distributions
|
|
32
|
+
path: ${{ runner.temp }}/dist/*
|
|
33
|
+
if-no-files-found: error
|
|
34
|
+
|
|
35
|
+
publish:
|
|
36
|
+
needs: [check, build]
|
|
37
|
+
runs-on: ubuntu-latest
|
|
38
|
+
environment:
|
|
39
|
+
name: pypi
|
|
40
|
+
url: https://pypi.org/project/linkedin-api/
|
|
41
|
+
permissions:
|
|
42
|
+
id-token: write
|
|
43
|
+
steps:
|
|
44
|
+
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
|
|
45
|
+
with:
|
|
46
|
+
name: distributions
|
|
47
|
+
path: dist
|
|
48
|
+
- uses: astral-sh/setup-uv@36300bab3f61b84e19f32b6bd26b7897f3c7e951 # v10.4.2
|
|
49
|
+
with:
|
|
50
|
+
version: '0.13.10'
|
|
51
|
+
enable-cache: false
|
|
52
|
+
- run: uv publish --trusted-publishing always dist/*.whl dist/*.tar.gz
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Linkedin-api
|
|
2
|
+
**tmp/
|
|
3
|
+
.env
|
|
4
|
+
|
|
5
|
+
# Dev
|
|
6
|
+
*.pyc
|
|
7
|
+
.vscode
|
|
8
|
+
/playground.py
|
|
9
|
+
cookies/
|
|
10
|
+
|
|
11
|
+
.pytest_cache
|
|
12
|
+
**__pycache__/
|
|
13
|
+
credentials.json
|
|
14
|
+
|
|
15
|
+
# PyPI
|
|
16
|
+
dist
|
|
17
|
+
build
|
|
18
|
+
*.egg-info
|
|
19
|
+
|
|
20
|
+
# Misc
|
|
21
|
+
.DS_Store
|
|
22
|
+
.idea/
|
|
23
|
+
venv/
|
|
24
|
+
.venv/
|
|
25
|
+
|
|
26
|
+
cache
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# Working on linkedin-api
|
|
2
|
+
|
|
3
|
+
`linkedin_api.Linkedin` is the public Python client. Endpoint methods live in
|
|
4
|
+
`linkedin_api/linkedin.py`. When changing one, check its callers for the
|
|
5
|
+
identifiers they pass, the keys they read, and how they handle empty results.
|
|
6
|
+
Keep those behaviors compatible unless the task calls for an API change.
|
|
7
|
+
Update the corresponding guide in `docs/source/guides/` when usage changes.
|
|
8
|
+
|
|
9
|
+
## Local verification
|
|
10
|
+
|
|
11
|
+
Run commands from the repository root. Use `uv sync --locked --all-groups`
|
|
12
|
+
to reproduce the development environment. Python and uv requirements live in
|
|
13
|
+
`pyproject.toml`.
|
|
14
|
+
|
|
15
|
+
| Change | Check |
|
|
16
|
+
| --- | --- |
|
|
17
|
+
| Python code | `uv run --locked black --check .`, `uv run --locked ruff check .`, `uv run --locked mypy`, and `uv run --locked --group test pytest tests/unit` |
|
|
18
|
+
| Sphinx docs or API docstrings | `uv run --locked --group docs make -C docs html` |
|
|
19
|
+
| Packaging | `uv build` |
|
|
20
|
+
| Dependency constraints | Regenerate `uv.lock` with `uv lock` and include it in the change. Use `uv lock --upgrade` for a full refresh. |
|
|
21
|
+
|
|
22
|
+
## Testing LinkedIn behavior
|
|
23
|
+
|
|
24
|
+
Use `tests/unit/` for offline regressions. For cookie persistence tests,
|
|
25
|
+
pass a temporary cookie directory to `CookieRepository` with a trailing
|
|
26
|
+
path separator. Its default points into the user's home directory.
|
|
27
|
+
|
|
28
|
+
Select live tests individually when the task needs LinkedIn verification.
|
|
29
|
+
The end-to-end suite includes tests that send messages, follow companies,
|
|
30
|
+
and respond to invitations. Use a dedicated test account and keep credentials
|
|
31
|
+
and session cookies out of fixtures, logs, and PRs. For example, to check
|
|
32
|
+
profile retrieval, set all five variables from `.env.example` in a local
|
|
33
|
+
`.env`. The test module checks all five during collection. Then run:
|
|
34
|
+
|
|
35
|
+
```sh
|
|
36
|
+
uv run --locked --group test --env-file .env pytest tests/e2e/test_linkedin_api_requests.py::test_get_profile
|
|
37
|
+
```
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# Contribution guide
|
|
2
|
+
|
|
3
|
+
We welcome contributions! [Learn how to find endpoints](README.md#find-new-endpoints).
|
|
4
|
+
|
|
5
|
+
## How to contribute
|
|
6
|
+
|
|
7
|
+
1. Fork
|
|
8
|
+
1. Write some code (with tests if possible)
|
|
9
|
+
1. Write some docs
|
|
10
|
+
1. Check code formatting.
|
|
11
|
+
In project root folder run `uv run black --check .`
|
|
12
|
+
Proceed in case no issues found. Otherwise run `uv run black .`
|
|
13
|
+
1. Run `uv run --locked ruff check .` and `uv run --locked mypy` from the repository root. Both checks cover the package, tests, examples, and documentation configuration.
|
|
14
|
+
1. Run the tests
|
|
15
|
+
1. Create a pull request on GitHub
|
|
16
|
+
|
|
17
|
+
Public methods return regular Python dictionaries. Use the result types in
|
|
18
|
+
`linkedin_api.models` for records with known fields. Endpoints that pass
|
|
19
|
+
through arbitrary JSON return `JsonObject`. Keep dynamic decoding inside the
|
|
20
|
+
library and preserve existing dictionary keys and empty results.
|
|
21
|
+
|
|
22
|
+
## Releasing to PyPI
|
|
23
|
+
|
|
24
|
+
Before the first release, create the `pypi` environment in the GitHub repository
|
|
25
|
+
settings. In the [PyPI publishing settings for linkedin-api](https://pypi.org/manage/project/linkedin-api/settings/publishing/),
|
|
26
|
+
add a GitHub trusted publisher with owner `tomquirk`, repository `linkedin-api`,
|
|
27
|
+
workflow filename `release.yml`, and environment `pypi`.
|
|
28
|
+
|
|
29
|
+
1. Run `uv version --bump patch` (or choose `minor` or `major`). Commit the
|
|
30
|
+
updated `pyproject.toml` and `uv.lock` together and merge the release changes.
|
|
31
|
+
2. From a clean checkout of the merged release commit, tag and push that version:
|
|
32
|
+
|
|
33
|
+
```sh
|
|
34
|
+
tag="v$(uv version --short)"
|
|
35
|
+
git tag -a "$tag" -m "Release $tag"
|
|
36
|
+
git push origin "refs/tags/$tag"
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
3. Follow **Publish to PyPI** in GitHub Actions. It checks that the tag matches
|
|
40
|
+
the package version, runs the Python checks, and publishes the wheel and
|
|
41
|
+
source distribution once the checks and build pass.
|
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: linkedin-api
|
|
3
|
+
Version: 2.4.0
|
|
4
|
+
Summary: LinkedIn API for Python
|
|
5
|
+
Project-URL: Homepage, https://github.com/tomquirk/linkedin-api
|
|
6
|
+
Project-URL: Repository, https://github.com/tomquirk/linkedin-api
|
|
7
|
+
Project-URL: Documentation, https://linkedin-api.readthedocs.io
|
|
8
|
+
Author-email: Tom Quirk <tom@codalabs.au>
|
|
9
|
+
Maintainer-email: Tom Quirk <tom@codalabs.au>
|
|
10
|
+
License-Expression: MIT
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Keywords: ai,api,automation,bot,company,data,integration,linkedin,network,profiles,scraper,sdk
|
|
13
|
+
Requires-Python: >=3.12
|
|
14
|
+
Requires-Dist: beautifulsoup4<5,>=4.15.0
|
|
15
|
+
Requires-Dist: lxml<7,>=6.2.0
|
|
16
|
+
Requires-Dist: requests<3,>=2.34.2
|
|
17
|
+
Description-Content-Type: text/markdown
|
|
18
|
+
|
|
19
|
+
<div align="center">
|
|
20
|
+
|
|
21
|
+
# LinkedIn API for Python
|
|
22
|
+
|
|
23
|
+

|
|
24
|
+
[](https://linkedin-api.readthedocs.io)
|
|
25
|
+
[](https://pypi.org/project/linkedin-api/)
|
|
26
|
+
[](https://discord.gg/hdd48NEB37)
|
|
27
|
+
|
|
28
|
+
Search profiles, send messages, find jobs, and more with Python. No official LinkedIn API access required.
|
|
29
|
+
|
|
30
|
+
<p align="center">
|
|
31
|
+
<a href="https://linkedin-api.readthedocs.io">Documentation</a>
|
|
32
|
+
·
|
|
33
|
+
<a href="https://linkedin-api.readthedocs.io/en/latest/guides">Guides</a>
|
|
34
|
+
·
|
|
35
|
+
<a href="#quick-start">Quick start</a>
|
|
36
|
+
·
|
|
37
|
+
<a href="#how-it-works">How it works</a>
|
|
38
|
+
</p>
|
|
39
|
+
|
|
40
|
+
</div>
|
|
41
|
+
|
|
42
|
+
> [!IMPORTANT]
|
|
43
|
+
> This is an unofficial library and is not endorsed by LinkedIn.
|
|
44
|
+
> Using this library may violate LinkedIn's Terms of Service and can lead to account restrictions.
|
|
45
|
+
> Use a dedicated test account, respect rate limits, and proceed at your own risk.
|
|
46
|
+
|
|
47
|
+
## Features
|
|
48
|
+
|
|
49
|
+
- No official API access required - authenticate with a valid LinkedIn account.
|
|
50
|
+
- Direct HTTP API interface (no Selenium, Puppeteer, or browser automation).
|
|
51
|
+
- Search and fetch people, companies, jobs, and posts.
|
|
52
|
+
- Read and send messages.
|
|
53
|
+
- Send and accept connection requests.
|
|
54
|
+
- React to posts and fetch engagement data.
|
|
55
|
+
|
|
56
|
+
See the [API reference](https://linkedin-api.readthedocs.io/en/latest/api.html) for the full method list.
|
|
57
|
+
|
|
58
|
+
## Installation
|
|
59
|
+
|
|
60
|
+
> [!NOTE]
|
|
61
|
+
> Python 3.12+ is required.
|
|
62
|
+
|
|
63
|
+
Install from PyPI:
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
pip install linkedin-api
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Install the latest code from GitHub:
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
pip install git+https://github.com/tomquirk/linkedin-api.git
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Quick start
|
|
76
|
+
|
|
77
|
+
Use environment variables instead of hard-coding credentials:
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
export LINKEDIN_USERNAME="you@example.com"
|
|
81
|
+
export LINKEDIN_PASSWORD="your-password"
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
```python
|
|
85
|
+
import os
|
|
86
|
+
|
|
87
|
+
from linkedin_api import Linkedin
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
api = Linkedin(
|
|
91
|
+
os.environ["LINKEDIN_USERNAME"],
|
|
92
|
+
os.environ["LINKEDIN_PASSWORD"],
|
|
93
|
+
)
|
|
94
|
+
|
|
95
|
+
# Get a profile
|
|
96
|
+
profile = api.get_profile("billy-g")
|
|
97
|
+
|
|
98
|
+
# Get profile contact info
|
|
99
|
+
contact_info = api.get_profile_contact_info("billy-g")
|
|
100
|
+
|
|
101
|
+
# Get 1st-degree connections for a profile URN id
|
|
102
|
+
connections = api.get_profile_connections("1234asc12304")
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
More examples are available in `examples/` and in the docs:
|
|
106
|
+
|
|
107
|
+
- Guides: https://linkedin-api.readthedocs.io/en/latest/guides
|
|
108
|
+
- API reference: https://linkedin-api.readthedocs.io/en/latest/api.html
|
|
109
|
+
|
|
110
|
+
## Development
|
|
111
|
+
|
|
112
|
+
### Prerequisites
|
|
113
|
+
|
|
114
|
+
- [`uv`](https://docs.astral.sh/uv/)
|
|
115
|
+
- A LinkedIn account for integration tests (use a non-personal account if possible)
|
|
116
|
+
|
|
117
|
+
### Setup
|
|
118
|
+
|
|
119
|
+
1. Create a local env file from `.env.example`.
|
|
120
|
+
1. Install dependencies:
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
uv sync --locked --all-groups
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### Run tests
|
|
127
|
+
|
|
128
|
+
Run the offline unit suite:
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
uv run --locked --group test pytest tests/unit
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
For live tests, configure all five variables listed in `.env.example` for a
|
|
135
|
+
dedicated test account. To check profile retrieval alone:
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
uv run --locked --group test --env-file .env pytest tests/e2e/test_linkedin_api_requests.py::test_get_profile
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
Running the entire `tests/e2e` directory sends messages, follows companies,
|
|
142
|
+
and can accept or reject pending invitations on that account.
|
|
143
|
+
|
|
144
|
+
### Formatting
|
|
145
|
+
|
|
146
|
+
Check formatting:
|
|
147
|
+
|
|
148
|
+
```bash
|
|
149
|
+
uv run black --check .
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
Fix formatting:
|
|
153
|
+
|
|
154
|
+
```bash
|
|
155
|
+
uv run black .
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
### Troubleshooting
|
|
159
|
+
|
|
160
|
+
#### I keep getting a `CHALLENGE`
|
|
161
|
+
|
|
162
|
+
Linkedin will throw you a curve ball in the form of a Challenge URL. We currently don't handle this, and so you're kinda screwed. We think it could be only IP-based (i.e. logging in from different location). Your best chance at resolution is to log out and log back in on your browser.
|
|
163
|
+
|
|
164
|
+
**Known reasons for Challenge** include:
|
|
165
|
+
|
|
166
|
+
- 2FA
|
|
167
|
+
- Rate-limit - "It looks like you’re visiting a very high number of pages on LinkedIn.". Note - n=1 experiment where this page was hit after ~900 contiguous requests in a single session (within the hour) (these included random delays between each request), as well as a bunch of testing, so who knows the actual limit.
|
|
168
|
+
|
|
169
|
+
Please add more as you come across them.
|
|
170
|
+
|
|
171
|
+
#### Search problems
|
|
172
|
+
|
|
173
|
+
- Mileage may vary when searching general keywords like "software" using the standard `search` method. They've recently added some smarts around search whereby they group results by people, company, jobs etc. if the query is general enough. Try to use an entity-specific search method (i.e. search_people) where possible.
|
|
174
|
+
|
|
175
|
+
## How it works
|
|
176
|
+
|
|
177
|
+
This project attempts to provide a simple Python interface for the LinkedIn API.
|
|
178
|
+
|
|
179
|
+
> Do you mean the [legit LinkedIn API](https://developer.linkedin.com/)?
|
|
180
|
+
|
|
181
|
+
NO! To retrieve structured data, the [LinkedIn Website](https://linkedin.com) uses a service they call **Voyager**. Voyager endpoints give us access to pretty much everything we could want from LinkedIn: profiles, companies, connections, messages, etc. - anything that you can see on linkedin.com, we can get from Voyager.
|
|
182
|
+
|
|
183
|
+
This project aims to provide complete coverage for Voyager.
|
|
184
|
+
|
|
185
|
+
[How does it work?](#deep-dive)
|
|
186
|
+
|
|
187
|
+
### Deep dive
|
|
188
|
+
|
|
189
|
+
Voyager endpoints look like this:
|
|
190
|
+
|
|
191
|
+
```text
|
|
192
|
+
https://www.linkedin.com/voyager/api/identity/profiles/tom-quirk/profileView
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
Or, more clearly
|
|
196
|
+
|
|
197
|
+
```text
|
|
198
|
+
___________________________________ _______________________________
|
|
199
|
+
| base path | resource |
|
|
200
|
+
https://www.linkedin.com/voyager/api /identity/profiles/tom-quirk/profileView
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
They are authenticated with a simple cookie, which we send with every request, along with a bunch of headers.
|
|
204
|
+
|
|
205
|
+
To get a cookie, we POST a given username and password (of a valid LinkedIn user account) to `https://www.linkedin.com/uas/authenticate`.
|
|
206
|
+
|
|
207
|
+
### Find new endpoints
|
|
208
|
+
|
|
209
|
+
We're looking at the LinkedIn website and we spot some data we want. What now?
|
|
210
|
+
|
|
211
|
+
The following describes the most reliable method to find relevant endpoints:
|
|
212
|
+
|
|
213
|
+
1. `view source`
|
|
214
|
+
1. `command-f`/search the page for some keyword in the data. This will exist inside of a `<code>` tag.
|
|
215
|
+
1. Scroll down to the **next adjacent element** which will be another `<code>` tag, probably with an `id` that looks something like
|
|
216
|
+
|
|
217
|
+
```html
|
|
218
|
+
<code style="display: none" id="datalet-bpr-guid-3900675">
|
|
219
|
+
{"request":"/voyager/api/identity/profiles/tom-quirk/profileView","status":200,"body":"bpr-guid-3900675"}
|
|
220
|
+
</code>
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
The value of `request` is the url! 🤘
|
|
224
|
+
|
|
225
|
+
You can also use the `network` tab in you browsers developer tools, but you will encounter mixed results.
|
|
226
|
+
|
|
227
|
+
### How Clients query Voyager
|
|
228
|
+
|
|
229
|
+
linkedin.com uses the [Rest-li Protocol](https://linkedin.github.io/rest.li/spec/protocol) for querying data. Rest-li is an internal query language/syntax where clients (like linkedin.com) specify what data they want. It's conceptually similar to the GraphQL.
|
|
230
|
+
|
|
231
|
+
Here's an example of making a request for an organisation's `name` and `groups` (the Linkedin groups it manages):
|
|
232
|
+
|
|
233
|
+
```text
|
|
234
|
+
/voyager/api/organization/companies?decoration=(name,groups*~(entityUrn,largeLogo,groupName,memberCount,websiteUrl,url))&q=universalName&universalName=linkedin
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
The "querying" happens in the `decoration` parameter, which looks like the following:
|
|
238
|
+
|
|
239
|
+
```text
|
|
240
|
+
(
|
|
241
|
+
name,
|
|
242
|
+
groups*~(entityUrn,largeLogo,groupName,memberCount,websiteUrl,url)
|
|
243
|
+
)
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
Here, we request an organisation name and a list of groups, where for each group we want `largeLogo`, `groupName`, and so on.
|
|
247
|
+
|
|
248
|
+
Different endpoints use different parameters (and perhaps even different syntaxes) to specify these queries. Notice that the above query had a parameter `q` whose value was `universalName`; the query was then specified with the `decoration` parameter.
|
|
249
|
+
|
|
250
|
+
In contrast, the `/search/cluster` endpoint uses `q=guided`, and specifies its query with the `guided` parameter, whose value is something like
|
|
251
|
+
|
|
252
|
+
```text
|
|
253
|
+
List(v->PEOPLE)
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
It could be possible to document (and implement a nice interface for) this query language - as we add more endpoints to this project, I'm sure it will become more clear if such a thing would be possible (and if it's worth it).
|
|
257
|
+
|
|
258
|
+
## Contributing
|
|
259
|
+
|
|
260
|
+
See `CONTRIBUTING.md` for contribution workflow and expectations.
|
|
261
|
+
|
|
262
|
+
## License
|
|
263
|
+
|
|
264
|
+
MIT. See `LICENSE`.
|
|
265
|
+
|
|
266
|
+
## Dependency management
|
|
267
|
+
|
|
268
|
+
Run `uv lock --upgrade` to refresh all dependency groups. The resolver waits seven days after release before selecting new package versions.
|