Registry / data / tranco

tranco

JSON →
library0.8.1pypypi✓ verified 85d ago

A Python library for accessing the Tranco top sites ranking, which is hardened against manipulation. Current version 0.8.1. Released periodically.

pip install tranco
INSTALL
IMPORT
SIG · TRANCO
T
tranco
datapythonv0.8.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Tranco
from tranco import Tranco
Correct import path as of v0.8+

Initialize Tranco client with caching, fetch latest list, and print top 5 domains.

from tranco import Tranco t = Tranco(cache=True, cache_dir='.tranco') latest_list = t.list() print(latest_list.top(10)[:5])
Debug
Known issues
breakingIn v0.8.0, the API changed from `tranco.Tranco()` to `Tranco()` direct import. Old code using `import tranco; t = tranco.Tranco()` may still work but is deprecated.
fix
Use `from tranco import Tranco` and then `Tranco()`.
affects: <0.8.0
deprecatedThe `Tranco.list()` method returns a `TrancoList` object. Accessing `latest_list.top(10)` works, but iterating directly over the list object is deprecated; use `.top()` or `.list()` methods.
fix
Use `latest_list.top(n)` to get top n domains or `list(latest_list)` to get all.
affects: all
gotchaThe `cache` parameter defaults to `True` in v0.8.0+, which caches the list locally. If you have an old cache file, it may prevent fetching a fresh list unless you clear the cache or set `cache=False`.
fix
Set `cache=False` or delete the cache directory (`./.tranco` by default).
affects: >=0.8.0
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'tranco'
The package is not installed or the import path is incorrect.
fix
Install with `pip install tranco` and use `from tranco import Tranco`.
AttributeError: module 'tranco' has no attribute 'Tranco'
Trying to access the class via module incorrectly in older versions or after a bad install.
fix
Use `from tranco import Tranco` and then instantiate with `Tranco()`.
ValueError: The Tranco list is not available for the specified date
Requesting a list for a date that does not exist (e.g., future date or before dataset start).
fix
Use `t.list(date='latest')` or check available dates with `t.available_dates()`.
Upgrade
Version history
0.8.1latest on PyPI · released Apr 2, 2024
Audit
Dependencies

No dependency data recorded yet.

Agent activity
13 hits · last 30 days
node
10
OpenAI (training)
1
Resources
tranco — pip install tranco · libregistry