Skip to content

索引 API

本页面记录了 PyPI 对 PEP 503 (HTML) 和PEP 691 (JSON) 索引 API 的实现。

有关此 API 的官方实时规范,请参阅Simple Repository API 。

笔记

索引 API 有时被称为“传统 API”,因为它提供了与 PyPI 传统代码库相同的功能。

笔记

此API同时支持HTML和JSON格式。

建议新的集成使用 JSON 版本。

路线

列出所有项目

路线:GET /simple/

返回所有已注册的项目。

响应头:

  • X-PyPI-Last-Serial- 任何项目的最新序列号。

状态码:

  • 200 OK无错误

HTML

HTML 请求示例(如果未Accept传递请求头,则使用默认值):

GET /simple/ HTTP/1.1
Host: pypi.org
Accept: application/vnd.pypi.simple.v1+html
示例 HTML 响应
HTTP/1.0 200 OK
Content-Type: application/vnd.pypi.simple.v1+html
X-PyPI-Last-Serial: 24888689

<html>
  <head>
    <meta name="pypi:repository-version" content="1.4">
    <title>Simple index</title>
  </head>
  <body>
    <a href="/simple/0/">0</a>
    <a href="/simple/0-0/">0-._.-._.-._.-._.-._.-._.-0</a>
    <!-- More projects... -->
  </body>
</html>

JSON

JSON 请求示例:

GET /simple/ HTTP/1.1
Host: pypi.org
Accept: application/vnd.pypi.simple.v1+json
示例 JSON 响应
HTTP/1.1 200 OK
Content-Type: application/vnd.pypi.simple.v1+json
X-PyPI-Last-Serial: 24888689

{
  "meta": {
    "_last-serial": 24888689,
    "api-version": "1.4"
  },
  "projects": [
    {
      "_last-serial": 3075854,
      "name": "0"
    },
    {
      "_last-serial": 1448421,
      "name": "0-._.-._.-._.-._.-._.-._.-0"
    },
    "More projects..."
  ]
}

获取项目分布

路线:GET /simple/<project>/

