OA0 = Omni AI 0
OA0 是一个探索 AI 的论坛
现在注册
已注册用户请  登录
OA0  ›  技能包  ›  linkdapi:使用 LinkdAPI Python SDK 访问 LinkedIn 职业资料资料

linkdapi:使用 LinkdAPI Python SDK 访问 LinkedIn 职业资料资料

 
  api ·  2026-02-25 06:26:17 · 2 次点击  · 0 条评论  

名称: linkdapi
描述: 使用 LinkdAPI Python SDK 访问 LinkedIn 专业个人档案与公司数据。当需要获取个人档案信息、公司数据、职位列表或在 LinkedIn 上搜索人员/职位时使用。本技能采用 uv 脚本模式,支持内联依赖的临时 Python 脚本。


LinkdAPI Python SDK

LinkdAPI Python SDK —— 以企业级可靠性从 LinkedIn 获取专业个人档案与公司数据。

获取 API 密钥: https://linkdapi.com/signup?ref=K_CZJSWF

快速开始模式

使用 uv 脚本模式 来编写带有内联依赖的临时 Python 脚本:

# /// script
# dependencies = [
#     "linkdapi",
# ]
# ///

from linkdapi import LinkdAPI

client = LinkdAPI("YOUR_API_KEY")
profile = client.get_profile_overview("ryanroslansky")
print(profile)

运行脚本:

uv run script.py

此模式会自动安装依赖、运行脚本并清理环境,非常适合一次性任务。

为何采用此模式

  • 无需全局安装:依赖项按脚本管理
  • 设计为临时性:编写、运行、删除 —— 无需清理
  • 可复现:所有必需内容都在一个文件中
  • 快速:uv 处理依赖解析与缓存

编写脚本

脚本头部格式

始终以 uv 脚本块开始:

# /// script
# dependencies = [
#     "linkdapi",
#     # 按需添加更多依赖(例如 "rich", "pandas")
# ]
# ///

常见任务

获取个人档案概览:

# /// script
# dependencies = ["linkdapi"]
# ///

from linkdapi import LinkdAPI

client = LinkdAPI("YOUR_API_KEY")
profile = client.get_profile_overview("ryanroslansky")

if profile.get('success'):
    data = profile['data']
    print(f"{data['fullName']} - {data.get('headline', '')}")
    print(f"Location: {data.get('location')}")

获取公司信息:

# /// script
# dependencies = ["linkdapi"]
# ///

from linkdapi import LinkdAPI

client = LinkdAPI("YOUR_API_KEY")
company = client.get_company_info(name="google")

if company.get('success'):
    data = company['data']
    print(f"{data['name']}")
    print(f"Industry: {data.get('industry')}")
    print(f"Employees: {data.get('employeeCount', 'N/A')}")

搜索职位:

# /// script
# dependencies = ["linkdapi"]
# ///

from linkdapi import LinkdAPI

client = LinkdAPI("YOUR_API_KEY")
result = client.search_jobs(
    keyword="Software Engineer",
    location="San Francisco, CA",
    time_posted="1week"
)

if result.get('success'):
    for job in result['data']['jobs'][:5]:
        print(f"{job['title']} at {job['company']}")

批量档案信息丰富(异步):

# /// script
# dependencies = ["linkdapi"]
# ///

import asyncio
from linkdapi import AsyncLinkdAPI

async def enrich():
    async with AsyncLinkdAPI("YOUR_API_KEY") as api:
        profiles = await asyncio.gather(
            api.get_profile_overview("ryanroslansky"),
            api.get_profile_overview("satyanadella"),
            api.get_profile_overview("jeffweiner08")
        )
        for p in profiles:
            if p.get('success'):
                print(p['data']['fullName'])

asyncio.run(enrich())

智能体工作流

当用户请求 LinkedIn 数据时:

  1. 识别任务(个人档案查询、公司数据、职位搜索等)
  2. 在临时工作区编写脚本,包含 uv 脚本头部
  3. 添加依赖项(通常只需 "linkdapi",按需添加其他)
  4. 导入并使用 LinkdAPI 类
  5. 使用 uv run 运行
  6. 捕获输出并报告给用户
  7. 使用后删除脚本(可选)

工作流示例

用户:"获取 jeffweiner08 的个人档案"

智能体:

cat > /tmp/linkdapi_query.py << 'EOF'
# /// script
# dependencies = ["linkdapi"]
# ///

from linkdapi import LinkdAPI
import os

client = LinkdAPI(os.getenv("LINKDAPI_API_KEY"))
profile = client.get_profile_overview("jeffweiner08")

if profile.get('success'):
    data = profile['data']
    print(f"Name: {data['fullname']}")
    print(f"Headline: {data.get('headline', 'N/A')}")
    print(f"Location: {data.get('location', 'N/A')}")
    print(f"Company: {data.get('company', 'N/A')}")
else:
    print(f"Error: {profile.get('message')}")
EOF

uv run /tmp/linkdapi_query.py
rm /tmp/linkdapi_query.py

获取 API 密钥

要使用 LinkdAPI,您需要一个 API 密钥。请在此注册:

🔗 https://linkdapi.com/signup?ref=K_CZJSWF

注册后,您将获得一个用于身份验证请求的 API 密钥。

身份验证

将 API 密钥设置为环境变量:

export LINKDAPI_API_KEY="your_api_key_here"

在脚本中使用:

import os
from linkdapi import LinkdAPI

client = LinkdAPI(os.getenv("LINKDAPI_API_KEY"))

核心 API 方法

个人档案

  • get_profile_overview(username) —— 基本档案信息
  • get_profile_details(urn) —— 详细档案数据
  • get_contact_info(username) —— 邮箱、电话、网站
  • get_full_profile(username=None, urn=None) —— 完整档案
  • get_full_experience(urn) —— 工作经历
  • get_education(urn) —— 教育背景
  • get_skills(urn) —— 技能与认可

公司

  • get_company_info(company_id=None, name=None) —— 公司详情
  • company_name_lookup(query) —— 按名称搜索
  • get_company_employees_data(company_id) —— 员工统计数据
  • get_company_jobs(company_ids) —— 职位列表

职位

  • search_jobs(keyword, location, ...) —— 搜索职位发布
  • get_job_details(job_id) —— 详细职位信息

搜索

  • search_people(keyword, title, company, ...) —— 查找人员
  • search_companies(keyword, industry, ...) —— 查找公司
  • search_posts(keyword, ...) —— 查找帖子

性能提示

  • 批量操作时使用 AsyncLinkdAPI(速度提升 40 倍)
  • asyncio.gather() 中添加 return_exceptions=True 以实现优雅的错误处理
  • 使用上下文管理器(async with)以确保正确清理资源

错误处理

检查响应并处理错误:

result = client.get_profile_overview("username")

if result.get('success'):
    data = result['data']
    # 处理数据
else:
    print(f"API Error: {result.get('message')}")

参考文档

完整 API 文档:https://linkdapi.com/docs

2 次点击  ∙  0 人收藏  
登录后收藏  
目前尚无回复
0 条回复
About   ·   Help   ·    
OA0 - Omni AI 0 一个探索 AI 的社区
沪ICP备2024103595号-2
Developed with Cursor