# 查询汇率

> 查询不同源币种与目标币种之间的汇率，可同时传入源金额获得换算结果。

```yaml
openapi: 3.1.0
x-onerway-docs-version: original
x-onerway-spec-key: transfer/v3-transactions/query-exchange-rate
info:
  title: 查询汇率
  version: original
  description: 查询不同源币种与目标币种之间的汇率，可同时传入源金额获得换算结果。
servers:
  - url: https://sandbox-transfer-api.onerway.com
    description: sandbox
  - url: https://transfer-api.onerway.com
    description: production
paths:
  /api/v3/acct/queryExchangeRate:
    post:
      summary: 查询汇率
      description: 查询不同源币种与目标币种之间的汇率，可同时传入源金额获得换算结果。
      parameters:
        - name: ApiKey
          in: header
          required: true
          description: Onerway 分配的账户服务 API key 请求 Header；必须使用与请求域名相同环境的值。
          schema:
            type: string
            description: Onerway 分配的账户服务 API key 请求 Header；必须使用与请求域名相同环境的值。
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                sourceCurrency:
                  type: string
                  description: 源币种，参见[币种枚举](/zh/transfer/api-reference/v3-enums#币种枚举)。
                targetCurrency:
                  type: string
                  description: 目标币种，参见[币种枚举](/zh/transfer/api-reference/v3-enums#币种枚举)。
                  x-onerway-constraints:
                    - kind: rule
                      text: 不可与 sourceCurrency 相同。
                sourceAmount:
                  type: number
                  description: 以 `sourceCurrency` 计价的源金额。
                onBehalfOf:
                  type: string
                  description: 请求实际对应的商户号，仅在代其他商户发起请求时填写。
              required:
                - sourceCurrency
                - targetCurrency
            examples:
              default:
                summary: 请求结构示例（替换为当前商户数据）
                value:
                  sourceCurrency: USD
                  targetCurrency: EUR
                  sourceAmount: 100
      responses:
        "200":
          description: 成功示例
          content:
            application/json:
              schema:
                anyOf:
                  - type: object
                    properties:
                      respCode:
                        type: string
                        description: 响应码；`20000` 表示请求处理成功，其余为错误码。
                      respMsg:
                        type: string
                        description: 响应码对应的可读说明。
                      data:
                        type: object
                        properties:
                          sourceAmount:
                            type: number
                            description: 以 `sourceCurrency` 计价的源金额。
                          sourceCurrency:
                            type: string
                            description: 源币种，参见[币种枚举](/zh/transfer/api-reference/v3-enums#币种枚举)。
                          targetAmount:
                            type: number
                            description: 以 `targetCurrency` 计价的目标金额。
                          targetCurrency:
                            type: string
                            description: 目标币种，参见[币种枚举](/zh/transfer/api-reference/v3-enums#币种枚举)。
                          conversionRate:
                            type: number
                            description: 本次查询的换算汇率
                          quoteTime:
                            type: string
                            description: 本次查询的报价时间；时区：北京时间（UTC+8）。
                            x-onerway-constraints:
                              - kind: rule
                                text: yyyy-MM-dd HH:mm:ss; UTC+08:00
                        description: 成功业务数据；失败不作为有效业务数据读取
                      error:
                        type: object
                        properties:
                          type:
                            type: string
                            description: 错误类型。
                          code:
                            type: string
                            description: 本接口错误标识。
                          declineCode:
                            type: string
                            description: 拒绝原因码，可能为空。
                          message:
                            type: string
                            description: 错误详细说明
                          param:
                            type: string
                            description: 失败字段或条件；无法定位时可能为空
                          docUrl:
                            type: string
                            description: 错误文档链接，可能为空。
                          requestId:
                            type: string
                            description: 服务端错误跟踪标识，req_ + 32 位十六进制字符；不是商户请求编号
                          errorDetails:
                            type: array
                            description: 具体错误明细；见下列分支
                            items:
                              type: object
                              properties:
                                errorCode:
                                  type: string
                                  description: 业务或校验明细码。
                                message:
                                  type: string
                                  description: 明细说明
                        description: 结构化失败信息；并非每个失败分支都有该字段
                  - type: object
                    properties:
                      respCode:
                        type: string
                      respMsg:
                        type: string
                      error:
                        type: object
                        properties:
                          type:
                            type: string
                          code:
                            type: string
                          message:
                            type: string
                          requestId:
                            type: string
                          errorDetails:
                            type: array
                            items:
                              type: object
                              properties:
                                errorCode:
                                  type: string
                                message:
                                  type: string
                              required:
                                - errorCode
                                - message
                          param:
                            type: string
                        required:
                          - type
                          - code
                          - message
                          - requestId
                          - errorDetails
                          - param
                    required:
                      - respCode
                      - respMsg
                      - error
              examples:
                "40004":
                  summary: sourceAmount 为负数。
                  description: sourceAmount 为负数。
                  value:
                    respCode: "40004"
                    respMsg: Illegal parameter [sourceAmount]
                    error:
                      type: validation_error
                      code: "40004"
                      message: Illegal parameter [sourceAmount]
                      requestId: req_00000000000000000000000000000001
                      errorDetails:
                        - errorCode: "40004"
                          message: Illegal parameter [sourceAmount]
                      param: sourceAmount
                success:
                  summary: 成功示例
                  value:
                    respCode: "20000"
                    respMsg: Success
                    data:
                      sourceCurrency: USD
                      sourceAmount: 100
                      targetCurrency: EUR
                      targetAmount: 92
                      conversionRate: 0.92
                      quoteTime: 2026-01-15 10:00:00
                failure:
                  summary: sourceAmount 为负数。
                  value:
                    respCode: "40004"
                    respMsg: Illegal parameter [sourceAmount]
                    error:
                      type: validation_error
                      code: "40004"
                      message: Illegal parameter [sourceAmount]
                      requestId: req_00000000000000000000000000000001
                      errorDetails:
                        - errorCode: "40004"
                          message: Illegal parameter [sourceAmount]
                      param: sourceAmount
```
