Generate quote
const url = 'https://api.openfx.com/v1/brokerage/{orgId}/generate_quote';
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
amount: 1000,
buy: 'USDC',
sell: 'USD',
referencedUnit: 'USDC',
quoteForSeconds: 3
})
};
fetch(url, options)
.then(res => res.json())
.then(json => console.log(json))
.catch(err => console.error(err));import requests
url = "https://api.openfx.com/v1/brokerage/{orgId}/generate_quote"
payload = {
"amount": 1000,
"buy": "USDC",
"sell": "USD",
"referencedUnit": "USDC",
"quoteForSeconds": 3
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)HttpResponse<String> response = Unirest.post("https://api.openfx.com/v1/brokerage/{orgId}/generate_quote")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"amount\": 1000,\n \"buy\": \"USDC\",\n \"sell\": \"USD\",\n \"referencedUnit\": \"USDC\",\n \"quoteForSeconds\": 3\n}")
.asString();CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_WRITEDATA, stdout);
curl_easy_setopt(hnd, CURLOPT_URL, "https://api.openfx.com/v1/brokerage/{orgId}/generate_quote");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "Authorization: Bearer <token>");
headers = curl_slist_append(headers, "Content-Type: application/json");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "{\n \"amount\": 1000,\n \"buy\": \"USDC\",\n \"sell\": \"USD\",\n \"referencedUnit\": \"USDC\",\n \"quoteForSeconds\": 3\n}");
CURLcode ret = curl_easy_perform(hnd);package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.openfx.com/v1/brokerage/{orgId}/generate_quote"
payload := strings.NewReader("{\n \"amount\": 1000,\n \"buy\": \"USDC\",\n \"sell\": \"USD\",\n \"referencedUnit\": \"USDC\",\n \"quoteForSeconds\": 3\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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))
}curl --request POST \
--url https://api.openfx.com/v1/brokerage/{orgId}/generate_quote \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"amount": 1000,
"buy": "USDC",
"sell": "USD",
"referencedUnit": "USDC",
"quoteForSeconds": 3
}
'{
"status": "success",
"data": {
"quote": {
"id": "123e4567-e89b-12d3-a456-426614174000",
"userId": "123e4567-e89b-12d3-a456-426614174001",
"buy": "USD",
"sell": "USDC",
"referencedUnit": "USD",
"referencedAmount": 1000,
"quoteAmount": 999.800000007998,
"createdAt": "2024-11-25T15:05:34.945Z",
"expiryTimeinSeconds": 3
}
}
}{
"status": "error",
"message": "Query validation failed"
}{
"status": "error",
"message": "The authorization key provided is either invalid or expired, please try again"
}{
"status": "error",
"message": "Error while creating a quote, please try again later"
}Generate quote
Creates a quote for a currency pair and amount, returning a quote ID and rate valid for 3 seconds by default.
POST
/
v1
/
brokerage
/
{orgId}
/
generate_quote
Generate quote
const url = 'https://api.openfx.com/v1/brokerage/{orgId}/generate_quote';
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
amount: 1000,
buy: 'USDC',
sell: 'USD',
referencedUnit: 'USDC',
quoteForSeconds: 3
})
};
fetch(url, options)
.then(res => res.json())
.then(json => console.log(json))
.catch(err => console.error(err));import requests
url = "https://api.openfx.com/v1/brokerage/{orgId}/generate_quote"
payload = {
"amount": 1000,
"buy": "USDC",
"sell": "USD",
"referencedUnit": "USDC",
"quoteForSeconds": 3
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)HttpResponse<String> response = Unirest.post("https://api.openfx.com/v1/brokerage/{orgId}/generate_quote")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"amount\": 1000,\n \"buy\": \"USDC\",\n \"sell\": \"USD\",\n \"referencedUnit\": \"USDC\",\n \"quoteForSeconds\": 3\n}")
.asString();CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_WRITEDATA, stdout);
curl_easy_setopt(hnd, CURLOPT_URL, "https://api.openfx.com/v1/brokerage/{orgId}/generate_quote");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "Authorization: Bearer <token>");
headers = curl_slist_append(headers, "Content-Type: application/json");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "{\n \"amount\": 1000,\n \"buy\": \"USDC\",\n \"sell\": \"USD\",\n \"referencedUnit\": \"USDC\",\n \"quoteForSeconds\": 3\n}");
CURLcode ret = curl_easy_perform(hnd);package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.openfx.com/v1/brokerage/{orgId}/generate_quote"
payload := strings.NewReader("{\n \"amount\": 1000,\n \"buy\": \"USDC\",\n \"sell\": \"USD\",\n \"referencedUnit\": \"USDC\",\n \"quoteForSeconds\": 3\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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))
}curl --request POST \
--url https://api.openfx.com/v1/brokerage/{orgId}/generate_quote \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"amount": 1000,
"buy": "USDC",
"sell": "USD",
"referencedUnit": "USDC",
"quoteForSeconds": 3
}
'{
"status": "success",
"data": {
"quote": {
"id": "123e4567-e89b-12d3-a456-426614174000",
"userId": "123e4567-e89b-12d3-a456-426614174001",
"buy": "USD",
"sell": "USDC",
"referencedUnit": "USD",
"referencedAmount": 1000,
"quoteAmount": 999.800000007998,
"createdAt": "2024-11-25T15:05:34.945Z",
"expiryTimeinSeconds": 3
}
}
}{
"status": "error",
"message": "Query validation failed"
}{
"status": "error",
"message": "The authorization key provided is either invalid or expired, please try again"
}{
"status": "error",
"message": "Error while creating a quote, please try again later"
}v1 sunsets December 31, 2026. Migrate to v2 — see the migration guide.
- Get real-time exchange rates
- Lock in rates for trading
- Calculate exchange amounts
- Review applicable fees and margins
Idempotency is supported on v2 and v3 for this endpoint. v1 does not support idempotency keys — see Migration guide.
Errors
| Status | Message | Notes |
|---|---|---|
| 400 | Query validation failed | Request didn’t match schema (unsupported pair, bad amount, missing direction, etc.) |
| 401 | The authorization key provided is either invalid or expired, please try again | Mint a fresh JWT — see Authentication |
| 500 | Error while creating a quote, please try again later | Quote-engine failure. Distinct from the generic 500 — the request never reached trade execution; request a fresh quote |
Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Path Parameters
Body
application/json
⌘I