获取所有可用版本(wheel 和源代码发行版)的分发下载 URL 。project项目匹配不区分大小写_,逗号-和空格视为等效字符。链接可以选择性地包含使用 URL片段的哈希值。该片段的. 格式 为` <hash_name> : #<hashname>=<hexdigest>...md5sha1sha224sha256sha384sha512

如果 PyPI 中存在某个分发文件的 PGP/GPG 签名,则该签名可通过与文件相同的 URL 访问.asc,但此 URL 列表中不包含指向该签名的链接。因此,一旦您拥有一个 wheel 或 sdist 文件名(例如 `<wheel_name>`) ,您可以使用单独的请求https://file.pythonhosted.org/.../foo-1.0.tar.gz来检查该签名是否存在 。https://file.pythonhosted.org/.../foo-1.0.tar.gz.ascGET

响应头:

  • X-PyPI-Last-Serial- 项目的最新序列号。

状态码:

  • 200 OK无错误

HTML

HTML 请求示例(如果未Accept传递请求头,则使用默认值):

GET /simple/beautifulsoup4/ HTTP/1.1
Host: pypi.org
Accept: application/vnd.pypi.simple.v1+html
示例 HTML 响应
HTTP/2 200 OK
Content-Type: application/vnd.pypi.simple.v1+html
Etag: "q4SqZutq1tfRDqhh3zQ4gQ"
X-PyPI-Last-Serial: 2857110

<!DOCTYPE html>
<html>
  <head>
    <meta name="pypi:repository-version" content="1.4">
    <meta name="pypi:project-status" content="active">
    <title>Links for beautifulsoup4</title>
  </head>
  <body>
    <h1>Links for beautifulsoup4</h1>
    <a href="https://files.pythonhosted.org/packages/6f/be/99dcf74d947cc1e7abef5d0c4572abcb479c33ef791d94453a8fd7987d8f/beautifulsoup4-4.0.1.tar.gz#sha256=dc6bc8e8851a1c590c8cc8f25915180fdcce116e268d1f37fa991d2686ea38de" >beautifulsoup4-4.0.1.tar.gz</a><br />
    <a href="https://files.pythonhosted.org/packages/a0/75/db36172ea767dd2f0c9817a99e24f7e9b79c2ce63eb2f8b867284cc60daf/beautifulsoup4-4.0.2.tar.gz#sha256=353792f8246a9551b232949fb14dce21d9b6ced9207bf9f4a69a4c4eb46c8127" >beautifulsoup4-4.0.2.tar.gz</a><br />
    <!-- ...More files... -->
    <a href="https://files.pythonhosted.org/packages/14/7e/e4313dad823c3a0751c99b9bc0182b1dd19aea164ce7445e9a70429b9e92/beautifulsoup4-4.13.0b2-py3-none-any.whl#sha256=7e05ad0b6c26108d9990e2235e8a9b4e2c03ead6f391ceb60347f8ebea6b80ba" data-requires-python="&gt;=3.6.0" data-dist-info-metadata="sha256=d0aa787c2b55e5b0b3aff66f137cf33341c5e781cb87b4dc184cbb25c7ac0ab5" data-core-metadata="sha256=d0aa787c2b55e5b0b3aff66f137cf33341c5e781cb87b4dc184cbb25c7ac0ab5">beautifulsoup4-4.13.0b2-py3-none-any.whl</a><br />
    <a href="https://files.pythonhosted.org/packages/81/bd/c97d94e2b96f03d1c50bc9de04130e014eda89322ba604923e0c251eb02e/beautifulsoup4-4.13.0b2.tar.gz#sha256=c684ddec071aa120819889aa9e8940f85c3f3cdaa08e23b9fa26510387897bd5" data-requires-python="&gt;=3.6.0" >beautifulsoup4-4.13.0b2.tar.gz</a><br />
  </body>
</html>
<!--SERIAL 22406780-->

JSON

JSON 请求示例:

GET /simple/beautifulsoup4/ HTTP/1.1
Host: pypi.org
Accept: application/vnd.pypi.simple.v1+json
示例 JSON 响应
HTTP/2 200 OK
Content-Type: application/vnd.pypi.simple.v1+json
Etag: "hVGQAYl/eoNrx2H5FmPuXw"
X-PyPI-Last-Serial: 22406780

{
  "files": [
    {
      "core-metadata": false,
      "data-dist-info-metadata": false,
      "filename": "beautifulsoup4-4.0.1.tar.gz",
      "hashes": {
        "sha256": "dc6bc8e8851a1c590c8cc8f25915180fdcce116e268d1f37fa991d2686ea38de"
      },
      "requires-python": null,
      "size": 51024,
      "upload-time": "2014-01-21T05:35:05.558877Z",
      "url": "https://files.pythonhosted.org/packages/6f/be/99dcf74d947cc1e7abef5d0c4572abcb479c33ef791d94453a8fd7987d8f/beautifulsoup4-4.0.1.tar.gz",
      "yanked": false
    },
    {
      "core-metadata": false,
      "data-dist-info-metadata": false,
      "filename": "beautifulsoup4-4.0.2.tar.gz",
      "hashes": {
        "sha256": "353792f8246a9551b232949fb14dce21d9b6ced9207bf9f4a69a4c4eb46c8127"
      },
      "requires-python": null,
      "size": 51240,
      "upload-time": "2014-01-21T05:35:09.581933Z",
      "url": "https://files.pythonhosted.org/packages/a0/75/db36172ea767dd2f0c9817a99e24f7e9b79c2ce63eb2f8b867284cc60daf/beautifulsoup4-4.0.2.tar.gz",
      "yanked": false
    },
    "...More files...",
    {
      "core-metadata": {
        "sha256": "524392d64a088e56a4232f50d6edb208dc03105394652acb72c6d5fa64c89f3e"
      },
      "data-dist-info-metadata": {
        "sha256": "524392d64a088e56a4232f50d6edb208dc03105394652acb72c6d5fa64c89f3e"
      },
      "filename": "beautifulsoup4-4.12.3-py3-none-any.whl",
      "hashes": {
        "sha256": "b80878c9f40111313e55da8ba20bdba06d8fa3969fc68304167741bbf9e082ed"
      },
      "requires-python": ">=3.6.0",
      "size": 147925,
      "upload-time": "2024-01-17T16:53:12.779164Z",
      "url": "https://files.pythonhosted.org/packages/b1/fe/e8c672695b37eecc5cbf43e1d0638d88d66ba3a44c4d321c796f4e59167f/beautifulsoup4-4.12.3-py3-none-any.whl",
      "yanked": false
    },
    {
      "core-metadata": false,
      "data-dist-info-metadata": false,
      "filename": "beautifulsoup4-4.12.3.tar.gz",
      "hashes": {
        "sha256": "74e3d1928edc070d21748185c46e3fb33490f22f52a3addee9aee0f4f7781051"
      },
      "requires-python": ">=3.6.0",
      "size": 581181,
      "upload-time": "2024-01-17T16:53:17.902970Z",
      "url": "https://files.pythonhosted.org/packages/b3/ca/824b1195773ce6166d388573fc106ce56d4a805bd7427b624e063596ec58/beautifulsoup4-4.12.3.tar.gz",
      "yanked": false
    },
    {
      "core-metadata": {
        "sha256": "d0aa787c2b55e5b0b3aff66f137cf33341c5e781cb87b4dc184cbb25c7ac0ab5"
      },
      "data-dist-info-metadata": {
        "sha256": "d0aa787c2b55e5b0b3aff66f137cf33341c5e781cb87b4dc184cbb25c7ac0ab5"
      },
      "filename": "beautifulsoup4-4.13.0b2-py3-none-any.whl",
      "hashes": {
        "sha256": "7e05ad0b6c26108d9990e2235e8a9b4e2c03ead6f391ceb60347f8ebea6b80ba"
      },
      "requires-python": ">=3.6.0",
      "size": 179607,
      "upload-time": "2024-03-20T13:00:33.355932Z",
      "url": "https://files.pythonhosted.org/packages/14/7e/e4313dad823c3a0751c99b9bc0182b1dd19aea164ce7445e9a70429b9e92/beautifulsoup4-4.13.0b2-py3-none-any.whl",
      "yanked": false
    },
    {
      "core-metadata": false,
      "data-dist-info-metadata": false,
      "filename": "beautifulsoup4-4.13.0b2.tar.gz",
      "hashes": {
        "sha256": "c684ddec071aa120819889aa9e8940f85c3f3cdaa08e23b9fa26510387897bd5"
      },
      "requires-python": ">=3.6.0",
      "size": 550258,
      "upload-time": "2024-03-20T13:00:31.245327Z",
      "url": "https://files.pythonhosted.org/packages/81/bd/c97d94e2b96f03d1c50bc9de04130e014eda89322ba604923e0c251eb02e/beautifulsoup4-4.13.0b2.tar.gz",
      "yanked": false
    }
  ],
  "meta": {
    "_last-serial": 22406780,
    "api-version": "1.4"
  },
  "name": "beautifulsoup4",
  "project-status": {
    "status": "active"
  }
  "versions": [
    "4.0.1",
    "4.0.2",
    "...More versions...",
    "4.12.3",
    "4.13.0b2"
  ]
}