pypi-api.md (2016B)
1 --- 2 label: PyPI API 3 icon: package-dependents 4 order: 520 5 --- 6 7 # PyPI API 8 9 **Base URL:** `https://notamitgamer-osma-pypi-api.hf.space` 10 11 ## GET /ping 12 13 Uptime check — always returns 200. Lightweight endpoint for UptimeRobot or health monitors; doesn't query the database. 14 15 ```bash 16 curl https://notamitgamer-osma-pypi-api.hf.space/ping 17 ``` 18 19 ```json 20 { "ping": "pong" } 21 ``` 22 23 ## GET /health 24 25 Server status + total package count. Returns `200` when the database is ready; returns `503` during cold-start initialization. 26 27 ```bash 28 curl https://notamitgamer-osma-pypi-api.hf.space/health 29 ``` 30 31 ```json 32 { 33 "status": "ok", 34 "total_packages": 780432 35 } 36 ``` 37 38 ## GET /stats 39 40 Total package count and dataset source metadata. 41 42 ```bash 43 curl https://notamitgamer-osma-pypi-api.hf.space/stats 44 ``` 45 46 ```json 47 { 48 "total_pypi_packages": 780432, 49 "source": "pypi.org", 50 "note": "Snapshot dataset — updated periodically." 51 } 52 ``` 53 54 ## GET /browse 55 56 Paginated package list, ordered by `package_no`. 57 58 | Parameter | Type | Default | Max | Required | Description | 59 |---|---|---|---|---|---| 60 | `page` | integer | 1 | — | optional | Page number, 1-indexed | 61 | `limit` | integer | 200 | 500 | optional | Rows per page | 62 63 ```bash 64 curl "https://notamitgamer-osma-pypi-api.hf.space/browse?page=1&limit=5" 65 ``` 66 67 ```json 68 { 69 "page": 1, 70 "limit": 5, 71 "results": [ 72 { "no": 1, "name": "0", "version": "0.1.0", "url": "https://pypi.org/project/0/" } 73 ] 74 } 75 ``` 76 77 ## GET /search 78 79 Ranked search across all packages. `0` = exact match, `1` = starts-with, `2` = contains. 80 81 | Parameter | Type | Default | Max | Required | Description | 82 |---|---|---|---|---|---| 83 | `q` | string | — | 100 chars | required | Search query, min 2 characters | 84 | `limit` | integer | 250 | 500 | optional | Max results to return | 85 86 ```bash 87 curl "https://notamitgamer-osma-pypi-api.hf.space/search?q=requests&limit=5" 88 ``` 89 90 ```json 91 { 92 "query": "requests", 93 "count": 87, 94 "results": [ 95 { "no": 512, "name": "requests", "version": "2.31.0", "url": "...", "rank": 0 } 96 ] 97 } 98 ```