Create Quote
curl --request POST \
--url https://api-sandbox.uqpaytech.com/api/v1/conversion/quote \
--header 'Content-Type: application/json' \
--header 'x-auth-token: <api-key>' \
--header 'x-idempotency-key: <x-idempotency-key>' \
--data '
{
"sell_currency": "USD",
"buy_currency": "SGD",
"conversion_date": "2024-08-26",
"sell_amount": "1000.00",
"buy_amount": "1000.00"
}
'import requests
url = "https://api-sandbox.uqpaytech.com/api/v1/conversion/quote"
payload = {
"sell_currency": "USD",
"buy_currency": "SGD",
"conversion_date": "2024-08-26",
"sell_amount": "1000.00",
"buy_amount": "1000.00"
}
headers = {
"x-idempotency-key": "<x-idempotency-key>",
"x-auth-token": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'x-idempotency-key': '<x-idempotency-key>',
'x-auth-token': '<api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
sell_currency: 'USD',
buy_currency: 'SGD',
conversion_date: '2024-08-26',
sell_amount: '1000.00',
buy_amount: '1000.00'
})
};
fetch('https://api-sandbox.uqpaytech.com/api/v1/conversion/quote', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api-sandbox.uqpaytech.com/api/v1/conversion/quote",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'sell_currency' => 'USD',
'buy_currency' => 'SGD',
'conversion_date' => '2024-08-26',
'sell_amount' => '1000.00',
'buy_amount' => '1000.00'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-auth-token: <api-key>",
"x-idempotency-key: <x-idempotency-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api-sandbox.uqpaytech.com/api/v1/conversion/quote"
payload := strings.NewReader("{\n \"sell_currency\": \"USD\",\n \"buy_currency\": \"SGD\",\n \"conversion_date\": \"2024-08-26\",\n \"sell_amount\": \"1000.00\",\n \"buy_amount\": \"1000.00\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-idempotency-key", "<x-idempotency-key>")
req.Header.Add("x-auth-token", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api-sandbox.uqpaytech.com/api/v1/conversion/quote")
.header("x-idempotency-key", "<x-idempotency-key>")
.header("x-auth-token", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"sell_currency\": \"USD\",\n \"buy_currency\": \"SGD\",\n \"conversion_date\": \"2024-08-26\",\n \"sell_amount\": \"1000.00\",\n \"buy_amount\": \"1000.00\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-sandbox.uqpaytech.com/api/v1/conversion/quote")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-idempotency-key"] = '<x-idempotency-key>'
request["x-auth-token"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"sell_currency\": \"USD\",\n \"buy_currency\": \"SGD\",\n \"conversion_date\": \"2024-08-26\",\n \"sell_amount\": \"1000.00\",\n \"buy_amount\": \"1000.00\"\n}"
response = http.request(request)
puts response.read_body{
"sell_currency": "USD",
"sell_amount": "100",
"buy_currency": "SGD",
"buy_amount": "135.02",
"quote_price": {
"currency_pair": "USDSGD",
"direct_rate": "1.358663",
"inverse_rate": "0.736018",
"quote_id": "4e70729d-36dd-4465-80a2-f7282bf46bfa",
"validity": {
"valid_from": 1724393057882,
"valid_to": 1724393132882
}
}
}Conversion
Create Quote
创建一个用于换汇的新 FX 报价。返回的汇率已包含 UQPAY 的加价,反映报价有效期内适用的最终汇率。
使用说明
- 在执行换汇或跨币种 payout 前需要先获取报价。
- 生成的报价必须在其有效期(75 秒)内使用,超时后如有需要须重新请求报价。
- 同时指定
buy_currency和sell_currency,但buy_amount与sell_amount只定义其中之一。所定义的金额代表交易(固定)的一方,另一方金额将根据 UQPAY 的汇率自动计算。 - 使用特定
transaction_type创建的报价只能用于对应的操作,不允许混用。- 换汇报价必须配合创建换汇使用。
- payout 报价必须配合创建 Payout 使用。
POST
/
v1
/
conversion
/
quote
Create Quote
curl --request POST \
--url https://api-sandbox.uqpaytech.com/api/v1/conversion/quote \
--header 'Content-Type: application/json' \
--header 'x-auth-token: <api-key>' \
--header 'x-idempotency-key: <x-idempotency-key>' \
--data '
{
"sell_currency": "USD",
"buy_currency": "SGD",
"conversion_date": "2024-08-26",
"sell_amount": "1000.00",
"buy_amount": "1000.00"
}
'import requests
url = "https://api-sandbox.uqpaytech.com/api/v1/conversion/quote"
payload = {
"sell_currency": "USD",
"buy_currency": "SGD",
"conversion_date": "2024-08-26",
"sell_amount": "1000.00",
"buy_amount": "1000.00"
}
headers = {
"x-idempotency-key": "<x-idempotency-key>",
"x-auth-token": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'x-idempotency-key': '<x-idempotency-key>',
'x-auth-token': '<api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
sell_currency: 'USD',
buy_currency: 'SGD',
conversion_date: '2024-08-26',
sell_amount: '1000.00',
buy_amount: '1000.00'
})
};
fetch('https://api-sandbox.uqpaytech.com/api/v1/conversion/quote', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api-sandbox.uqpaytech.com/api/v1/conversion/quote",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'sell_currency' => 'USD',
'buy_currency' => 'SGD',
'conversion_date' => '2024-08-26',
'sell_amount' => '1000.00',
'buy_amount' => '1000.00'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-auth-token: <api-key>",
"x-idempotency-key: <x-idempotency-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api-sandbox.uqpaytech.com/api/v1/conversion/quote"
payload := strings.NewReader("{\n \"sell_currency\": \"USD\",\n \"buy_currency\": \"SGD\",\n \"conversion_date\": \"2024-08-26\",\n \"sell_amount\": \"1000.00\",\n \"buy_amount\": \"1000.00\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-idempotency-key", "<x-idempotency-key>")
req.Header.Add("x-auth-token", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api-sandbox.uqpaytech.com/api/v1/conversion/quote")
.header("x-idempotency-key", "<x-idempotency-key>")
.header("x-auth-token", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"sell_currency\": \"USD\",\n \"buy_currency\": \"SGD\",\n \"conversion_date\": \"2024-08-26\",\n \"sell_amount\": \"1000.00\",\n \"buy_amount\": \"1000.00\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-sandbox.uqpaytech.com/api/v1/conversion/quote")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-idempotency-key"] = '<x-idempotency-key>'
request["x-auth-token"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"sell_currency\": \"USD\",\n \"buy_currency\": \"SGD\",\n \"conversion_date\": \"2024-08-26\",\n \"sell_amount\": \"1000.00\",\n \"buy_amount\": \"1000.00\"\n}"
response = http.request(request)
puts response.read_body{
"sell_currency": "USD",
"sell_amount": "100",
"buy_currency": "SGD",
"buy_amount": "135.02",
"quote_price": {
"currency_pair": "USDSGD",
"direct_rate": "1.358663",
"inverse_rate": "0.736018",
"quote_id": "4e70729d-36dd-4465-80a2-f7282bf46bfa",
"validity": {
"valid_from": 1724393057882,
"valid_to": 1724393132882
}
}
}授权
由 UQPAY 提供的登录 API Token。
请求头
用于保持操作幂等性的唯一标识符(UUID),确保同一操作的重复执行不会产生意外影响或重复。它有助于在网络错误、重试或失败时保持数据一致性。
请求体
application/json
卖出的币种。
在跨币种 payout 场景下,这应为汇款方账户中的币种。
示例:从 USD 账户向受益人付出 SGD,则设置 sell_currency = USD。
示例:
"USD"
买入的币种。
在跨币种 payout 场景下,这应为受益人将收到的币种。
示例:从 USD 账户向受益人付出 SGD,则设置 buy_currency = SGD。
示例:
"SGD"
指定将执行换汇的预定日期。该日期应为有效的工作日。
示例:
"2024-08-26"
sell_currency 的金额。
示例:
"1000.00"
buy_currency 的金额。
示例:
"1000.00"
交易类型。
conversion:默认值。仅用于换汇。payout:仅用于跨币种 payout。
可用选项:
conversion, payout 
