-
Notifications
You must be signed in to change notification settings - Fork 984
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: move stats API to user docs (#17161)
Signed-off-by: William Woodruff <william@trailofbits.com> Co-authored-by: Dustin Ingram <di@users.noreply.github.com>
- Loading branch information
Showing
3 changed files
with
64 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/>`_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
``` |