名称: linkdapi
描述: 使用 LinkdAPI Python SDK 访问 LinkedIn 专业个人档案与公司数据。当需要获取个人档案信息、公司数据、职位列表或在 LinkedIn 上搜索人员/职位时使用。本技能采用 uv 脚本模式,支持内联依赖的临时 Python 脚本。
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 脚本块开始:
# /// 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 数据时:
"linkdapi",按需添加其他)uv run 运行用户:"获取 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
要使用 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"))
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