{"id":24375,"library":"pypistats","title":"PyPI Stats","description":"Python interface to the PyPI Stats API (https://pypistats.org/api). Provides programmatic and CLI access to download statistics for Python packages. Current version 1.13.0, requires Python >=3.10. Releases approximately every few months.","status":"active","version":"1.13.0","language":"python","source_language":"en","source_url":"https://github.com/hugovk/pypistats","tags":["pypi-stats","downloads","cli","api-wrapper"],"install":[{"cmd":"pip install pypistats","lang":"bash","label":"Install from PyPI"}],"dependencies":[{"reason":"HTTP client (replaced httpx in 1.12.0)","package":"urllib3","optional":false},{"reason":"CLI output formatting","package":"rich","optional":true}],"imports":[{"note":"The main module is importable directly as a package.","symbol":"pypistats","correct":"import pypistats"},{"note":"recent is a module inside the package; import it as shown.","wrong":"import pypistats.recent","symbol":"recent","correct":"from pypistats import recent"}],"quickstart":{"code":"import pypistats\n\n# Get recent downloads for a package\ndata = pypistats.recent('requests', format='json')\nprint(data[:200])  # first 200 characters\n\n# CLI equivalent: pypistats recent requests","lang":"python","description":"Fetches recent download stats for a package in JSON format."},"warnings":[{"fix":"Upgrade to Python 3.10+ or pin pypistats<1.12.0.","message":"Dropped support for Python 3.9 in version 1.12.0.","severity":"breaking","affected_versions":"<1.12.0"},{"fix":"Use only the public API; do not depend on httpx-related behavior.","message":"HTTP client changed from httpx to urllib3 in 1.12.0. Code relying on httpx internals will break.","severity":"breaking","affected_versions":">=1.12.0"},{"fix":"Specify format='json' or other explicit format.","message":"The 'format=None' option returns raw Python data structure (added in 1.8.0); not formally deprecated but may change.","severity":"deprecated","affected_versions":">=1.8.0"},{"fix":"Ensure you pass a string package name to the Python functions.","message":"Package name validation: CLI accepts directory containing pyproject.toml/setup.cfg to infer package name (since 1.11.0), but the library API expects a string.","severity":"gotcha","affected_versions":">=1.11.0"},{"fix":"If parsing output, update your regex or use format='json'.","message":"The CLI table format changed from MARKDOWN/SINGLE_BORDER to TableStyle in 1.8.0 to fix DeprecationWarnings.","severity":"gotcha","affected_versions":">=1.8.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Use `from pypistats import recent` or `import pypistats; pypistats.recent(...)`.","cause":"Attempting to import submodule as if it's a nested package; `recent` is a module inside `pypistats` but should be imported with `from pypistats import recent`.","error":"ModuleNotFoundError: No module named 'pypistats.recent'"},{"fix":"Explicitly `import pypistats.recent` (though `from pypistats import recent` is cleaner).","cause":"Importing the package but forgetting to import the submodule.","error":"AttributeError: module 'pypistats' has no attribute 'recent'"},{"fix":"Use one of the accepted formats: format='json' (or 'csv', 'markdown', None).","cause":"Passing invalid format string; valid values are 'json', 'csv', 'markdown', or None.","error":"ValueError: Unsupported format: json"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}