# PyPi download statistics for several packages or for all packages from a user
## pip install pipuserstats
```python
Retrieves download statistics for a given user or package(s) from PyPI Stats API.
Args:
username_or_packages (str | tuple | list): The username or package(s) to retrieve statistics for.
If a string is passed, username_or_packages will be treated as a username. If a list/tuple is passed,
username_or_packages will be treated as packages.
sleeptime (float | int, optional): The time to sleep between API requests. Defaults to 1.0.
clear_cache (bool, optional): Whether to clear the PyPI Stats API cache before retrieving statistics.
Defaults to False.
Returns:
pd.DataFrame: A pandas DataFrame containing the download statistics for the given user or package(s).
Raises:
Exception: If an error occurs while retrieving statistics for a package.
from pipuserstats import get_user_pip_stats
df = get_user_pip_stats(
username_or_packages="hansalemao", sleeptime=1, clear_cache=False
)
print(df)
"""
# -1 means "no data available"
total 2023-04-20 ... 2022-10-23 2022-10-22
a-cv-imwrite-imread-plus 3593 31 ... -1 -1
a-cv-sift-detection 244 -1 ... -1 -1
a-cv2-calculate-difference 279 2 ... -1 -1
a-cv2-calculate-simlilarity 339 2 ... -1 -1
a-cv2-easy-resize 2223 24 ... -1 -1
... ... ... ... ...
"""
df = get_user_pip_stats(
username_or_packages=["pandas", "numpy"], sleeptime=0.5, clear_cache=False
)
"""
df
Out[4]:
total 2023-04-20 2023-04-19 ... 2022-10-24 2022-10-23 2022-10-22
pandas 639313100 4258267 4265098 ... 3721798 2540678 2738365
numpy 843036266 5667169 5747109 ... 4882242 3261557 3556995
[2 rows x 181 columns]
"""
"""
```
Raw data
{
"_id": null,
"home_page": "https://github.com/hansalemaos/pipuserstats",
"name": "pipuserstats",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "pypi,stats",
"author": "Johannes Fischer",
"author_email": "aulasparticularesdealemaosp@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/75/12/122b85f568b1e933df30ccda402ae995dddf72572d3b0a83a8acdaf1bf31/pipuserstats-0.10.tar.gz",
"platform": null,
"description": "# PyPi download statistics for several packages or for all packages from a user\r\n\r\n## pip install pipuserstats\r\n\r\n\r\n\r\n```python\r\nRetrieves download statistics for a given user or package(s) from PyPI Stats API.\r\n\r\nArgs:\r\n\tusername_or_packages (str | tuple | list): The username or package(s) to retrieve statistics for.\r\n\tIf a string is passed, username_or_packages will be treated as a username. If a list/tuple is passed,\r\n\tusername_or_packages will be treated as packages.\r\n\tsleeptime (float | int, optional): The time to sleep between API requests. Defaults to 1.0.\r\n\tclear_cache (bool, optional): Whether to clear the PyPI Stats API cache before retrieving statistics.\r\n\t\tDefaults to False.\r\n\r\nReturns:\r\n\tpd.DataFrame: A pandas DataFrame containing the download statistics for the given user or package(s).\r\n\r\nRaises:\r\n\tException: If an error occurs while retrieving statistics for a package.\r\n\r\n\r\n\r\n\r\n\r\nfrom pipuserstats import get_user_pip_stats\r\n\r\ndf = get_user_pip_stats(\r\n username_or_packages=\"hansalemao\", sleeptime=1, clear_cache=False\r\n)\r\nprint(df)\r\n\"\"\"\r\n# -1 means \"no data available\"\r\n total 2023-04-20 ... 2022-10-23 2022-10-22\r\na-cv-imwrite-imread-plus 3593 31 ... -1 -1\r\na-cv-sift-detection 244 -1 ... -1 -1\r\na-cv2-calculate-difference 279 2 ... -1 -1\r\na-cv2-calculate-simlilarity 339 2 ... -1 -1\r\na-cv2-easy-resize 2223 24 ... -1 -1\r\n ... ... ... ... ...\r\n\"\"\"\r\n\r\ndf = get_user_pip_stats(\r\n username_or_packages=[\"pandas\", \"numpy\"], sleeptime=0.5, clear_cache=False\r\n)\r\n\r\n\"\"\"\r\ndf\r\nOut[4]: \r\n total 2023-04-20 2023-04-19 ... 2022-10-24 2022-10-23 2022-10-22\r\npandas 639313100 4258267 4265098 ... 3721798 2540678 2738365\r\nnumpy 843036266 5667169 5747109 ... 4882242 3261557 3556995\r\n[2 rows x 181 columns]\r\n\"\"\"\r\n\t\r\n\"\"\"\r\n\r\n```\r\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "PyPi download statistics for several packages or for all packages from a user",
"version": "0.10",
"split_keywords": [
"pypi",
"stats"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "7e97741ba2366e70c594c2c27850c83a8160d4abed92badc9ed5368f796a1372",
"md5": "eb811d005314dea00644ccc2f585281c",
"sha256": "80ca8456cd3ba1d9ccd4b12c249ecde2e0ca834d65a3dcf953ea76e1e9e3a0d9"
},
"downloads": -1,
"filename": "pipuserstats-0.10-py3-none-any.whl",
"has_sig": false,
"md5_digest": "eb811d005314dea00644ccc2f585281c",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 11787,
"upload_time": "2023-04-21T04:20:06",
"upload_time_iso_8601": "2023-04-21T04:20:06.555001Z",
"url": "https://files.pythonhosted.org/packages/7e/97/741ba2366e70c594c2c27850c83a8160d4abed92badc9ed5368f796a1372/pipuserstats-0.10-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "7512122b85f568b1e933df30ccda402ae995dddf72572d3b0a83a8acdaf1bf31",
"md5": "e6c8d9a0b9ce0d8a04c1db8ac9281de3",
"sha256": "eb49cef2d3bc7008a22058b70c701904c1836c1d7847af66dfd0fc29f1967948"
},
"downloads": -1,
"filename": "pipuserstats-0.10.tar.gz",
"has_sig": false,
"md5_digest": "e6c8d9a0b9ce0d8a04c1db8ac9281de3",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 9398,
"upload_time": "2023-04-21T04:20:09",
"upload_time_iso_8601": "2023-04-21T04:20:09.150947Z",
"url": "https://files.pythonhosted.org/packages/75/12/122b85f568b1e933df30ccda402ae995dddf72572d3b0a83a8acdaf1bf31/pipuserstats-0.10.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-04-21 04:20:09",
"github": true,
"gitlab": false,
"bitbucket": false,
"github_user": "hansalemaos",
"github_project": "pipuserstats",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [],
"lcname": "pipuserstats"
}