Social Links

Detect, validate, and sanitize social media links in Python

Gallery image 1
Gallery image 2

Detect, validate, sanitize, and parse IDs from social profile URLs: many platforms, no extra dependencies

social-links is a pure Python helper for social URLs: auto-detect platform, check a link against a named platform, normalize to a canonical shape, and extract usernames or IDs. The README ships 65+ predefined platforms (major networks plus developer and creator sites) and allows custom regex-based platforms when you need more.

When it is useful

You ingest profile links from users, build directory or signup flows, or clean UGC before storage. Install from PyPI; docs and a browser demo are linked from the repository.

What you can do

  • Call the module-level API for typical cases or the SocialLinks class when you need custom lists or regex flags.
  • Extend or override platform definitions for internal domains or new networks.
  • Rely on pattern-based matching; understand that edge-case URLs may still need human review.

Limits

  • Validation is regex-driven, not a live probe of whether an account exists or is safe.
  • Platforms change URLs over time; pin versions and add tests for links you care about.
  • Phishing and lookalike domains are a separate security concern; do not treat “valid shape” as “trusted site.”

Frequently asked questions

What does Social Links do?

It is a pure Python, zero-dependency library for social profile URLs: auto-detect the platform, validate a link against a named platform, normalize to a canonical shape, and extract usernames or IDs.

How many platforms are included?

The README ships 65+ predefined platforms (major networks plus developer and creator sites). You can add or override platforms with custom regex patterns via the SocialLinks class.

How do I install it?

Install from PyPI with pip install social-links, or use uv pip install social-links. Module-level helpers cover typical cases; use the SocialLinks class when you need custom lists or regex flags.

Does validation prove an account exists?

No. Matching is regex-driven, not a live probe of whether an account exists or is safe. Treat valid shape as separate from trust; phishing and lookalike domains still need their own checks.

Continue exploring