mirror of
https://github.com/LukeHagar/pypistats.org.git
synced 2025-12-06 04:21:09 +00:00
api etiquette and 503 routing if necessary to disable api in the future
This commit is contained in:
@@ -19,6 +19,20 @@
|
||||
<li>All download data is updated once daily.</li>
|
||||
</ul>
|
||||
</p>
|
||||
<h2>Etiquette</h2>
|
||||
<p>
|
||||
If you plan on using the API to download historical data for every python package in the database (e.g. for some
|
||||
personal data exploration), <b>DON'T</b>. This website runs on limited resources and you will degrade
|
||||
the site performance by doing this. It will also take a very long time.
|
||||
</p>
|
||||
<p>
|
||||
You are much better off extracting the data directly from the Google
|
||||
BigQuery <a href="https://bigquery.cloud.google.com/table/the-psf:pypi.downloads">pypi downloads tables</a>. You
|
||||
can query up to 1TB of data FREE every month before having to pay. The volume of data queried for this website
|
||||
falls well under that limit (each month of data is less than 100 GB queried) and you will have your data
|
||||
in a relatively short amount of time. <a
|
||||
href="https://packaging.python.org/guides/analyzing-pypi-package-downloads/">Here is a quick guide</a>.
|
||||
</p>
|
||||
<h2>API Client</h2>
|
||||
<p>
|
||||
The <a href="{{ url_for('general.package_page', package='pypistats') }}">pypistats</a> <a
|
||||
|
||||
@@ -54,6 +54,7 @@ def api_downloads_recent(package):
|
||||
@blueprint.route("/packages/<package>/overall")
|
||||
def api_downloads_overall(package):
|
||||
"""Get the overall download time series of a package."""
|
||||
# abort(503)
|
||||
package = package.replace(".", "-")
|
||||
mirrors = request.args.get("mirrors")
|
||||
if mirrors == "true":
|
||||
@@ -106,6 +107,7 @@ def api_downloads_system(package):
|
||||
|
||||
def generic_downloads(model, package, arg, name):
|
||||
"""Generate a generic response."""
|
||||
# abort(503)
|
||||
package = package.replace(".", "-")
|
||||
category = request.args.get(arg)
|
||||
if category is not None:
|
||||
|
||||
@@ -26,3 +26,9 @@ def handle_404(err):
|
||||
def handle_500(err):
|
||||
"""Return 500."""
|
||||
return "500", 500
|
||||
|
||||
|
||||
@blueprint.app_errorhandler(503)
|
||||
def handle_503(err):
|
||||
"""Return 500."""
|
||||
return "503 TEMPORARILY DISABLED", 503
|
||||
|
||||
Reference in New Issue
Block a user