Skip to main content

qodev-linkedin-api

Async Python client for LinkedIn data export API.

Installation

pip install qodev-linkedin-api
# or
uv add qodev-linkedin-api

From GitHub (alternative)

uv add qodev-linkedin-api --source git+ssh://git@github.com/qodevai/linkedin-api.git

For development

git clone git@github.com:qodevai/linkedin-api.git
cd linkedin-api
make install
make install-hooks  # Set up pre-commit hooks

Quick Start

make install        # Install dependencies
make install-hooks  # Set up pre-commit hooks (recommended)
make check          # Run all quality checks
make test           # Run tests with coverage

Usage

Basic Usage

import asyncio
from linkedin import LinkedInClient

async def main():
    async with LinkedInClient() as client:
        # Get all connections
        connections = await client.get_connections()
        for conn in connections:
            print(f"{conn.first_name} {conn.last_name} - {conn.company}")

        # Get invitations (both sent and received)
        invitations = await client.get_invitations()

        # Get only outgoing invitations
        sent = await client.get_outgoing_invitations()

        # Get inbox messages
        messages = await client.get_inbox()

        # Get changelog (API changes tracking)
        changelog = await client.get_changelog()

asyncio.run(main())

Configuration

from linkedin import LinkedInClient

# Auth token from environment variable (default)
# Set LINKEDIN_AUTH_TOKEN env var
client = LinkedInClient()

# Or pass token directly
client = LinkedInClient(auth_token="your-token-here")

# Custom API version and timeout
client = LinkedInClient(
    api_version="202312",  # LinkedIn API version
    timeout=60.0,          # Request timeout in seconds
)

Error Handling

from linkedin import (
    LinkedInClient,
    AuthenticationError,
    RateLimitError,
    APIError,
)

async def fetch_with_retry():
    try:
        async with LinkedInClient() as client:
            return await client.get_connections()
    except AuthenticationError:
        print("Invalid or expired token")
    except RateLimitError as e:
        print(f"Rate limited. Retry after: {e.retry_after} seconds")
    except APIError as e:
        print(f"API error {e.status_code}: {e}")

Models

All responses are typed Pydantic models:

from linkedin import Connection, Invitation, Message, ChangeLogEntry

# Connection fields
conn: Connection
conn.url           # LinkedIn profile URL
conn.first_name
conn.last_name
conn.email         # Optional
conn.company       # Optional
conn.position      # Optional
conn.connected_on  # Date string

# Invitation fields
inv: Invitation
inv.to
inv.invitee_profile_url
inv.message        # Optional
inv.direction      # "OUTGOING" or "INCOMING"
inv.sent_at        # Date string

# Message fields
msg: Message
msg.conversation_id
msg.from_member
msg.to_member      # Optional
msg.content
msg.date           # Date string
msg.subject        # Optional
msg.folder         # Optional

# ChangeLogEntry fields
entry: ChangeLogEntry
entry.id
entry.method
entry.resource_name
entry.captured_at          # Unix timestamp (ms)
entry.processed_at         # Unix timestamp (ms)
entry.captured_datetime    # Property: datetime object
entry.processed_datetime   # Property: datetime object

Development

Available Commands

make help           # Show all available commands
make install        # Install all dependencies
make install-hooks  # Install pre-commit hooks
make check          # Run all checks (lint, format, typecheck, typos)
make test           # Run tests with coverage
make test-fast      # Run tests without coverage
make lint           # Lint code with ruff
make lint-fix       # Auto-fix lint issues
make format         # Format code with ruff
make typecheck      # Run type checking with pyright
make typos          # Check for typos
make build          # Build package (sdist + wheel)
make clean          # Clean generated files

Pre-commit Hooks

Pre-commit hooks run automatically on every commit:

make install-hooks  # Install once

Hooks include:

  • YAML/TOML/JSON validation
  • Trailing whitespace removal
  • Ruff linting and formatting
  • Typos spell checking

Running Checks Manually

# Run all checks (recommended before committing)
make check

# Or run individual checks
make lint
make format-check
make typecheck
make typos

Environment Variables

Variable Description
LINKEDIN_AUTH_TOKEN LinkedIn API auth token (required if not passed to client)

Requirements

  • Python 3.11+
  • uv (for development)

License

MIT

Metadata

Release files for qodev-linkedin-api 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for qodev-linkedin-api 0.3.0
File Size Uploaded
qodev_linkedin_api-0.3.0.tar.gz 10.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for qodev-linkedin-api 0.3.0
File Interpreter ABI Platform
qodev_linkedin_api-0.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 19.7 kB

Release files / qodev_linkedin_api-0.3.0.tar.gz

Download URL qodev_linkedin_api-0.3.0.tar.gz
Size 10.9 kB
Tags Source
SHA-256 checksum
How to use checksums
37239b7deb3005b3a734c8f25040ec59213c59f9a56b30c88aa9fa41df703d28
BLAKE2b-256 checksum
How to use checksums
4f23ca80605f5f10c5914fb86e47348513a3666c615885c17a0cf88f783d9a37
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Feb 24, 2026.

Transparency log

Release files / qodev_linkedin_api-0.3.0-py3-none-any.whl

Download URL qodev_linkedin_api-0.3.0-py3-none-any.whl
Size 8.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
03852138dbc9110b7a60db95ea549fff29e858174de4f3c8b1658c5a80d48608
BLAKE2b-256 checksum
How to use checksums
4fc8bd62e16ac5017162217c7c3628fd8d7e0cbdee56bbd1352fe3670c0d0689
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Feb 24, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page