REST API Postman 集合(现货)

上次更新时间: 2025年4月1日

Postman 是一个流行的 API 测试环境,允许实现和测试 REST API 端点。

Postman 提供 HTTP 网络连接到 REST API,允许自定义 HTTP 标头和 GET/POST 数据,并允许使用 JavaScript 变体执行自定义代码。

可以通过集合(本质上是包含每个 API 端点配置和代码的 JSON 文件)将预定义实现导入到 Postman 中。

以下是我们的 现货 REST API 的 Postman 集合示例:

请注意,上述集合旨在演示 API 用法,因此它们并未实现所有可能的输入参数。可以通过查阅相应的 API 文档并使用提供的端点/参数作为示例,向集合中添加额外的端点和参数。

为方便快速参考,以下是 Postman 集合中 JSON 内容的示例:

bash

Bash

{
  "info": {
    "_postman_id": "b530d6e8-8aa3-403d-b8ab-1665d4606eab",
    "name": "Kraken REST API - GetWebSocketsToken Endpoint",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
  },
  "item": [
    {
      "name": "GetWebSocketsToken",
      "event": [
        {
          "listen": "prerequest",
          "script": {
            "id": "e11ed019-722d-4ecf-8ddf-1f724e5b1ab4",
            "exec": [
              "api_key = \"API PUBLIC KEY\"",
              "api_secret = CryptoJS.enc.Base64.parse(\"API PRIVATE KEY\");",
              "api_nonce = (Date.now() * 1000).toString();",
              "api_endpoint = \"/0/private/GetWebSocketsToken\";",
              "api_post = \"nonce=\" + api_nonce;",
              "",
              "api_sha256 = CryptoJS.SHA256(api_nonce + api_post);",
              "api_sign = CryptoJS.algo.HMAC.create(CryptoJS.algo.SHA512, api_secret);",
              "api_sign.update(api_endpoint, api_secret);",
              "api_sign.update(api_sha256, api_secret);",
              "api_sign = api_sign.finalize().toString(CryptoJS.enc.Base64);",
              "",
              "pm.globals.set(\"api_nonce\", api_nonce);",
              "pm.globals.set(\"api_key\", api_key);",
              "pm.globals.set(\"api_signature\", api_sign);"
            ],
            "type": "text/javascript"
          }
        }
      ],
      "request": {
        "auth": {
          "type": "noauth"
        },
        "method": "POST",
        "header": [
          {
            "key": "API-Key",
            "type": "text",
            "value": "{{api_key}}"
          },
          {
            "key": "API-Sign",
            "type": "text",
            "value": "{{api_signature}}"
          }
        ],
        "body": {
          "mode": "urlencoded",
          "urlencoded": [
            {
              "key": "nonce",
              "value": "{{api_nonce}}",
              "type": "text"
            }
          ]
        },
        "url": {
          "raw": "https://api.kraken.com/0/private/GetWebSocketsToken",
          "protocol": "https",
          "host": [
            "api",
            "kraken",
            "com"
          ],
          "path": [
            "0",
            "private",
            "GetWebSocketsToken"
          ]
        }
      },
      "response": []
    }
  ],
  "protocolProfileBehavior": {}
}

需要更多帮助吗?