Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: move stats API to user docs #17161

Merged
merged 2 commits into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 4 additions & 43 deletions docs/dev/api-reference/stats.rst
Original file line number Diff line number Diff line change
@@ -1,48 +1,9 @@
Stats API
=========

PyPI offers a JSON stats endpoint via a ``Accept: application/json`` GET
request. Without the ``Accept`` header set, you will be returned a HTML page.
.. important::

**Example Client**: https://github.com/cooperlees/pypistats
This API documentation has been migrated to a new page in
the `user documentation <https://docs.pypi.org/>`_:

Project
-------

.. http:get:: /stats/

Returns statistics in JSON format. This includes:
- Total size of PyPI packages in bytes
- Top 100 packages + their size in bytes

**Example Request**:

- `curl -H "Accept: application/json" https://pypi.org/stats/`

.. code:: http

GET /stats HTTP/1.1
Host: pypi.org
Accept: application/json

**Example response**:

.. code:: json

{
"top_packages": {
"CodeIntel": {
"size": 23767329521
},
"Fiona": {
"size": 6209535709
},
"FlexGet": {
"size": 4387002448
},
"...": "..."
},
"total_packages_size": 23965450269
}

:statuscode 200: no error
* `Stats API <https://docs.pypi.org/api/stats/>`_
7 changes: 7 additions & 0 deletions docs/mkdocs-user-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ markdown_extensions:
- pymdownx.emoji:
emoji_index: !!python/name:material.extensions.emoji.twemoji
emoji_generator: !!python/name:material.extensions.emoji.to_svg
- pymdownx.magiclink:
repo_url_shorthand: true
normalize_issue_symbols: true
provider: github
user: pypi
repo: warehouse
theme:
name: material
logo: assets/logo.png
Expand Down Expand Up @@ -84,3 +90,4 @@ nav:
- "api/index-api.md"
- "api/upload.md"
- "api/integrity.md"
- "api/stats.md"
53 changes: 53 additions & 0 deletions docs/user/api/stats.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Stats API

!!! important

You **must** set `Accept: application/json` in your requests to this API.
Without the `Accept` header, you will be returned an HTML page.

!!! tip

An example stats API client can be found at @coopherlees/pypistats.

## Routes

### Project stats

Route: `GET /stats/`

Returns statistics in JSON format. This includes:

- Total size of PyPI packages in bytes
- Top 100 packages + their size in bytes

Status codes:

* `200 OK` - no error

Example request:

```http
GET /stats HTTP/1.1
Host: pypi.org
Accept: application/json
```

??? note "Example JSON response"

```json
{
"top_packages": {
"CodeIntel": {
"size": 23767329521
},
"Fiona": {
"size": 6209535709
},
"FlexGet": {
"size": 4387002448
},
"...": "..."
},
"total_packages_size": 23965450269
}
```
Loading