--- id: publicsuffix2 version: "2.20191221" license: MIT and MPL-2.0 license_treatment: copyleft maintenance: abandoned --- # publicsuffix2 — Get a public suffix for a domain name using the Public Suffix List. Forked from and using the same API as the publicsuffix package. License: copyleft · Maintenance: abandoned · Downloads: 7.6M/mo ## What it is and what it does publicsuffix2 is a Python module that parses domain names against the Public Suffix List to identify the public suffix (effective TLD) and registrable domain. It builds the PSL as a Trie structure for efficient lookup, making it suitable for large-scale processing. The module comes bundled with a copy of the PSL so it works out of the box, though that data is from 2019-12-21. The package supports several query modes: extracting the registrable domain (base domain), returning only the effective TLD, handling IDNA-encoded domains, ignoring wildcards for aggregation, and strict validation to reject domains with invalid TLDs. It exposes both convenience functions (get_public_suffix, get_sld, get_tld) and a PublicSuffixList class for finer control. However, the project is abandoned—no releases or commits since late 2021—so the bundled data will not reflect newly added public suffixes. Use it for: - Extract the registrable domain from a URL for web browser cookie scope management. - Identify the effective TLD of a domain to highlight the most important part in a user interface. - Aggregate and sort URLs by website in large-scale domain processing or DNS research. - Validate that a domain includes a recognized public suffix using strict mode. - Handle internationalized domain names (IDN) by toggling IDNA encoding on or off. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Extracts the public suffix and registrable domain from a domain name using the Public Suffix List, with support for IDNA encoding, wildcard handling, and strict validation. Yes, if your domain processing needs are static or historical. The package has no dependencies, low install friction, and a stable API. However, do not use it if you require current public suffix data—the bundled list is from 2019-12-21 and the project is abandoned. Use fetch() to pull the latest list at runtime, or consider an actively maintained alternative if freshness is critical. ## Install pip install publicsuffix2 uv add publicsuffix2 poetry add publicsuffix2 ## Installing publicsuffix2 Before you install: Low install friction with no runtime dependencies. However, the package is abandoned—last commit was 2021-11-02 and no releases since 2019-12-21. The Public Suffix List data bundled with the package will become stale over time. License in practice: Dual-licensed under MIT and MPL-2.0 (copyleft). The code is MIT-licensed but the bundled Public Suffix List data is MPL-2.0-licensed, which imposes copyleft obligations on derivative works of the data. Quickstart: pip install publicsuffix2 from publicsuffix2 import get_public_suffix result = get_public_suffix('www.example.co.uk') # result: 'example.co.uk' The bundled Public Suffix List data is from 2019-12-21 and will not reflect newer public suffixes; use fetch() to download the latest list if current data is critical. Verify before relying: - Whether the stale bundled PSL (from 2019-12-21) is acceptable for your domain processing use case. - Performance characteristics of the Trie-based implementation in your specific workload or scale. ## Package facts - License: MIT and MPL-2.0 (copyleft) - Python support: unspecified - Install friction: low - Maintenance: abandoned - Downloads: 7.6M/month (top 5,000 on PyPI) - Known vulnerabilities: none known ## Tags public suffix list parser, extract registrable domain, domain name parsing, tld extraction, etld lookup, domain cookie handling, dns domain analysis, domain-parsing, psl-lookup, dns-utilities [View on SkillFed](https://skillfed.io/packages/publicsuffix2) · [View on PyPI](https://pypi.org/project/publicsuffix2/)