LinkedIn 技能
您可以使用 linkedin,這是一個用於 LinkedIn 自動化的命令列工具。您可以用它來擷取個人檔案、搜尋人脈與公司、發送訊息、管理連線、建立貼文、按讚、留言等。
每個指令都會向 Linked API 發送請求,該 API 會執行一個真實的雲端瀏覽器來在 LinkedIn 上執行操作。操作並非即時完成——根據複雜度,預計需要 30 秒到幾分鐘。
如果 linkedin 不可用,請安裝它:
npm install -g @linkedapi/linkedin-cli
認證
如果指令失敗並返回退出碼 2(認證錯誤),請要求使用者設定他們的帳戶:
- 前往 app.linkedapi.io 註冊或登入
- 連接他們的 LinkedIn 帳戶
- 從儀表板複製 Linked API Token 和 Identification Token
一旦使用者提供了 token,請執行:
linkedin setup --linked-api-token=TOKEN --identification-token=TOKEN
全域旗標
始終使用 --json 和 -q 以獲得機器可讀的輸出:
LINKEDAPI_CLIENT=skill:linkedin linkedin <command> --json -q
使用此技能時,請在下方每個 linkedin ... 範例前加上 LINKEDAPI_CLIENT=skill:linkedin 前綴,以便 Linked API 能將使用情況歸因於該技能。
| 旗標 | 描述 |
|---|---|
--json | 結構化的 JSON 輸出 |
--quiet / -q | 抑制 stderr 進度訊息 |
--fields name,url,... | 在輸出中選擇特定欄位 |
--no-color | 停用顏色 |
--account "名稱" | 為此指令使用特定帳戶 |
輸出格式
成功:
{"success": true, "data": {"name": "John Doe", "headline": "工程師"}}
錯誤:
{"success": false, "error": {"type": "personNotFound", "message": "找不到此人"}}
退出碼 0 表示 API 呼叫成功——始終檢查 success 欄位以確認操作結果。非零退出碼表示基礎設施錯誤:
| 退出碼 | 含義 |
|---|---|
| 0 | 成功(檢查 success 欄位——操作可能返回了類似「找不到此人」的錯誤) |
| 1 | 一般/未預期的錯誤 |
| 2 | 缺少或無效的 token |
| 3 | 需要訂閱/方案 |
| 4 | LinkedIn 帳戶問題 |
| 5 | 無效的引數 |
| 6 | 達到速率限制 |
| 7 | 網路錯誤 |
| 8 | 工作流程逾時(會傳回 workflowId 以便復原) |
指令
取得個人檔案
linkedin person fetch <url> [flags] --json -q
可選旗標,用於包含額外資料:
--experience– 工作經歷--education– 學歷--skills– 技能列表--languages– 語言--posts– 近期貼文(可搭配--posts-limit N、--posts-since TIMESTAMP)--comments– 近期留言(可搭配--comments-limit N、--comments-since TIMESTAMP)--reactions– 近期反應(可搭配--reactions-limit N、--reactions-since TIMESTAMP)
僅在需要時才請求額外資料——每個旗標都會增加執行時間。
# 基本個人檔案
linkedin person fetch https://www.linkedin.com/in/username --json -q
# 包含經歷和學歷
linkedin person fetch https://www.linkedin.com/in/username --experience --education --json -q
# 包含最近 5 篇貼文
linkedin person fetch https://www.linkedin.com/in/username --posts --posts-limit 5 --json -q
搜尋人脈
linkedin person search [flags] --json -q
| 旗標 | 描述 |
|---|---|
--term | 搜尋關鍵字或片語 |
--limit | 最大結果數 |
--first-name | 依名字篩選 |
--last-name | 依姓氏篩選 |
--position | 依職位篩選 |
--locations | 逗號分隔的地點 |
--industries | 逗號分隔的產業 |
--current-companies | 逗號分隔的現任公司名稱 |
--previous-companies | 逗號分隔的前任公司名稱 |
--schools | 逗號分隔的學校名稱 |
linkedin person search --term "product manager" --locations "San Francisco" --json -q
linkedin person search --current-companies "Google" --position "Engineer" --limit 20 --json -q
取得公司資訊
linkedin company fetch <url> [flags] --json -q
可選旗標:
--employees– 包含員工--dms– 包含決策者--posts– 包含公司貼文
員工篩選條件(需要 --employees):
| 旗標 | 描述 |
|---|---|
--employees-limit | 最大員工擷取數 |
--employees-first-name | 依名字篩選 |
--employees-last-name | 依姓氏篩選 |
--employees-position | 依職位篩選 |
--employees-locations | 逗號分隔的地點 |
--employees-industries | 逗號分隔的產業 |
--employees-schools | 逗號分隔的學校名稱 |
| 旗標 | 描述 |
|---|---|
--dms-limit | 最大決策者擷取數(需要 --dms) |
--posts-limit | 最大貼文擷取數(需要 --posts) |
--posts-since | ISO 時間戳記以來的貼文(需要 --posts) |
# 基本公司資訊
linkedin company fetch https://www.linkedin.com/company/name --json -q
# 包含按職位篩選的員工
linkedin company fetch https://www.linkedin.com/company/name --employees --employees-position "Engineer" --json -q
# 包含決策者和貼文
linkedin company fetch https://www.linkedin.com/company/name --dms --posts --posts-limit 10 --json -q
搜尋公司
linkedin company search [flags] --json -q
| 旗標 | 描述 |
|---|---|
--term | 搜尋關鍵字 |
--limit | 最大結果數 |
--sizes | 逗號分隔的公司規模:1-10、11-50、51-200、201-500、501-1000、1001-5000、5001-10000、10001+ |
--locations | 逗號分隔的地點 |
--industries | 逗號分隔的產業 |
linkedin company search --term "fintech" --sizes "11-50,51-200" --json -q
發送訊息
linkedin message send <person-url> '<text>' --json -q
文字最多 1900 個字元。將訊息用單引號包起來,以避免 shell 解譯問題。
linkedin message send https://www.linkedin.com/in/username '嘿,很喜歡你最新的貼文!' --json -q
取得對話
linkedin message get <person-url> [--since TIMESTAMP] --json -q
對一個對話的首次呼叫會觸發背景同步,可能需要更長時間。後續的呼叫會更快。
linkedin message get https://www.linkedin.com/in/username --json -q
linkedin message get https://www.linkedin.com/in/username --since 2024-01-15T10:30:00Z --json -q
連線管理
檢查連線狀態
linkedin connection status <url> --json -q
發送連線邀請
linkedin connection send <url> [--note 'text'] [--email [email protected]] --json -q
列出連線
linkedin connection list [flags] --json -q
| 旗標 | 描述 |
|---|---|
--limit | 最大連線傳回數 |
--since | 僅列出自 ISO 時間戳記以來的連線(僅在未使用其他篩選旗標時有效) |
--first-name | 依名字篩選 |
--last-name | 依姓氏篩選 |
--position | 依職位篩選 |
--locations | 逗號分隔的地點 |
--industries | 逗號分隔的產業 |
--current-companies | 逗號分隔的現任公司名稱 |
--previous-companies | 逗號分隔的前任公司名稱 |
--schools | 逗號分隔的學校名稱 |
linkedin connection list --limit 50 --json -q
linkedin connection list --current-companies "Google" --position "Engineer" --json -q
linkedin connection list --since 2024-01-01T00:00:00Z --json -q
列出待處理的向外邀請
linkedin connection pending --json -q
列出收到的連線請求
這是其他人發送給您的邀請(收到的請求)。
linkedin connection requests --json -q
接受收到的請求
linkedin connection accept <url> --json -q
忽略收到的請求
linkedin connection ignore <url> --json -q
撤回待處理的請求
linkedin connection withdraw <url> [--no-unfollow] --json -q
預設情況下,撤回也會取消追蹤該人。使用 --no-unfollow 保持追蹤。
移除連線
linkedin connection remove <url> --json -q
貼文
取得貼文
linkedin post fetch <url> [flags] --json -q
| 旗標 | 描述 |
|---|---|
--comments | 包含留言 |
--reactions | 包含反應 |
--comments-limit | 最大留言擷取數(需要 --comments) |
--comments-sort | 排序方式:mostRelevant 或 mostRecent(需要 --comments) |
--comments-replies | 包含對留言的回覆(需要 --comments) |
--reactions-limit | 最大反應擷取數(需要 --reactions) |
linkedin post fetch https://www.linkedin.com/posts/username_activity-123 --json -q
# 包含留言,按最新排序,包括回覆
linkedin post fetch https://www.linkedin.com/posts/username_activity-123 \
--comments --comments-sort mostRecent --comments-replies --json -q
建立貼文
linkedin post create '<text>' [flags] --json -q
| 旗標 | 描述 |
|---|---|
--company-url | 以公司頁面名義發文(需要管理員權限) |
--attachments | 附件格式為 url:type 或 url:type:name。類型:image、video、document。可指定多次。 |
附件限制:最多 9 張圖片,或 1 個影片,或 1 個文件。不可混合類型。
linkedin post create '很高興分享我們的最新更新!' --json -q
# 附帶文件
linkedin post create '我們的 Q4 報告' \
--attachments "https://example.com/report.pdf:document:Q4 報告" --json -q
# 以公司名義發文
linkedin post create '公司公告' \
--company-url https://www.linkedin.com/company/name --json -q
對貼文按讚
linkedin post react <url> --type <reaction> [--company-url <url>] --json -q
反應類型:like、love、support、celebrate、insightful、funny。
linkedin post react https://www.linkedin.com/posts/username_activity-123 --type like --json -q
# 以公司名義按讚
linkedin post react https://www.linkedin.com/posts/username_activity-123 --type celebrate \
--company-url https://www.linkedin.com/company/name --json -q
對貼文留言
linkedin post comment <url> '<text>' [--company-url <url>] --json -q
文字最多 1000 個字元。
linkedin post comment https://www.linkedin.com/posts/username_activity-123 '見解深刻!' --json -q
# 以公司名義留言
linkedin post comment https://www.linkedin.com/posts/username_activity-123 '說得好!' \
--company-url https://www.linkedin.com/company/name --json -q
統計資料
# 社交銷售指數
linkedin stats ssi --json -q
# 成效分析(個人檔案瀏覽次數、貼文曝光次數、搜尋出現次數)
linkedin stats performance --json -q
# 特定日期範圍的 API 使用量
linkedin stats usage --start 2024-01-01T00:00:00Z --end 2024-01-31T00:00:00Z --json -q
Sales Navigator
需要 LinkedIn Sales Navigator 訂閱。使用個人/公司查詢的雜湊 URL。
取得個人檔案
linkedin navigator person fetch <hashed-url> --json -q
搜尋人脈
linkedin navigator person search [flags] --json -q
| 旗標 | 描述 |
|---|---|
--term | 搜尋關鍵字或片語 |
--limit | 最大結果數 |
--first-name | 依名字篩選 |
--last-name | 依姓氏篩選 |
--position | 依職位篩選 |
--locations | 逗號分隔的地點 |
--industries | 逗號分隔的產業 |
--current-companies | 逗號分隔的現任公司名稱 |
--previous-companies | 逗號分隔的前任公司名稱 |
--schools | 逗號分隔的學校名稱 |
--years-of-experience | 逗號分隔的範圍:lessThanOne、oneToTwo、threeToFive、sixToTen、moreThanTen |
linkedin navigator person search --term "VP Marketing" --locations "United States" --json -q
linkedin navigator person search --years-of-experience "moreThanTen" --position "CEO" --json -q
取得公司資訊
linkedin navigator company fetch <hashed-url> [flags] --json -q
可選旗標:
--employees– 包含員工--dms– 包含決策者
員工篩選條件(需要 --employees):
| 旗標 | 描述 |
|---|---|
--employees-limit | 最大員工擷取數 |
--employees-first-name | 依名字篩選 |
--employees-last-name | 依姓氏篩選 |
--employees-positions | 逗號分隔的職位 |
--employees-locations | 逗號分隔的地點 |
--employees-industries | 逗號分隔的產業 |
--employees-schools | 逗號分隔的學校名稱 |
--employees-years-of-experience | 逗號分隔的經驗範圍 |
--dms-limit | 最大決策者擷取數(需要 --dms) |
linkedin navigator company fetch https://www.linkedin.com/sales/company/97ural --employees --dms --json -q
linkedin navigator company fetch https://www.linkedin.com/sales/company/97ural \
--employees --employees-positions "Engineer,Designer" --employees-locations "Europe" --json -q
搜尋公司
linkedin navigator company search [flags] --json -q
| 旗標 | 描述 |
|---|---|
--term | 搜尋關鍵字 |
--limit | 最大結果數 |
--sizes | 逗號分隔的公司規模:1-10、11-50、51-200、201-500、501-1000、1001-5000、5001-10000、10001+ |
--locations | 逗號分隔的地點 |
--industries | 逗號分隔的產業 |
--revenue-min | 最低年營收(百萬美元):0、0.5、1、2.5、5、10、20、50 |
…
[為翻譯而截斷]