Contact Us

If you still have questions or prefer to get help directly from an agent, please submit a request.
We’ll get back to you as soon as possible.

Please fill out the contact form below and we will reply as soon as possible.

  • Become a customer
  • Contact Us
Chinese
US English (US)
FR French
ES Spanish
JP Japanese
BR Portuguese (Brazil)
CN Chinese
  • Home

Fastmarkets 认证 API

Written by Connor Bevans

Updated at February 4th, 2026

Contact Us

If you still have questions or prefer to get help directly from an agent, please submit a request.
We’ll get back to you as soon as possible.

Please fill out the contact form below and we will reply as soon as possible.

+ More

Table of Contents

Fastmarkets认证 API 生成访问令牌 请求示例: 回复示例: 技术API信息 更多帮助

Fastmarkets认证 API

所有的 Fastmarkets API 都采用了成熟可靠的现代安全标准。包括使用OAuth 2.0、OpenID Connect 和 JSON Web Tokens。

Fastmarkets data的客户通常有自己的能使用和处理数据的服务。因此,基于单个用户凭证的验证方式并不适用。为此,Fastmarkets分配唯一的服务密钥和服务名称,用于生成访问令牌来调用Fastmarkets认证API。返回的访问令牌(以 JSON Web Token 的形式)用于对其他Fastmarkets API(例如Fastmarkets Physical Prices API)的调用,用以验证调用服务是否拥有查看所请求数据的必要权限。

生成访问令牌

如以下示例所示,使用提供的服务密钥和服务名称访问Fastmarkets Authentication API ,需要一个POST Connect Token请求。响应包含访问令牌本身、过期时间(以秒为单位)以及访问令牌类型(始终为“Bearer”类型)。

请求示例:

import requests # use requests library
import json # use json library
url = "https://auth.fastmarkets.com/connect/token"
payload = {
		   'grant_type': 'servicekey',
		   'client_id': 'service_client',
		   'scope': 'fastmarkets.physicalprices.api',
		   'serviceName': 'service_name',
		   'serviceKey': 'service_key'
		   }
header = {'Content-Type': "application/x-www-form-urlencoded"}

token_response = requests.post(url, data = payload, headers = header)
accessToken = json.loads(token_response.content)

其中的 service_name 和 service_key 应替换成您自己的服务名称和服务密钥。

回复示例:

{
"access_token": "eyJhbGciOiJSUzI1NiIsImtpZCI6IjdjZTkyOTQ4NDk0ODRkMDM4YzQ0N...eEJkMWKgeY4vumE1RY-h4pC1CT6w",
"expires_in":7200,
"token_type":"Bearer"
}

请注意访问令牌将会过期。响应中有到期时间。这是经过设计的。 根据要求,在以下这些情况下需要生成新的访问令牌:

1. 在每次向需要访问令牌的 API 发出请求之前(例如 the Physical Prices API) - 如果频繁发出数据请求,这可能会效率低下,但可以适用于无状态处理。

2. 当当前访问令牌即将过期时——通过Connect Token请求返回的“expires in”值以秒为单位提供过期时间。或者,解码 JSON Web 令牌 (JWT) 本身会显示一个名为“exp”的参数,其中包含表示过期时间的时间戳值。

3. 从 API 收到状态码 401(未授权)响应时

 

技术API信息

如需了解更多关于我们 API 的信息,请参阅API 技术信息。

 

更多帮助


如果您还有其他问题或需要进一步的帮助,请查看我们⁠支持中心提供的所有帮助内容。

如果您找不到所需信息并希望联系我们的支持团队,那么⁠让我们为您提供帮助吧。

 

 

Was this article helpful?

Yes
No
Give feedback about this article

Related Articles

  • 预约线上培训研讨会
  • 下载并安装 Excel Add-in

Copyright 2026 – Fastmarkets.

Knowledge Base Software powered by Helpjuice

Expand