Public dataset · Web, code and analytics
PyPI Downloads in BigQuery
The pypi dataset logs every file download from the Python Package Index, plus Simple API requests and package metadata. The two log tables are over 1 PiB each, partitioned by day and clustered by project: one package over 30 days reads about 11 GiB, while a careless query can read tens of TiB.
bigquery-public-data.pypi is the Python Package Index dataset. Its description says it is owned by the Python Software Foundation and licensed under Creative Commons Attribution 4.0. All three tables were last modified on the day these sizes were measured.
file_downloads has one row per file downloaded from PyPI, with the project, the file (filename, version, type), the country_code and a details record describing the client: installer, Python version, operating system, CPU and whether it ran in CI. simple_requests has no table description; its columns (url, project, details, http) match file_downloads minus the file record, consistent with logging requests to the Simple index pages that installers read to find files. It is even larger by row count. distribution_metadata holds package metadata per uploaded file (name, version, summary, license, requirements, classifiers and upload time).
The log tables are partitioned by day on timestamp and clustered by project; distribution_metadata is partitioned by month on upload_time. None of them requires a partition filter, so BigQuery will happily run a query that reads the whole history.
Tables and sizes
| Table | Rows | Size | Full scan | Layout |
|---|---|---|---|---|
file_downloadsOne row per file download. | 3,774,997,645,529 | 1.3 PiB | $8,449.61 | Partitioned: by day on timestamp · Clustered: project |
simple_requestsOne row per Simple API index request. | 6,198,370,440,940 | 1.2 PiB | $7,573.84 | Partitioned: by day on timestamp · Clustered: project |
distribution_metadataMetadata of every uploaded distribution file. | 26,445,964 | 176 GiB | $1.08 | Partitioned: by month on upload_time |
Example queries
Daily downloads of one package, last 30 days
Both filters do work: the date range prunes partitions and project = 'pandas' prunes clustered blocks. Change the project name for your own package.
SELECT
DATE(timestamp) AS day,
COUNT(*) AS downloads
FROM `bigquery-public-data.pypi.file_downloads`
WHERE project = 'pandas'
AND DATE(timestamp) BETWEEN DATE_SUB(CURRENT_DATE(), INTERVAL 30 DAY) AND DATE_SUB(CURRENT_DATE(), INTERVAL 1 DAY)
GROUP BY day
ORDER BY day;The same count without a date filter (expensive)
Clustering on project still keeps this far below the full table, but dropping the date filter makes it about 28 times more expensive than the 30-day query.
SELECT
DATE(timestamp) AS day,
COUNT(*) AS downloads
FROM `bigquery-public-data.pypi.file_downloads`
WHERE project = 'pandas'
GROUP BY day
ORDER BY day;Python versions downloading a package, yesterday
REGEXP_EXTRACT trims 3.12.4 style versions to 3.12. details.python can be NULL for clients that do not report it.
SELECT
REGEXP_EXTRACT(details.python, r'^\d+\.\d+') AS python_version,
COUNT(*) AS downloads
FROM `bigquery-public-data.pypi.file_downloads`
WHERE project = 'requests'
AND DATE(timestamp) = DATE_SUB(CURRENT_DATE(), INTERVAL 1 DAY)
GROUP BY python_version
ORDER BY downloads DESC;Most downloaded projects, yesterday
No project filter, so clustering cannot help: one day across all projects reads about 70 GiB.
SELECT project, COUNT(*) AS downloads
FROM `bigquery-public-data.pypi.file_downloads`
WHERE DATE(timestamp) = DATE_SUB(CURRENT_DATE(), INTERVAL 1 DAY)
GROUP BY project
ORDER BY downloads DESC
LIMIT 20;Release history of a package since 2024
distribution_metadata is partitioned by month on upload_time, so the date filter limits the scan to recent months.
SELECT version, MIN(upload_time) AS first_upload, ARRAY_AGG(DISTINCT packagetype) AS file_types
FROM `bigquery-public-data.pypi.distribution_metadata`
WHERE name = 'requests'
AND upload_time >= '2024-01-01'
GROUP BY version
ORDER BY first_upload DESC;Querying it cheaply
- Always filter
timestamp(orDATE(timestamp)) onfile_downloadsandsimple_requests. Theprojectcolumn alone is about 42 TiB across all partitions, andCOUNT(*)with atimestamp IS NOT NULLcondition reads about 27 TiB. - Filter on
projecttoo. The tables are clustered byproject, so a one-package query reads a small share of each day. SELECT *on a single day offile_downloadsreads about 1.4 TiB, more than the free monthly TiB. Name the columns, and avoid the widedetailsrecord unless you need it.- Set a maximum bytes billed on ad hoc queries so a missing filter fails instead of running (see the bytes billed limit error).
- If you report on your packages every week, aggregate daily counts into a small table of your own and query that.
FAQ
How much does it cost to query PyPI downloads in BigQuery?
A 30-day download count for one package reads about 11 GiB, inside the free 1 TiB a month. Without filters it gets expensive fast: one day of SELECT * is about 1.4 TiB, roughly $8.66 at the $6.25 per TiB on-demand list price.
Is the PyPI BigQuery dataset free?
Yes for storage: the data sits in the bigquery-public-data project and Google pays to store it. You pay for the queries you run from your own project. On-demand, the first 1 TiB scanned each month is free, then you pay per TiB scanned (see BigQuery pricing).
How do I count downloads for my Python package in BigQuery?
Query bigquery-public-data.pypi.file_downloads with WHERE project = 'your-package' and a DATE(timestamp) range, then COUNT(*) grouped by day, version (file.version) or installer (details.installer.name).
Which PyPI table should I use to count downloads?
file_downloads. The Python Packaging User Guide describes it as getting one entry for each download. simple_requests has no file column, so it cannot tell you which version or file was fetched.
Related datasets
All public datasets · BigQuery cost queries · Pricing calculator
