# Query an exchange rate

> Query an exchange rate between different source and target currencies, optionally supplying a source amount for conversion.

```yaml
openapi: 3.1.0
x-onerway-docs-version: original
x-onerway-spec-key: transfer/v3-transactions/query-exchange-rate
info:
  title: Query an exchange rate
  version: original
  description: Query an exchange rate between different source and target
    currencies, optionally supplying a source amount for conversion.
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: Query an exchange rate
      description: Query an exchange rate between different source and target
        currencies, optionally supplying a source amount for conversion.
      parameters:
        - name: ApiKey
          in: header
          required: true
          description: Account service API key assigned by Onerway, supplied in the
            request header. Use the key for the same environment as the request
            domain.
          schema:
            type: string
            description: Account service API key assigned by Onerway, supplied in the
              request header. Use the key for the same environment as the
              request domain.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                sourceCurrency:
                  type: string
                  description: Source currency. See [currency
                    enums](/transfer/api-reference/v3-enums#currency-enums).
                targetCurrency:
                  type: string
                  description: Target currency. See [currency
                    enums](/transfer/api-reference/v3-enums#currency-enums).
                  x-onerway-constraints:
                    - kind: rule
                      text: Must differ from sourceCurrency.
                sourceAmount:
                  type: number
                  description: Source amount denominated in `sourceCurrency`.
                onBehalfOf:
                  type: string
                  description: Merchant number that the request applies to. Supply it only when
                    making a request on behalf of another merchant.
              required:
                - sourceCurrency
                - targetCurrency
            examples:
              default:
                summary: Request structure (replace with your merchant data)
                value:
                  sourceCurrency: USD
                  targetCurrency: EUR
                  sourceAmount: 100
      responses:
        "200":
          description: Success example
          content:
            application/json:
              schema:
                anyOf:
                  - type: object
                    properties:
                      respCode:
                        type: string
                        description: Response code; `20000` indicates successful request processing. All
                          other values are error codes.
                      respMsg:
                        type: string
                        description: Human-readable description of the response code.
                      data:
                        type: object
                        properties:
                          sourceAmount:
                            type: number
                            description: Source amount denominated in `sourceCurrency`.
                          sourceCurrency:
                            type: string
                            description: Source currency. See [currency
                              enums](/transfer/api-reference/v3-enums#currency-enums).
                          targetAmount:
                            type: number
                            description: Target amount denominated in `targetCurrency`.
                          targetCurrency:
                            type: string
                            description: Target currency. See [currency
                              enums](/transfer/api-reference/v3-enums#currency-enums).
                          conversionRate:
                            type: number
                            description: Conversion rate returned by this query
                          quoteTime:
                            type: string
                            description: "Time of this rate query; time zone: Beijing time (UTC+8)."
                            x-onerway-constraints:
                              - kind: rule
                                text: yyyy-MM-dd HH:mm:ss; UTC+08:00
                        description: Business data on success; do not consume as valid business data on
                          failure
                      error:
                        type: object
                        properties:
                          type:
                            type: string
                            description: Error type.
                          code:
                            type: string
                            description: Endpoint error identifier.
                          declineCode:
                            type: string
                            description: Decline reason code; may be empty.
                          message:
                            type: string
                            description: Detailed error description
                          param:
                            type: string
                            description: Failed field or condition; may be empty when no field is identified
                          docUrl:
                            type: string
                            description: Link to error documentation; may be empty.
                          requestId:
                            type: string
                            description: Server-generated error trace identifier, req_ plus 32 hexadecimal
                              characters; not the merchant requestId
                          errorDetails:
                            type: array
                            description: Error details; see the variants below
                            items:
                              type: object
                              properties:
                                errorCode:
                                  type: string
                                  description: Business or validation detail code.
                                message:
                                  type: string
                                  description: Detail message
                        description: Structured failure information; not present for every failure path
                  - 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: Sending a negative sourceAmount.
                  description: Sending a negative 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: Success example
                  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: Sending a negative 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
```
